From bddbf8cf7653ee9cfe644052b72ef17e7ec0b3c8 Mon Sep 17 00:00:00 2001 From: ChocolateCharlie Date: Wed, 29 Jun 2022 21:46:18 +0200 Subject: [PATCH 1/2] Replace conditions with exceptions --- jupyter_notebooks/createModel.ipynb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/jupyter_notebooks/createModel.ipynb b/jupyter_notebooks/createModel.ipynb index 6ef050f7..54c35602 100644 --- a/jupyter_notebooks/createModel.ipynb +++ b/jupyter_notebooks/createModel.ipynb @@ -501,17 +501,21 @@ "outputs": [], "source": [ "# load model and convert to SBML\n", - "if loadFile(\"SPARCED.txt\") == 1:\n", - " print(\"Success loading antimony file\")\n", - "else:\n", + "try:\n", + " assert not loadFile(\"SPARCED.txt\") == -1\n", + "except:\n", " print(\"Failed to load antimony file\")\n", " exit(1)\n", - "\n", - "if writeSBMLFile(\"SPARCED.xml\",\"SPARCED\") == 1:\n", - " print(\"Success converting antimony to SBML\")\n", "else:\n", + " print(\"Success loading antimony file\")\n", + "\n", + "try:\n", + " writeSBMLFile(\"SPARCED.xml\",\"SPARCED\") == -1", + "except:\n", " print(\"Failure converting antimony to SBML\")\n", - " exit(1)" + " exit(1)", + "else:\n", + " print(\"Success converting antimony to SBML\")\n" ] }, { From df6feabb30d7e2dc99eee1246fa987f604a94353 Mon Sep 17 00:00:00 2001 From: ChocolateCharlie Date: Wed, 29 Jun 2022 21:52:07 +0200 Subject: [PATCH 2/2] Fix assertion --- jupyter_notebooks/createModel.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_notebooks/createModel.ipynb b/jupyter_notebooks/createModel.ipynb index 54c35602..a2ce9867 100644 --- a/jupyter_notebooks/createModel.ipynb +++ b/jupyter_notebooks/createModel.ipynb @@ -510,7 +510,7 @@ " print(\"Success loading antimony file\")\n", "\n", "try:\n", - " writeSBMLFile(\"SPARCED.xml\",\"SPARCED\") == -1", + " assert not writeSBMLFile(\"SPARCED.xml\",\"SPARCED\") == 0", "except:\n", " print(\"Failure converting antimony to SBML\")\n", " exit(1)",