modelbase2 0.1.79__py3-none-any.whl → 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. modelbase2/__init__.py +138 -26
  2. modelbase2/distributions.py +306 -0
  3. modelbase2/experimental/__init__.py +17 -0
  4. modelbase2/experimental/codegen.py +239 -0
  5. modelbase2/experimental/diff.py +227 -0
  6. modelbase2/experimental/notes.md +4 -0
  7. modelbase2/experimental/tex.py +521 -0
  8. modelbase2/fit.py +284 -0
  9. modelbase2/fns.py +185 -0
  10. modelbase2/integrators/__init__.py +19 -0
  11. modelbase2/integrators/int_assimulo.py +146 -0
  12. modelbase2/integrators/int_scipy.py +147 -0
  13. modelbase2/label_map.py +610 -0
  14. modelbase2/linear_label_map.py +301 -0
  15. modelbase2/mc.py +548 -0
  16. modelbase2/mca.py +280 -0
  17. modelbase2/model.py +1621 -0
  18. modelbase2/npe.py +343 -0
  19. modelbase2/parallel.py +171 -0
  20. modelbase2/parameterise.py +28 -0
  21. modelbase2/paths.py +36 -0
  22. modelbase2/plot.py +829 -0
  23. modelbase2/sbml/__init__.py +14 -0
  24. modelbase2/sbml/_data.py +77 -0
  25. modelbase2/sbml/_export.py +656 -0
  26. modelbase2/sbml/_import.py +585 -0
  27. modelbase2/sbml/_mathml.py +691 -0
  28. modelbase2/sbml/_name_conversion.py +52 -0
  29. modelbase2/sbml/_unit_conversion.py +74 -0
  30. modelbase2/scan.py +616 -0
  31. modelbase2/scope.py +96 -0
  32. modelbase2/simulator.py +635 -0
  33. modelbase2/surrogates/__init__.py +32 -0
  34. modelbase2/surrogates/_poly.py +66 -0
  35. modelbase2/surrogates/_torch.py +249 -0
  36. modelbase2/surrogates.py +316 -0
  37. modelbase2/types.py +352 -11
  38. modelbase2-0.2.0.dist-info/METADATA +81 -0
  39. modelbase2-0.2.0.dist-info/RECORD +42 -0
  40. {modelbase2-0.1.79.dist-info → modelbase2-0.2.0.dist-info}/WHEEL +1 -1
  41. modelbase2/core/__init__.py +0 -29
  42. modelbase2/core/algebraic_module_container.py +0 -130
  43. modelbase2/core/constant_container.py +0 -113
  44. modelbase2/core/data.py +0 -109
  45. modelbase2/core/name_container.py +0 -29
  46. modelbase2/core/reaction_container.py +0 -115
  47. modelbase2/core/utils.py +0 -28
  48. modelbase2/core/variable_container.py +0 -24
  49. modelbase2/ode/__init__.py +0 -13
  50. modelbase2/ode/integrator.py +0 -80
  51. modelbase2/ode/mca.py +0 -270
  52. modelbase2/ode/model.py +0 -470
  53. modelbase2/ode/simulator.py +0 -153
  54. modelbase2/utils/__init__.py +0 -0
  55. modelbase2/utils/plotting.py +0 -372
  56. modelbase2-0.1.79.dist-info/METADATA +0 -44
  57. modelbase2-0.1.79.dist-info/RECORD +0 -22
  58. {modelbase2-0.1.79.dist-info → modelbase2-0.2.0.dist-info/licenses}/LICENSE +0 -0
