Skip to content
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

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

fchapoton
Copy link
Contributor

by avoiding lists inside if possible

📝 Checklist

  • The title is concise and informative.
  • The description explains in detail what this PR is about.

Copy link

Documentation preview for this PR (built with commit 6c58d92; changes) is ready! 🎉
This preview will update shortly after each push to this PR.

@@ -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)
Copy link
Contributor

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)

Copy link
Contributor Author

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]
Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Contributor

@dcoudert dcoudert left a 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.

vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 20, 2025
    
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
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 23, 2025
    
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
vbraun pushed a commit to vbraun/sage that referenced this pull request Jan 25, 2025
    
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
@vbraun vbraun merged commit 4764e7b into sagemath:develop Jan 27, 2025
21 of 26 checks passed
@fchapoton fchapoton deleted the simplify_extend_in_combinat branch January 27, 2025 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants