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
I'm trying pygad (2.16.3) for the first time , and have found the check for the number of arguments of the fitness function to be overly sensitive, e.g. I would like to be able to pass fitness functions of the following types:
Incorrectly triggers an error that fitness requires 3 parameters, since f.fit.__code__.co_argcount returns 3 (including self). Checking with signature instead could be an alternative:
Also triggers an error, but fitness can be called with 2 parameters as required. Unsure of a workaround for this one.
Is there any reason why pygad couldn't use either of these fitness functions? I'd especially like to be able to use a function of a class instance for one of my projects.
The text was updated successfully, but these errors were encountered:
jack89roberts
changed the title
Wrong number of arguments exceptions for functions with 2 required parameters
Wrong number of arguments exceptions for fitness functions with 2 required parameters
May 19, 2022
I'm trying
pygad
(2.16.3) for the first time , and have found the check for the number of arguments of the fitness function to be overly sensitive, e.g. I would like to be able to pass fitness functions of the following types:Class instance functions:
Incorrectly triggers an error that fitness requires 3 parameters, since
f.fit.__code__.co_argcount
returns 3 (includingself
). Checking withsignature
instead could be an alternative:Functions with additional parameters that have default values:
Also triggers an error, but
fitness
can be called with 2 parameters as required. Unsure of a workaround for this one.Is there any reason why
pygad
couldn't use either of these fitness functions? I'd especially like to be able to use a function of a class instance for one of my projects.The text was updated successfully, but these errors were encountered: