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
{{ message }}
Repository navigation
Accepting classes with __call__ methods implemented, not only functions #342
But I can't do that, because in the current implementation, to check the input parameters we have a check on the 'code' property, not for the call one. In this way, we can only use functions on gad, while this simple change to accept classes would be very beneficial to the library.
Callable class instances are now accepted for the fitness function and callbacks. Argument validation uses their callable signatures instead of requiring __code__. I verified a run using callable instances for both fitness_func and on_fitness; both were invoked successfully. See current implementation. I am closing this as implemented.
Activity
ahmedfgad commentedon Mar 28, 2026
Thanks @arturossouza for the suggestion. This is going to be supported in the next release.
PyGAD 3.6.0
ahmedfgad commentedon Oct 8, 2026
Callable class instances are now accepted for the fitness function and callbacks. Argument validation uses their callable signatures instead of requiring
__code__. I verified a run using callable instances for bothfitness_funcandon_fitness; both were invoked successfully. See current implementation. I am closing this as implemented.