Skip to content

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

Open
jakobj wants to merge 1 commit intoHappy-Algorithms-League:masterfrom
jakobj:maint/assert-valid-indices
Open

Make sure all individuals (parents and offspring) are assigned a valid, unique index#376
jakobj wants to merge 1 commit intoHappy-Algorithms-League:masterfrom
jakobj:maint/assert-valid-indices

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
@jakobj jakobj requested a review from HenrikMettler December 6, 2022 15:01
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

# 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