Skip to content

Commit

Permalink
Merge pull request #134 from Spin-Chemistry-Labs/133-fix-missing-path…
Browse files Browse the repository at this point in the history
…-import

Add missing imports
  • Loading branch information
vatai authored Aug 31, 2023
2 parents 825b537 + 7567511 commit 1dd2b51
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions examples/kinetics_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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__":
Expand Down
9 changes: 6 additions & 3 deletions radicalpy/classical.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -126,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()
Expand All @@ -142,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():
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ seaborn
sympy
tqdm
graphviz
dot2tex

0 comments on commit 1dd2b51

Please sign in to comment.