@@ -0,0 +1,52 @@
1
+ from __future__ import annotations
2
+
3
+ import keyword
4
+ import re
5
+
6
+ __all__ = ["RE_FROM_SBML", "RE_KWDS", "SBML_DOT"]
7
+
8
+ RE_KWDS = re.compile("|".join(f"^{i}$" for i in keyword.kwlist))
9
+ SBML_DOT = "__SBML_DOT__"
10
+ RE_FROM_SBML = re.compile(r"__(\d+)__")
11
+
12
+
13
+ def _escape_keyword(re_sub: re.Match) -> str:
14
+ return f"{re_sub.group(0)}_"
15
+
16
+
17
+ def _ascii_to_character(re_sub: re.Match) -> str:
18
+ """Convert an escaped non-alphanumeric character."""
19
+ return chr(int(re_sub.group(1)))
20
+
21
+
22
+ def _name_to_py(name: str) -> str:
23
+ name = RE_FROM_SBML.sub(_ascii_to_character, name)
24
+ name = RE_KWDS.sub(_escape_keyword, name)
25
+ name = (
26
+ name.replace(SBML_DOT, ".")
27
+ .replace(" ", "_")
28
+ .replace("-", "_")
29
+ .replace("(", "")
30
+ .replace(")", "")
31
+ .replace("[", "")
32
+ .replace("]", "")
33
+ .replace(".", "")
34
+ .replace(",", "")
35
+ .replace(":", "")
36
+ .replace(";", "")
37
+ .replace('"', "")
38
+ .replace("'", "")
39
+ .replace("^", "")
40
+ .replace("|", "")
41
+ .replace("=", "eq")
42
+ .replace(">", "lg")
43
+ .replace("<", "sm")
44
+ .replace("+", "plus")
45
+ .replace("-", "minus")
46
+ .replace("*", "star")
47
+ .replace("/", "div")
48
+ # .lower()
49
+ )
50
+ if not name[0].isalpha():
51
+ return f"_{name}"
52
+ return name
@@ -0,0 +1,74 @@
1
+ from __future__ import annotations
2
+
3
+ __all__ = ["get_ast_types", "get_operator_mappings", "get_unit_conversion"]
4
+
5
+
6
+ import libsbml
7
+
8
+ unit_conversion = {
9
+ "UNIT_KIND_AMPERE": "AMPERE",
10
+ "UNIT_KIND_AVOGADRO": "AVOGADRO",
11
+ "UNIT_KIND_BECQUEREL": "BECQUEREL",
12
+ "UNIT_KIND_CANDELA": "CANDELA",
13
+ "UNIT_KIND_CELSIUS": "CELSIUS",
14
+ "UNIT_KIND_COULOMB": "COULOMB",
15
+ "UNIT_KIND_DIMENSIONLESS": "DIMENSIONLESS",
16
+ "UNIT_KIND_FARAD": "FARAD",
17
+ "UNIT_KIND_GRAM": "GRAM",
18
+ "UNIT_KIND_GRAY": "GRAY",
19
+ "UNIT_KIND_HENRY": "HENRY",
20
+ "UNIT_KIND_HERTZ": "HERTZ",
21
+ "UNIT_KIND_ITEM": "ITEM",
22
+ "UNIT_KIND_JOULE": "JOULE",
23
+ "UNIT_KIND_KATAL": "KATAL",
24
+ "UNIT_KIND_KELVIN": "KELVIN",
25
+ "UNIT_KIND_KILOGRAM": "KILOGRAM",
26
+ "UNIT_KIND_LITER": "LITER",
27
+ "UNIT_KIND_LITRE": "LITER",
28
+ "UNIT_KIND_LUMEN": "LUMEN",
29
+ "UNIT_KIND_LUX": "LUX",
30
+ "UNIT_KIND_METER": "METER",
31
+ "UNIT_KIND_METRE": "METRE",
32
+ "UNIT_KIND_MOLE": "MOLE",
33
+ "UNIT_KIND_NEWTON": "NEWTON",
34
+ "UNIT_KIND_OHM": "OHM",
35
+ "UNIT_KIND_PASCAL": "PASCAL",
36
+ "UNIT_KIND_RADIAN": "RADIAN",
37
+ "UNIT_KIND_SECOND": "SECOND",
38
+ "UNIT_KIND_SIEMENS": "SIEMENS",
39
+ "UNIT_KIND_SIEVERT": "SIEVERT",
40
+ "UNIT_KIND_STERADIAN": "STERADIAN",
41
+ "UNIT_KIND_TESLA": "TESLA",
42
+ "UNIT_KIND_VOLT": "VOLT",
43
+ "UNIT_KIND_WATT": "WATT",
44
+ "UNIT_KIND_WEBER": "WEBER",
45
+ "UNIT_KIND_INVALID": "INVALID",
46
+ }
47
+
48
+
49
+ def get_unit_conversion() -> dict[str, str]:
50
+ return {getattr(libsbml, k): v.lower() for k, v in unit_conversion.items()}
51
+
52
+
53
+ ast_types = dict(
54
+ sorted(
55
+ {getattr(libsbml, i): i for i in dir(libsbml) if i.startswith("AST_")}.items()
56
+ )
57
+ )
58
+
59
+
60
+ def get_ast_types() -> dict[str, str]:
61
+ return ast_types
62
+
63
+
64
+ operator_mappings = {
65
+ "AST_TIMES": "*",
66
+ "AST_PLUS": "+",
67
+ "AST_MINUS": "-",
68
+ "AST_DIVIDE": "/",
69
+ "AST_POWER": "**",
70
+ }
71
+
72
+
73
+ def get_operator_mappings() -> dict[str, str]:
74
+ return operator_mappings