diff --git a/deap/base.py b/deap/base.py index b57b9663b..bccd516d2 100644 --- a/deap/base.py +++ b/deap/base.py @@ -28,6 +28,7 @@ class used as base class, for the fitness member of any individual. """ from copy import deepcopy from functools import partial from operator import mul, truediv +import numpy as np class Toolbox(object): @@ -225,7 +226,7 @@ def dominates(self, other, obj=slice(None)): @property 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) def __hash__(self): return hash(self.wvalues)