Skip to content

fix(base.Fitness): fitness value contains np.nan is now invalid#445

Open
yxliang01 wants to merge 1 commit intoDEAP:masterfrom
yxliang01:patch-3
Open

fix(base.Fitness): fitness value contains np.nan is now invalid#445
yxliang01 wants to merge 1 commit intoDEAP:masterfrom
yxliang01:patch-3

Conversation

@yxliang01
Copy link
Copy Markdown
Contributor

This fixes #440 .

@yxliang01 yxliang01 changed the title fix(base.Fitness): fitness contains np.nan is now invalid fix(base.Fitness): fitness value contains np.nan is now invalid Dec 12, 2019
Comment thread deap/base.py
def valid(self):
"""Assess if a fitness is valid or not."""
return len(self.wvalues) != 0
return len(self.wvalues) != 0 and all(not np.isnan(val) for val in self.wvalues)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about

Suggested change
return len(self.wvalues) != 0 and all(not np.isnan(val) for val in self.wvalues)
return len(self.wvalues) != 0 and not np.isnan(self.wvalues).any()

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.

HallOfFame does not store the best when np.nan involved

2 participants