You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On line 1683 in pygad.py the code says solution_idx = self.best_solutions.index(list(sol))
apparently assuming that self.best_solutions is always a list. However, it is possible that self.best_solutions is a numpy.ndarray, in which case the index method is undefined and the program crashes.
Adding
if type(self.best_solutions) is numpy.ndarray:
self.best_solutions = self.best_solutions.tolist()
before the first if statement (if (self.save_solutions) and (len(self.solutions) > 0) and (list(sol) in self.solutions):) seems to resolve the issue.
The text was updated successfully, but these errors were encountered:
On line 1683 in pygad.py the code says
solution_idx = self.best_solutions.index(list(sol))
apparently assuming that
self.best_solutions
is always alist
. However, it is possible thatself.best_solutions
is anumpy.ndarray
, in which case theindex
method is undefined and the program crashes.Adding
before the first if statement (
if (self.save_solutions) and (len(self.solutions) > 0) and (list(sol) in self.solutions):
) seems to resolve the issue.The text was updated successfully, but these errors were encountered: