Skip to content

Accepting classes with __call__ methods implemented, not only functions #342

Description

@arturossouza

Hi,

I was writing some architecture to leverage PyGad and I came across a problem.

Basically I am using a class architecture and would like to have something like this:

class OnFitness(BaseGeneticClass):
    def __call__ (ga_instance: pygad.GA, population_fitness):
        # do stuff

on_fitness = OnFitness()

ga_instance = pygad.GA(..., on_fitness=on_fitness)
ga_instance.run()

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.

Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions