Skip to content

Commit c234692

Browse files
authored
Fix type for SBML history dates (#1301)
* cast to string * cast dates to str * add test model * revert conf
1 parent 4ef4d79 commit c234692

File tree

4 files changed

+1464
-2
lines changed

4 files changed

+1464
-2
lines changed

release-notes/next-release.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
Fix automatic building of the documentation.
88

9+
Fix an issue where SBML models with a "created" date would break lots of the cobrapy
10+
functionality.
11+
912
## Other
1013

1114
## Deprecated features

src/cobra/io/sbml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ def _sbml_to_model(
606606
history: "libsbml.ModelHistory" = model.getModelHistory()
607607

608608
if history.isSetCreatedDate():
609-
created = history.getCreatedDate()
609+
created = history.getCreatedDate().getDateAsString()
610610

611611
c: "libsbml.ModelCreator"
612612
for c in history.getListCreators():
@@ -1237,7 +1237,7 @@ def _model_to_sbml(
12371237

12381238
history: "libsbml.ModelHistory" = libsbml.ModelHistory()
12391239
if "created" in meta and meta["created"]:
1240-
history.setCreatedDate(meta["created"])
1240+
history.setCreatedDate(libsbml.Date(meta["created"]))
12411241
else:
12421242
time = datetime.datetime.now()
12431243
timestr = time.strftime("%Y-%m-%dT%H:%M:%S")

0 commit comments

Comments
 (0)