Skip to content

Commit

Permalink
Fix type for SBML history dates (#1301)
Browse files Browse the repository at this point in the history
* cast to string

* cast dates to str

* add test model

* revert conf
  • Loading branch information
cdiener committed Nov 18, 2022
1 parent 4ef4d79 commit c234692
Show file tree
Hide file tree
Showing 4 changed files with 1,464 additions and 2 deletions.
3 changes: 3 additions & 0 deletions release-notes/next-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

Fix automatic building of the documentation.

Fix an issue where SBML models with a "created" date would break lots of the cobrapy
functionality.

## Other

## Deprecated features
Expand Down
4 changes: 2 additions & 2 deletions src/cobra/io/sbml.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def _sbml_to_model(
history: "libsbml.ModelHistory" = model.getModelHistory()

if history.isSetCreatedDate():
created = history.getCreatedDate()
created = history.getCreatedDate().getDateAsString()

c: "libsbml.ModelCreator"
for c in history.getListCreators():
Expand Down Expand Up @@ -1237,7 +1237,7 @@ def _model_to_sbml(

history: "libsbml.ModelHistory" = libsbml.ModelHistory()
if "created" in meta and meta["created"]:
history.setCreatedDate(meta["created"])
history.setCreatedDate(libsbml.Date(meta["created"]))
else:
time = datetime.datetime.now()
timestr = time.strftime("%Y-%m-%dT%H:%M:%S")
Expand Down

0 comments on commit c234692

Please sign in to comment.