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

Precondition check for 'XXXChromosome.of(Gene...)' factory methods #443

Closed
jenetics opened this issue Feb 8, 2019 · 1 comment
Closed
Assignees
Milestone

Comments

@jenetics
Copy link
Owner

jenetics commented Feb 8, 2019

The factory methods for the numeric chromosome, which takes a list of genes doesn't check the domain of the given genes. It assumes that they are the same an takes the range of the first gene for the whole chromosome.

IntegerChromosome ich = IntegerChromosome.of(
	IntegerGene.of(0, 100),
	IntegerGene.of(0, 200),
	IntegerGene.of(0, 300)
);

The code snippet above currently doesn't throw an exception. Instead it creates a new IntegerChromosome in the range of [0, 100]. The ranges of the other genes are ignored. This behaviour can lead to surprising results. The new behaviour should be to throw an IAE if the ranges of the given genes are different.

@jenetics jenetics self-assigned this Feb 8, 2019
@jenetics jenetics added this to the v4.4.0 milestone Feb 8, 2019
jenetics added a commit that referenced this issue Feb 8, 2019
Add checks when chromosome is created with gene array.
jenetics added a commit that referenced this issue Feb 8, 2019
@jenetics
Copy link
Owner Author

jenetics commented Feb 8, 2019

Merged into r4.4.0 branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant