Skip to content

use ruff to auto-simplify SIM110 #40258

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

fchapoton
Copy link
Contributor

This is about using all or any where possible.

This was scripted using

ruff check --select=SIM110 --fix --unsafe-fixes src/sage

📝 Checklist

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

Copy link

github-actions bot commented Jun 15, 2025

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

@@ -399,7 +399,8 @@ def _m_to_p_on_basis(self, A):
def lt(s, t):
if s == t:
return False
return all(len([z for z in t if z.intersection(p)]) == 1 for p in s)
return all(len([1 for z in t if z.intersection(p)]) == 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any difference between building a list of 1's and a list of z values. My proposal was to (try to) avoid building a list and to directly count the number of items. But may be it is not faster to use sum ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oui, c'est vrai. Peut-etre que mon code prend un peu moins de memoire que le code d'origine. J'ai pas trop envie de micro-optimiser ici. On aurait besoin d'une fonction is_singleton qui dit False des qu'on arrive a iterer deux fois.

Copy link
Contributor

Choose a reason for hiding this comment

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

ça marche.

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.

@fchapoton
Copy link
Contributor Author

Merci beaucoup pour toutes tes relectures, David.

@dcoudert
Copy link
Contributor

Pas de souci. Espérons que le nombre total de relecteurs augmentera un jour... il y a plein de PR en attente pour lesquelles je suis incompétent. J'ai des PRs en attente. Il y a surement pas mal de PR à clore car abandonnées.

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