-
-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
simplify some .extend in combinat #39342
simplify some .extend in combinat #39342
Conversation
Documentation preview for this PR (built with commit 6c58d92; changes) is ready! 🎉 |
@@ -1126,21 +1126,21 @@ def OA_10_205(): | |||
GDD = [[relabel[xx] for xx in B if xx in relabel] for B in pplane if p not in B] | |||
|
|||
# We turn the GDD into a PBD by extending the groups with a new point 204. | |||
GDD.extend([[relabel[xx] for xx in G]+[204] for G in groups]) | |||
GDD.extend([relabel[xx] for xx in G]+[204] for G in groups) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also avoid the [...]+[204]
from itertools import chain
GDD.extend(list(chain((relabel[xx] for xx in G), [204])) for G in groups)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this is not shorter..
@@ -1627,7 +1627,8 @@ def OA_10_796(): | |||
OA = OA_relabel(OA,17,47,blocks=[OA[0]]) # making sure [46]*17 is a block | |||
PBD = [[i*47+x for i,x in enumerate(B) if (x < 46 or i < 13)] for B in OA] | |||
extra_point = 10000 | |||
PBD.extend([list(range(i*47,(i+1)*47-int(i >= 13)))+[extra_point] for i in range(17)]) # Adding the columns | |||
PBD.extend(list(range(i*47,(i+1)*47-int(i >= 13)))+[extra_point] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here also, a smart use of chain
could avoid the addition of 2 lists.
@@ -545,7 +545,7 @@ def construction_q_x(k, q, x, check=True, explain_construction=False): | |||
# delete points. | |||
# | |||
# TD.extend([range(i*q,(i+1)*q) for i in range(x)]) | |||
TD.extend([list(range(i*q,(i+1)*q))+[p2] for i in range(x,q)]) | |||
TD.extend(list(range(i*q,(i+1)*q))+[p2] for i in range(x,q)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Proposed additional changes can be done in a future PR if relevant.
by avoiding lists inside if possible ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39342 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Frédéric Chapoton
by avoiding lists inside if possible ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39342 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Frédéric Chapoton
by avoiding lists inside if possible ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: sagemath#39342 Reported by: Frédéric Chapoton Reviewer(s): David Coudert, Frédéric Chapoton
by avoiding lists inside if possible
📝 Checklist