[med-svn] [Git][med-team/python-cobra][master] add Python3.13 patch (Closes: #1092791)
Alexandre Detiste (@detiste-guest)
gitlab at salsa.debian.org
Sun May 18 10:27:27 BST 2025
Alexandre Detiste pushed to branch master at Debian Med / python-cobra
Commits:
37fdc5cc by Alexandre Detiste at 2025-05-18T11:27:19+02:00
add Python3.13 patch (Closes: #1092791)
- - - - -
2 changed files:
- + debian/patches/a2b9d00a04b85b8c8eb12e4deba29ce2147896cf.patch
- debian/patches/series
Changes:
=====================================
debian/patches/a2b9d00a04b85b8c8eb12e4deba29ce2147896cf.patch
=====================================
@@ -0,0 +1,110 @@
+From a2b9d00a04b85b8c8eb12e4deba29ce2147896cf Mon Sep 17 00:00:00 2001
+From: Christian Diener <ch.diener at gmail.com>
+Date: Mon, 25 Nov 2024 12:46:45 +0100
+Subject: [PATCH] Fix the GPR copy in Python 3.13 (#1412)
+
+* fix GPR copy overwrite
+
+* add specific test
+
+* add RNs
+---
+ release-notes/next-release.md | 2 ++
+ src/cobra/core/gene.py | 8 ++++++--
+ tests/test_core/test_gpr.py | 15 ++++++++++-----
+ 3 files changed, 18 insertions(+), 7 deletions(-)
+
+diff --git a/release-notes/next-release.md b/release-notes/next-release.md
+index 2ddd48ce4..3b41cdc8c 100644
+--- a/release-notes/next-release.md
++++ b/release-notes/next-release.md
+@@ -4,6 +4,8 @@
+
+ ## Fixes
+
++Fixes failures of GPR.copy() in Python 3.13.
++
+ ## Other
+
+ ## Deprecated features
+diff --git a/src/cobra/core/gene.py b/src/cobra/core/gene.py
+index 4d8a13576..56733ec46 100644
+--- a/src/cobra/core/gene.py
++++ b/src/cobra/core/gene.py
+@@ -545,9 +545,13 @@ def to_string(self, names: dict = None) -> str:
+ """
+ return self._ast2str(self, names=names)
+
+- def copy(self):
++ def copy(self) -> "GPR":
+ """Copy a GPR."""
+- return deepcopy(self)
++ cls = type(self)
++ gpr = cls()
++ gpr._genes = deepcopy(self._genes)
++ gpr.body = deepcopy(self.body)
++ return gpr
+
+ def __copy__(self) -> "GPR":
+ """Ensure a correct shallow copy."""
+diff --git a/tests/test_core/test_gpr.py b/tests/test_core/test_gpr.py
+index 31d95f561..e472226b6 100644
+--- a/tests/test_core/test_gpr.py
++++ b/tests/test_core/test_gpr.py
+@@ -27,6 +27,16 @@ def test_gpr() -> None:
+ assert len(gpr1.genes) == 0
+
+
++def test_grp_copy() -> None:
++ """Test that copying a GPR works."""
++ gpr1 = GPR.from_string("(A and B) or C")
++ gpr2 = gpr1.copy()
++ assert gpr1 == gpr2
++ assert id(gpr1.body) is not id(gpr2.body)
++ assert gpr1._genes == gpr2._genes
++ assert id(gpr1._genes) is not id(gpr2._genes)
++
++
+ @pytest.mark.parametrize("test_input", ["", "", None])
+ def test_empty_gpr(test_input) -> None:
+ """Test empty GPR."""
+@@ -89,7 +99,6 @@ def test_and_gpr(gpr_input, num_genes, gpr_genes, gpr_output_string) -> None:
+ for ko_genes in powerset_ne(gpr_genes):
+ assert not gpr1.eval(ko_genes)
+ assert gpr1.body
+- gpr1.copy()
+
+
+ def all_except_one(iterable: Iterable[str]) -> Iterator[Tuple[str, ...]]:
+@@ -132,7 +141,6 @@ def test_or_gpr(
+ assert gpr1.eval(ko_genes)
+ assert not gpr1.eval(gpr_genes)
+ assert gpr1.body
+- gpr1.copy()
+
+
+ @pytest.mark.parametrize(
+@@ -158,7 +166,6 @@ def test_complicated_gpr(gpr_input: str) -> None:
+ assert not gpr1.eval("c")
+ assert not gpr1.eval(["a", "b"])
+ assert not gpr1.eval(["a", "b", "c"])
+- gpr1.copy()
+
+
+ @pytest.mark.parametrize(
+@@ -185,7 +192,6 @@ def test_gpr_from_ast_or(
+ for ko_genes in all_except_one(gpr_genes):
+ assert gpr1.eval(ko_genes)
+ assert not gpr1.eval(gpr_genes)
+- gpr1.copy()
+
+
+ @pytest.mark.parametrize(
+@@ -210,7 +216,6 @@ def test_gpr_from_ast_and(
+ assert gpr1.eval()
+ for ko_genes in powerset_ne(gpr_genes):
+ assert not gpr1.eval(ko_genes)
+- gpr1.copy()
+
+
+ @pytest.mark.parametrize("test_input", [["a", "b"], {"a", "b"}])
=====================================
debian/patches/series
=====================================
@@ -4,3 +4,4 @@ ignore_tests.patch
32-bit-test.patch
no_future_dependency.patch
remove-appdirs.patch
+a2b9d00a04b85b8c8eb12e4deba29ce2147896cf.patch
View it on GitLab: https://salsa.debian.org/med-team/python-cobra/-/commit/37fdc5cc85f064e4a0fcb6214830faef1292f86b
--
View it on GitLab: https://salsa.debian.org/med-team/python-cobra/-/commit/37fdc5cc85f064e4a0fcb6214830faef1292f86b
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20250518/b3b0fc7b/attachment-0001.htm>
More information about the debian-med-commit
mailing list