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

[BUG] model.copy() fails with python 3.13.0 #1411

Open
1 task done
mpredl opened this issue Nov 18, 2024 · 0 comments · May be fixed by #1412
Open
1 task done

[BUG] model.copy() fails with python 3.13.0 #1411

mpredl opened this issue Nov 18, 2024 · 0 comments · May be fixed by #1412
Assignees
Labels

Comments

@mpredl
Copy link

mpredl commented Nov 18, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Problem description

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

Code sample

Code run:

import cobra
text_book_model = cobra.io.load_model("textbook")
text_book_model.copy()

Traceback:

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

Environment

### Package Information
Package Version
cobra 0.29.0

Dependency Information

Package Version
appdirs 1.4.4
black missing
bumpversion missing
depinfo 2.2.0
diskcache 5.6.3
future 1.0.0
httpx 0.27.2
importlib-resources 6.4.5
isort missing
numpy 2.1.3
optlang 1.8.2
pandas 2.2.3
pydantic 2.9.2
python-libsbml 5.20.4
rich 13.9.4
ruamel.yaml 0.18.6
scipy missing
swiglpk 5.0.10
tox missing

Build Tools Information

Package Version
pip 24.3.1
setuptools 75.5.0

Platform Information

Linux 6.1.0-26-amd64-x86_64
CPython 3.13.0

Anything else?

No response

@mpredl mpredl added the bug label Nov 18, 2024
@cdiener cdiener self-assigned this Nov 20, 2024
@cdiener cdiener linked a pull request Nov 20, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants