From bc89e3f4b30a275364deeca64f32497bc74e4e4c Mon Sep 17 00:00:00 2001 From: Emil VATAI Date: Thu, 3 Aug 2023 18:40:35 +0900 Subject: [PATCH 1/4] Add missing imports --- radicalpy/classical.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/radicalpy/classical.py b/radicalpy/classical.py index e7cae64..0a121e1 100644 --- a/radicalpy/classical.py +++ b/radicalpy/classical.py @@ -1,8 +1,10 @@ #!/usr/bin/env python +from pathlib import Path from typing import Tuple +import dot2tex import graphviz import numpy as np import scipy as sp From d964830287717c63736536a18c31829ed757def4 Mon Sep 17 00:00:00 2001 From: Emil VATAI Date: Thu, 3 Aug 2023 18:42:53 +0900 Subject: [PATCH 2/4] Add missing requirements --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 9f155ca..482be11 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ seaborn sympy tqdm graphviz +dot2tex From e7e03f45f85304853505055d18655add3660b321 Mon Sep 17 00:00:00 2001 From: Emil VATAI Date: Thu, 3 Aug 2023 18:50:08 +0900 Subject: [PATCH 3/4] Fix path --- radicalpy/classical.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/radicalpy/classical.py b/radicalpy/classical.py index 0a121e1..b068438 100644 --- a/radicalpy/classical.py +++ b/radicalpy/classical.py @@ -128,7 +128,7 @@ def __getitem__(self, keys: list) -> np.ndarray: return np.sum([self.result[:, self.indices[k]] for k in ks], axis=0) -def reaction_scheme(rate_equations: dict): +def reaction_scheme(path: str, rate_equations: dict): data = [ (v1, v2, edge.label) for v1, rhs_data in rate_equations.items() @@ -144,9 +144,10 @@ def reaction_scheme(rate_equations: dict): G.node(v2, texlbl=f"${v2}$") G.edge(v2, v1, edge, texlbl=f"${edge}$") - path = Path(f"{__file__[:-3]}_graph.tex") + if not path.endswith("tex"): + path += ".tex" texcode = dot2tex.dot2tex(G.source) - path.write_text(texcode) + Path(path).write_text(texcode) def _random_theta_phi(): From 756751155d41c317e2616a9fc0d34db941d29980 Mon Sep 17 00:00:00 2001 From: Emil VATAI Date: Thu, 3 Aug 2023 18:56:03 +0900 Subject: [PATCH 4/4] Fix example --- examples/kinetics_simple.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/kinetics_simple.py b/examples/kinetics_simple.py index e5cca0f..f3f47a7 100644 --- a/examples/kinetics_simple.py +++ b/examples/kinetics_simple.py @@ -6,7 +6,8 @@ import graphviz import matplotlib.pyplot as plt import numpy as np -from radicalpy.classical import Rate, RateEquations, latex_eqlist_to_align, latexify +from radicalpy.classical import (Rate, RateEquations, latex_eqlist_to_align, + latexify, reaction_scheme) def main(): @@ -70,7 +71,7 @@ def main(): # for eq in latexify(off): # print(eq) # print(latex_eqlist_to_align(latexify(off))) - reaction_scheme(on) + reaction_scheme(__file__, on) if __name__ == "__main__":