There seems to be a bug when trying to copy a model in python v3.13.0. - cobra v0.29. The error message hints at problems copying the GPR. This issue does not happen in python v3.12.7 - cobra v0.29
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 text_book_model.copy()
File [~/.conda/envs/cf_prediction/1.1/lib/python3.13/site-packages/cobra/core/model.py:426], in Model.copy(self)
424 for attr, value in reaction.__dict__.items():
425 if attr not in do_not_copy_by_ref:
--> 426 new_reaction.__dict__[attr] = copy(value)
427 new_reaction._model = new
428 new.reactions.append(new_reaction)
File [~/.conda/envs/cf_prediction/1.1/lib/python3.13/copy.py:80], in copy(x)
78 copier = getattr(cls, "__copy__", None)
79 if copier is not None:
---> 80 return copier(x)
82 reductor = dispatch_table.get(cls)
83 if reductor is not None:
File [~/.conda/envs/cf_prediction/1.1/lib/python3.13/site-packages/cobra/core/gene.py:554], in GPR.__copy__(self)
552 def __copy__(self) -> "GPR":
553 """Ensure a correct shallow copy."""
--> 554 return self.copy()
File [~/.conda/envs/cf_prediction/1.1/lib/python3.13/site-packages/cobra/core/gene.py:550], in GPR.copy(self)
548 def copy(self):
549 """Copy a GPR."""
--> 550 return deepcopy(self)
File [~/.conda/envs/cf_prediction/1.1/lib/python3.13/copy.py:163], in deepcopy(x, memo, _nil)
161 y = x
162 else:
--> 163 y = _reconstruct(x, memo, *rv)
165 # If is its own copy, don't memoize.
166 if y is not x:
File [~/.conda/envs/cf_prediction/1.1/lib/python3.13/copy.py:254], in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
252 if deep and args:
253 args = (deepcopy(arg, memo) for arg in args)
--> 254 y = func(*args)
255 if deep:
256 memo[id(x)] = y
TypeError: GPR.__init__() takes from 1 to 2 positional arguments but 3 were given