Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gchhughes opened this issue Mar 7, 2023 · 0 comments
Open

Comments

@gchhughes
Copy link

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
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant