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

Make sure all individuals (parents and offspring) are assigned a valid, unique index #376

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jakobj
Copy link
Member

@jakobj jakobj commented Dec 6, 2022

(as the title suggests)

closes #375

@jakobj jakobj added this to the 0.4.0 milestone Dec 6, 2022
Copy link
Contributor

@HenrikMettler HenrikMettler left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this :) Lgtm, a suggestion but maybe that makes the code less readable

@@ -142,6 +142,8 @@ def step(
# concatenating the parent population to the offspring
# population instead of the other way around
combined = offsprings + pop.parents
assert all(ind.idx is not None for ind in combined)
assert len(set(ind.idx for ind in combined)) == len(combined)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe below could be easier to understand? (No preference though, both ways should be fine)

assert len(set(ind.idx for ind in combined)) == len([int.idx for ind in combined])

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.

Assert runtime invariant: all individuals in MuPlusLambda::step need to have a non-None index
2 participants