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
Unfortunately, I cannot annotate any arguments of type deap.creator.Individual when instantiating the Individual as part of a method on some class since the deap.creator.Individual class doesn't exist when the Python type checker runs.
Example:
from deap import base, creator
class Algo:
"""
Some evolutionary algorithm.
"""
@staticmethod
def mate(individual: creator.Individual):
"""
Method to mate individuals.
"""
pass
def setup(self):
"""
Method that configures deap.
"""
creator.create("FitnessMulti", base.Fitness, weights=(-1.0, -1.0))
creator.create("Individual", list, fitness=creator.FitnessMulti)
def optimize(self):
"""
Method that runs the algorithm.
"""
pass
I'm aware that deap is more script rather than OOP based but I'm curious if other people have encountered this problem and what their workarounds are.
This issue relates somewhat to #367 which is about type annotating the deap source code.
The text was updated successfully, but these errors were encountered:
Unfortunately you are right, we are working on a new schema for the individuals, but it is not ready yet. In the mean time you could use string style annotation.
Unfortunately, I cannot annotate any arguments of type
deap.creator.Individual
when instantiating theIndividual
as part of a method on some class since thedeap.creator.Individual
class doesn't exist when the Python type checker runs.Example:
I'm aware that
deap
is more script rather than OOP based but I'm curious if other people have encountered this problem and what their workarounds are.This issue relates somewhat to #367 which is about type annotating the
deap
source code.The text was updated successfully, but these errors were encountered: