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

fix IndexError: The gp.generate function tried to add a primitive of … #737

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
support evaluate function return nan
  • Loading branch information
wukan1986 committed Jan 4, 2024
commit d7cf32446843f112c8e9a84b78f039f1986762e4
4 changes: 2 additions & 2 deletions deap/base.py
Original file line number Diff line number Diff line change
@@ -232,10 +232,10 @@ def __hash__(self):
return hash(self.wvalues)

def __gt__(self, other):
return not self.__le__(other)
return self.wvalues > other.wvalues

def __ge__(self, other):
return not self.__lt__(other)
return self.wvalues >= other.wvalues

def __le__(self, other):
return self.wvalues <= other.wvalues
4 changes: 3 additions & 1 deletion deap/tools/support.py
Original file line number Diff line number Diff line change
@@ -522,10 +522,12 @@ def update(self, population):
update the hall of fame with.
"""
for ind in population:
if ind.fitness.values[0] != ind.fitness.values[0]:
continue
if len(self) == 0 and self.maxsize != 0:
# Working on an empty hall of fame is problematic for the
# "for else"
self.insert(population[0])
self.insert(ind)
continue
if ind.fitness > self[-1].fitness or len(self) < self.maxsize:
for hofer in self: