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

Anomalie cadre rose quand deux SAGE #463

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

pyDez
Copy link
Collaborator

@pyDez pyDez commented Oct 23, 2024

return result

@property
def results_by_perimeter(self):
Copy link
Collaborator

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
Copy link
Collaborator

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:
Copy link
Collaborator

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(
Copy link
Collaborator

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)

Copy link
Collaborator

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

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.

2 participants