Skip to content

simplify some nested for loops #40439

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

Merged
merged 2 commits into from
Jul 25, 2025
Merged

Conversation

fchapoton
Copy link
Contributor

either using walrus or simpler syntax

📝 Checklist

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

@@ -955,7 +955,9 @@ def maximal_order(self, take_shortcuts=True, order_basis=None):
Order of Quaternion Algebra (-22, 210) with base ring Rational Field
with basis (1, i, 1/2*i + 1/2*j, 1/2 + 17/22*i + 1/44*k)

sage: for d in ( m for m in range(1, 750) if is_squarefree(m) ): # long time (3s)
sage: for d in range(1, 700): # long time (3s)
Copy link
Contributor

Choose a reason for hiding this comment

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

To make the test timing comparable with past versions I would keep the 750, but that's really only a personal opinion, feel free to ignore!

Suggested change
sage: for d in range(1, 700): # long time (3s)
sage: for d in range(1, 750): # long time (3s)

@mantepse
Copy link
Contributor

nice!

@fchapoton
Copy link
Contributor Author

I would myself use rather 600 than 750. So I put 700 as a middle step. In principle, tests are not supposed to be long and complicated.

@mantepse
Copy link
Contributor

I would myself use rather 600 than 750. So I put 700 as a middle step. In principle, tests are not supposed to be long and complicated.

So, then use a number such that it is no longer a long test. In a fresh session,

sage: all(QuaternionAlgebra(d).maximal_order(take_shortcuts=False).is_maximal() for d in range(1, 350) if is_squarefree(d))

seems to be on the very safe side.

Besides, I think that would also be the better form of the example, more precisely

            sage: Q = QuaternionAlgebra
            sage: all(Q(d).maximal_order(take_shortcuts=False).is_maximal()
            ....:     for d in range(1, 350) if is_squarefree(d))

@fchapoton
Copy link
Contributor Author

d'accord ! Voilà

@vbraun vbraun merged commit 5eb9eb7 into sagemath:develop Jul 25, 2025
18 of 23 checks passed
@fchapoton fchapoton deleted the nest_for_loops branch August 18, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants