-
Notifications
You must be signed in to change notification settings - Fork 6
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
Anomalie cadre rose quand deux SAGE #463
base: main
Are you sure you want to change the base?
Conversation
return result | ||
|
||
@property | ||
def results_by_perimeter(self): |
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.
Je pense que ce serait intéressant d'ajouter un commentaire détaillé ici. À quoi sert cette méthode, pourquoi est-elle présente, etc. En l'état je suis obligé de tout déchiffrer pour essayer de comprendre, c'est un peu trop laborieux pour mon pauvre cerveau en manque de vacances :)
|
||
grouped_criteria = {} | ||
|
||
# Group the criteria by perimeter |
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.
Est-ce que ce code pourrait être avantageusement remplacé par l'utilisation de groupby ?
# Group the criteria by perimeter | ||
for criterion in criteria_list: | ||
perimeter = criterion.perimeter | ||
if perimeter not in grouped_criteria: |
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.
Il existe aussi l'outil defaultdict bien utile dans ce genre de cas :
grouped_criteria = defaultdict(list)
for criterion in criteria_list:
grouped_criteria[criterion.perimeter].append(criterion)
results_by_perimeter[perimeter] = result | ||
|
||
# sort based on the results cascade | ||
return dict( |
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.
Pas sûr d'avoir bien compris l'objectif ici, mais il me semble que les dictionnaires dans python ne sont pas ordonnés, donc aucune garantie que l'ordre renvoyé par sorted
soit conservé. Il existe OrderedDict éventuellement ? (Python a toujours la réponse :D)
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.
La feature est bien prise de tête, ça me semble donc impératif de bien clarifier le code correspondant. À part ça, c'est tout bon pour moi.
https://trello.com/c/kWgciXO7/1113-anomalie-cadre-rose-quand-deux-sage