-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
base: develop
Are you sure you want to change the base?
Conversation
Documentation preview for this PR (built with commit c43c151; changes) is ready! 🎉 |
@@ -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 |
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.
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 ?
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.
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.
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.
ça marche.
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.
Merci beaucoup pour toutes tes relectures, David. |
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. |
Co-authored-by: Martin Rubey <[email protected]>
This is about using
all
orany
where possible.This was scripted using
ruff check --select=SIM110 --fix --unsafe-fixes src/sage
📝 Checklist