Open
Description
Hi,
I've noticed that PyGAD version 3.4.0, both on PyPI and in releases here, still has the old code for checking the value of stop_criteria
argument in the GA constructor. It seems an older version of pygad.py
was packaged:
In the current (fixed) GitHub version in pygad/pygad.py
lines 1186 and 1217 both contain if number.replace(".", "").replace("-", "").isnumeric():
:
GeneticAlgorithmPython/pygad/pygad.py
Line 1186 in 822ac90
GeneticAlgorithmPython/pygad/pygad.py
Line 1217 in 822ac90
But both in the PyPI and release versions, in the corresponding lines (1171 and 1186) .replace("-", "")
is missing (and the code is clearly different from the current one on GitHub):
if len(criterion) == 2:
# There is only a single number.
number = number[0]
if number.replace(".", "").isnumeric(): # <<< 1171
number = float(number)
else:
self.valid_parameters = False
raise ValueError(f"The value following the stop word in the 'stop_criteria' parameter must be a number but the value ({number}) of type {type(number)} found.")
self.stop_criteria.append([stop_word, number])
elif len(criterion) > 2:
if stop_word == 'reach':
pass
else:
self.valid_parameters = False
raise ValueError(f"Passing multiple numbers following the keyword in the 'stop_criteria' parameter is expected only with the 'reach' keyword but the keyword ({stop_word}) found.")
for idx, num in enumerate(number):
if num.replace(".", "").isnumeric(): # <<< 1186
number[idx] = float(num)
else:
self.valid_parameters = False
raise ValueError(f"The value(s) following the stop word in the 'stop_criteria' parameter must be numeric but the value ({num}) of type {type(num)} found.")
self.stop_criteria.append([stop_word] + number)
Metadata
Metadata
Assignees
Labels
No labels