DEAP / deap

Distributed Evolutionary Algorithms in Python

Home Page:http://deap.readthedocs.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RecursionError when using pd.DataFrame as creator.create base argument

gchhughes opened this issue · comments

Hello,

I am trying to create an individual that inherits the pd.DataFrame class, but I receive a recursion error at line 165, setattr(self, obj_name, obj()). I am not sure how to resolve this issue on my end.

"""
creator.create(name = 'FitnessMin',
base = base.Fitness,
weights = (-1.0,))

creator.create(name = 'individual',
base = pd.DataFrame,
fitness = creator.FitnessMin)

creator.individual()

File /opt/miniconda3/envs/sym-seq-ml/lib/python3.10/site-packages/deap/creator.py:165, in create..initType(self, *args, **kargs)
161 """Replace the init function of the new type, in order to
162 add attributes that were defined with **kargs to the instance.
163 """
164 for obj_name, obj in dict_inst.items():
--> 165 setattr(self, obj_name, obj())
166 if base.init is not object.init:
167 base.init(self, *args, **kargs)

File /opt/miniconda3/envs/sym-seq-ml/lib/python3.10/site-packages/pandas/core/generic.py:5600, in NDFrame.setattr(self, name, value)
5598 else:
5599 try:
-> 5600 existing = getattr(self, name)
5601 if isinstance(existing, Index):
5602 object.setattr(self, name, value)

File /opt/miniconda3/envs/sym-seq-ml/lib/python3.10/site-packages/pandas/core/generic.py:5572, in NDFrame.getattr(self, name)
5562 """
5563 After regular attribute access, try looking up the name
5564 This allows simpler access to columns for interactive use.
...
5573 ):
5574 return self[name]
-> 5575 return object.getattribute(self, name)

RecursionError: maximum recursion depth exceeded while calling a Python object
"""