sbmlmath 0.0.2__tar.gz → 0.1.1__tar.gz

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 (42) hide show
  1. sbmlmath-0.1.1/.github/dependabot.yml +10 -0
  2. sbmlmath-0.1.1/.github/workflows/ci.yaml +140 -0
  3. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/.github/workflows/deploy_release.yaml +2 -2
  4. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/.pre-commit-config.yaml +8 -2
  5. sbmlmath-0.1.1/.readthedocs.yml +26 -0
  6. sbmlmath-0.1.1/PKG-INFO +69 -0
  7. sbmlmath-0.1.1/README.md +52 -0
  8. sbmlmath-0.1.1/doc/.gitignore +3 -0
  9. sbmlmath-0.1.1/doc/Makefile +20 -0
  10. sbmlmath-0.1.1/doc/about.rst +63 -0
  11. sbmlmath-0.1.1/doc/api.rst +10 -0
  12. sbmlmath-0.1.1/doc/conf.py +83 -0
  13. sbmlmath-0.1.1/doc/index.rst +9 -0
  14. sbmlmath-0.1.1/doc/make.bat +35 -0
  15. sbmlmath-0.1.1/doc/rtd_requirements.txt +2 -0
  16. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/pyproject.toml +7 -4
  17. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath/__init__.py +28 -5
  18. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath/cfunction.py +16 -7
  19. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath/csymbol.py +31 -6
  20. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath/mathml_parser.py +94 -21
  21. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath/mathml_printer.py +20 -4
  22. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath/species_symbol.py +26 -11
  23. sbmlmath-0.1.1/sbmlmath.egg-info/PKG-INFO +69 -0
  24. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath.egg-info/SOURCES.txt +10 -0
  25. sbmlmath-0.1.1/sbmlmath.egg-info/requires.txt +8 -0
  26. sbmlmath-0.1.1/tests/test_parser.py +57 -0
  27. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/tests/test_printer.py +1 -1
  28. sbmlmath-0.0.2/.github/workflows/ci.yaml +0 -53
  29. sbmlmath-0.0.2/PKG-INFO +0 -42
  30. sbmlmath-0.0.2/README.md +0 -31
  31. sbmlmath-0.0.2/sbmlmath.egg-info/PKG-INFO +0 -42
  32. sbmlmath-0.0.2/sbmlmath.egg-info/requires.txt +0 -8
  33. sbmlmath-0.0.2/tests/test_parser.py +0 -29
  34. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/.gitignore +0 -0
  35. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/LICENSE +0 -0
  36. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath.egg-info/dependency_links.txt +0 -0
  37. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/sbmlmath.egg-info/top_level.txt +0 -0
  38. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/setup.cfg +0 -0
  39. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/tests/test_csymbol.py +0 -0
  40. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/tests/test_mathml_parser_sbml_semantic_suite.py +0 -0
  41. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/tests/test_misc.py +0 -0
  42. {sbmlmath-0.0.2 → sbmlmath-0.1.1}/tests/test_species_symbol.py +0 -0
@@ -0,0 +1,10 @@
1
+ version: 2
2
+ updates:
3
+
4
+ - package-ecosystem: "github-actions"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ ignore:
9
+ - dependency-name: "*"
10
+ update-types: ["version-update:semver-patch", "version-update:semver-minor"]
@@ -0,0 +1,140 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ workflow_dispatch:
6
+ schedule:
7
+ - cron: '48 4 * * *'
8
+
9
+ jobs:
10
+ test-ubuntu:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.9", "3.12"]
16
+
17
+ steps:
18
+ - name: Check out repository
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Cache pip
27
+ uses: actions/cache@v4
28
+ with:
29
+ path: ~/.cache/pip
30
+ key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
31
+ restore-keys: |
32
+ ${{ runner.os }}-${{ matrix.python-version }}-
33
+
34
+ - name: Cache / restore SBML test suite
35
+ id: cache-sbml-test-suite
36
+ uses: actions/cache@v4
37
+ with:
38
+ path: sbml-test-suite
39
+ key: ${{ runner.os }}-sbml-test-suite
40
+
41
+ - name: Download SBML test suite
42
+ if: steps.cache-sbml-test-suite.outputs.cache-hit != 'true'
43
+ run: git clone --depth=1 https://github.com/sbmlteam/sbml-test-suite/
44
+
45
+ - name: Install local packages
46
+ run: |
47
+ pip install --upgrade pip setuptools && pip install .[test]
48
+
49
+ - name: Unit tests
50
+ env:
51
+ SBML_TEST_SUITE_ROOT: "${{ github.workspace }}/sbml-test-suite/"
52
+ run: pytest -vv
53
+
54
+ test-macos:
55
+ runs-on: macos-latest
56
+
57
+ strategy:
58
+ matrix:
59
+ python-version: ["3.9", "3.12"]
60
+
61
+ steps:
62
+ - name: Check out repository
63
+ uses: actions/checkout@v4
64
+
65
+ - name: Set up Python ${{ matrix.python-version }}
66
+ uses: actions/setup-python@v5
67
+ with:
68
+ python-version: ${{ matrix.python-version }}
69
+
70
+ - name: Cache pip
71
+ uses: actions/cache@v4
72
+ with:
73
+ path: ~/.cache/pip
74
+ key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
75
+ restore-keys: |
76
+ ${{ runner.os }}-${{ matrix.python-version }}-
77
+
78
+ - name: Cache / restore SBML test suite
79
+ id: cache-sbml-test-suite
80
+ uses: actions/cache@v4
81
+ with:
82
+ path: sbml-test-suite
83
+ key: ${{ runner.os }}-sbml-test-suite
84
+
85
+ - name: Download SBML test suite
86
+ if: steps.cache-sbml-test-suite.outputs.cache-hit != 'true'
87
+ run: git clone --depth=1 https://github.com/sbmlteam/sbml-test-suite/
88
+
89
+ - name: Install local packages
90
+ run: |
91
+ pip install --upgrade pip setuptools && pip install .[test]
92
+
93
+ - name: Unit tests
94
+ env:
95
+ SBML_TEST_SUITE_ROOT: "${{ github.workspace }}/sbml-test-suite/"
96
+ run: pytest -vv
97
+
98
+ test-windows:
99
+ runs-on: windows-latest
100
+
101
+ strategy:
102
+ matrix:
103
+ python-version: ["3.9", "3.12"]
104
+
105
+ steps:
106
+ - name: Check out repository
107
+ uses: actions/checkout@v4
108
+
109
+ - name: Set up Python ${{ matrix.python-version }}
110
+ uses: actions/setup-python@v5
111
+ with:
112
+ python-version: ${{ matrix.python-version }}
113
+
114
+ - name: Cache pip
115
+ uses: actions/cache@v4
116
+ with:
117
+ path: ~/.cache/pip
118
+ key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}
119
+ restore-keys: |
120
+ ${{ runner.os }}-${{ matrix.python-version }}-
121
+
122
+ - name: Cache / restore SBML test suite
123
+ id: cache-sbml-test-suite
124
+ uses: actions/cache@v4
125
+ with:
126
+ path: sbml-test-suite
127
+ key: ${{ runner.os }}-sbml-test-suite
128
+
129
+ - name: Download SBML test suite
130
+ if: steps.cache-sbml-test-suite.outputs.cache-hit != 'true'
131
+ run: git clone --depth=1 https://github.com/sbmlteam/sbml-test-suite/
132
+
133
+ - name: Install local packages
134
+ run: |
135
+ pip install --upgrade pip setuptools && pip install .[test]
136
+
137
+ - name: Unit tests
138
+ env:
139
+ SBML_TEST_SUITE_ROOT: "${{ github.workspace }}/sbml-test-suite/"
140
+ run: pytest -vv
@@ -16,11 +16,11 @@ jobs:
16
16
 
17
17
  steps:
18
18
  - name: Set up Python
19
- uses: actions/setup-python@v4
19
+ uses: actions/setup-python@v5
20
20
  with:
21
21
  python-version: "3.11"
22
22
 
23
- - uses: actions/checkout@v3
23
+ - uses: actions/checkout@v4
24
24
  with:
25
25
  fetch-depth: 20
26
26
 
@@ -1,15 +1,21 @@
1
1
  # See https://pre-commit.com for more information
2
2
  # See https://pre-commit.com/hooks.html for more hooks
3
3
  repos:
4
+ - repo: https://github.com/pycqa/isort
5
+ rev: 5.13.2
6
+ hooks:
7
+ - id: isort
8
+ name: isort (python)
9
+ args: ["--profile", "black", "--filter-files"]
4
10
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
- rev: v3.2.0
11
+ rev: v4.5.0
6
12
  hooks:
7
13
  - id: trailing-whitespace
8
14
  - id: end-of-file-fixer
9
15
  - id: check-yaml
10
16
  - id: check-added-large-files
11
17
  - repo: https://github.com/psf/black
12
- rev: 23.1.0
18
+ rev: 23.12.0
13
19
  hooks:
14
20
  - id: black
15
21
  # It is recommended to specify the latest version of Python
@@ -0,0 +1,26 @@
1
+ # .readthedocs.yml
2
+ # Read the Docs configuration file
3
+ # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4
+
5
+ # Required
6
+ version: 2
7
+
8
+ # Build documentation in the docs/ directory with Sphinx
9
+ sphinx:
10
+ builder: html
11
+ configuration: doc/conf.py
12
+ fail_on_warning: False
13
+
14
+ formats:
15
+ - pdf
16
+
17
+ python:
18
+ install:
19
+ - requirements: doc/rtd_requirements.txt
20
+ - method: pip
21
+ path: .
22
+
23
+ build:
24
+ os: "ubuntu-24.04"
25
+ tools:
26
+ python: "3.12"
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.1
2
+ Name: sbmlmath
3
+ Version: 0.1.1
4
+ Summary: SBML Math <-> SymPy
5
+ Author-email: Daniel Weindl <sci@danielweindl.de>
6
+ License: BSD-3-Clause
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: python-libsbml
11
+ Requires-Dist: sympy
12
+ Requires-Dist: pint
13
+ Requires-Dist: lxml>=4.6.4
14
+ Provides-Extra: test
15
+ Requires-Dist: pytest>=7; extra == "test"
16
+ Requires-Dist: pre-commit>=3; extra == "test"
17
+
18
+ # sbmlmath — a Python library for handling SBML MathML
19
+
20
+ This is a Python library for interconverting [SymPy](https://github.com/sympy/sympy/)
21
+ expressions and [SBML](https://sbml.org/)-MathML.
22
+ SBML uses a subset of [MathML](https://www.w3.org/Math/) that this library
23
+ aims to support. This is not (intended to be) a general MathML parser.
24
+
25
+ Main functionality:
26
+
27
+ * sympy -> SBML MathML
28
+ * SBML MathML -> sympy
29
+ * in particular for cases where `sympy.sympify(libsbml.formulaToL3String(...))`
30
+ won't do the job
31
+ (mind the differences operator precedence between
32
+ sympy/[Python](https://docs.python.org/3/reference/expressions.html#operator-precedence)
33
+ and [libsbml L3 formulas](https://synonym.caltech.edu/software/libsbml/5.18.0/docs/formatted/python-api/libsbml-math.html#math-l3)!)
34
+ * retaining unit annotations and other `<ci>` attributes
35
+
36
+ **NOTE: This is under development and the API is to be considered unstable**
37
+
38
+ Python support policy: sbmlmath follows [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html).
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ from sbmlmath import SBMLMathMLPrinter, SBMLMathMLParser
44
+ import sympy as sp
45
+
46
+ sympy_expr = sp.sympify("A ** B + exp(C) * D")
47
+ mathml = SBMLMathMLPrinter().doprint(sympy_expr)
48
+ print(mathml)
49
+
50
+ cycled_sympy = SBMLMathMLParser().parse_str(mathml)
51
+ print(cycled_sympy)
52
+ assert sympy_expr == cycled_sympy
53
+ ```
54
+
55
+ ## Documentation
56
+
57
+ Under construction at [sbmlmath.readthedocs.io](https://sbmlmath.readthedocs.io/).
58
+
59
+ ## Installation
60
+
61
+ Releases from [PyPI](https://pypi.org/project/sbmlmath/):
62
+ ```bash
63
+ pip install sbmlmath
64
+ ```
65
+
66
+ The latest development version from GitHub:
67
+ ```bash
68
+ pip install https://github.com/dweindl/sbmlmath/archive/main.zip
69
+ ```
@@ -0,0 +1,52 @@
1
+ # sbmlmath — a Python library for handling SBML MathML
2
+
3
+ This is a Python library for interconverting [SymPy](https://github.com/sympy/sympy/)
4
+ expressions and [SBML](https://sbml.org/)-MathML.
5
+ SBML uses a subset of [MathML](https://www.w3.org/Math/) that this library
6
+ aims to support. This is not (intended to be) a general MathML parser.
7
+
8
+ Main functionality:
9
+
10
+ * sympy -> SBML MathML
11
+ * SBML MathML -> sympy
12
+ * in particular for cases where `sympy.sympify(libsbml.formulaToL3String(...))`
13
+ won't do the job
14
+ (mind the differences operator precedence between
15
+ sympy/[Python](https://docs.python.org/3/reference/expressions.html#operator-precedence)
16
+ and [libsbml L3 formulas](https://synonym.caltech.edu/software/libsbml/5.18.0/docs/formatted/python-api/libsbml-math.html#math-l3)!)
17
+ * retaining unit annotations and other `<ci>` attributes
18
+
19
+ **NOTE: This is under development and the API is to be considered unstable**
20
+
21
+ Python support policy: sbmlmath follows [NEP 29](https://numpy.org/neps/nep-0029-deprecation_policy.html).
22
+
23
+ ## Usage
24
+
25
+ ```python
26
+ from sbmlmath import SBMLMathMLPrinter, SBMLMathMLParser
27
+ import sympy as sp
28
+
29
+ sympy_expr = sp.sympify("A ** B + exp(C) * D")
30
+ mathml = SBMLMathMLPrinter().doprint(sympy_expr)
31
+ print(mathml)
32
+
33
+ cycled_sympy = SBMLMathMLParser().parse_str(mathml)
34
+ print(cycled_sympy)
35
+ assert sympy_expr == cycled_sympy
36
+ ```
37
+
38
+ ## Documentation
39
+
40
+ Under construction at [sbmlmath.readthedocs.io](https://sbmlmath.readthedocs.io/).
41
+
42
+ ## Installation
43
+
44
+ Releases from [PyPI](https://pypi.org/project/sbmlmath/):
45
+ ```bash
46
+ pip install sbmlmath
47
+ ```
48
+
49
+ The latest development version from GitHub:
50
+ ```bash
51
+ pip install https://github.com/dweindl/sbmlmath/archive/main.zip
52
+ ```
@@ -0,0 +1,3 @@
1
+ /_build/
2
+ /generated/
3
+ /libsbml.inv
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,63 @@
1
+ sbmlmath — a Python library for handling SBML MathML
2
+ ====================================================
3
+
4
+ This is a Python library for interconverting `SymPy <https://github.com/sympy/sympy/>`_
5
+ expressions and `SBML <https://sbml.org/>`_-MathML.
6
+ SBML uses a subset of `MathML <https://www.w3.org/Math/>`_ that this library
7
+ aims to support. This is not (intended to be) a general MathML parser.
8
+
9
+ Main functionality:
10
+
11
+ * sympy -> SBML MathML
12
+
13
+ * SBML MathML -> sympy
14
+
15
+ * in particular for cases where ``sympy.sympify(libsbml.formulaToL3String(...))``
16
+ won't do the job
17
+ (mind the differences operator precedence between
18
+ sympy/`Python <https://docs.python.org/3/reference/expressions.html#operator-precedence>`_
19
+ and `libsbml L3 formulas <https://synonym.caltech.edu/software/libsbml/5.18.0/docs/formatted/python-api/libsbml-math.html#math-l3>`_!)
20
+
21
+ * retaining unit annotations and other ``<ci>`` attributes
22
+
23
+ **NOTE: This is under development and the API is to be considered unstable**
24
+
25
+ Python support policy: sbmlmath follows `NEP 29 <https://numpy.org/neps/nep-0029-deprecation_policy.html>`_.
26
+
27
+ Usage
28
+ -----
29
+
30
+ .. code-block:: python
31
+
32
+ from sbmlmath import SBMLMathMLPrinter, SBMLMathMLParser
33
+ import sympy as sp
34
+
35
+ sympy_expr = sp.sympify("A ** B + exp(C) * D")
36
+ mathml = SBMLMathMLPrinter().doprint(sympy_expr)
37
+ print(mathml)
38
+
39
+ cycled_sympy = SBMLMathMLParser().parse_str(mathml)
40
+ print(cycled_sympy)
41
+ assert sympy_expr == cycled_sympy
42
+
43
+
44
+ Installation
45
+ ------------
46
+
47
+ Releases from `PyPI <https://pypi.org/project/sbmlmath/>`_:
48
+
49
+ .. code-block:: bash
50
+
51
+ pip install sbmlmath
52
+
53
+ The latest development version from GitHub:
54
+
55
+ .. code-block:: bash
56
+
57
+ pip install https://github.com/dweindl/sbmlmath/archive/main.zip
58
+
59
+
60
+ Source code
61
+ -----------
62
+
63
+ The source code is hosted on `GitHub <https://github.com/dweindl/sbmlmath>`_.
@@ -0,0 +1,10 @@
1
+ API reference
2
+ =============
3
+
4
+ .. rubric:: Modules
5
+
6
+ .. autosummary::
7
+ :toctree: generated
8
+ :recursive:
9
+
10
+ sbmlmath
@@ -0,0 +1,83 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+ import zlib
9
+
10
+
11
+ def get_libsbml_inventory(
12
+ filename: str = "libsbml.inv",
13
+ base_url: str = "https://sbml.org/software/libsbml/5.18.0/docs/formatted/python-api/",
14
+ ) -> tuple[str, str]:
15
+ """Create the libsbml inventory file for use with intersphinx."""
16
+ inventory_header = (
17
+ "# Sphinx inventory version 2\n"
18
+ "# Project: libsbml\n"
19
+ "# Version: 5.18.0\n"
20
+ "# The remainder of this file is compressed using zlib.\n"
21
+ )
22
+ inventory_content = (
23
+ "libsbml.ASTNode py:class -1 classlibsbml_1_1_a_s_t_node.html libsbml.ASTNode\n"
24
+ "libsbml.SBase py:class -1 classlibsbml_1_1_s_base.html libsbml.SBase\n"
25
+ )
26
+ compressed_content = zlib.compress(inventory_content.encode("utf-8"))
27
+
28
+ with open(filename, "wb") as f:
29
+ f.write(inventory_header.encode("utf-8"))
30
+ f.write(compressed_content)
31
+
32
+ return (base_url, filename)
33
+
34
+
35
+ project = "sbmlmath"
36
+ copyright = "2024, Daniel Weindl"
37
+ author = "Daniel Weindl"
38
+
39
+ # -- General configuration ---------------------------------------------------
40
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
41
+
42
+ extensions = [
43
+ "sphinx.ext.autodoc",
44
+ "sphinx.ext.intersphinx",
45
+ "sphinx.ext.autosummary",
46
+ "sphinx.ext.viewcode",
47
+ "sphinx.ext.napoleon",
48
+ "sphinx_autodoc_typehints",
49
+ ]
50
+
51
+ templates_path = ["_templates"]
52
+ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
53
+
54
+
55
+ autodoc_default_options = {
56
+ "members": None,
57
+ "imported-members": ["sbmlmath"],
58
+ "inherited-members": False,
59
+ "show-inheritance": None,
60
+ }
61
+
62
+ # sphinx-autodoc-typehints options
63
+ # https://github.com/tox-dev/sphinx-autodoc-typehints
64
+ always_use_bars_union = True
65
+ typehints_fully_qualified = False
66
+
67
+ # autodoc_class_signature = "separated"
68
+
69
+ intersphinx_mapping = {
70
+ "sympy": ("https://docs.sympy.org/latest/", None),
71
+ "pint": ("https://pint.readthedocs.io/en/stable/", None),
72
+ "python": ("https://docs.python.org/3", None),
73
+ "libsbml": get_libsbml_inventory(),
74
+ }
75
+
76
+ typehints_document_rtype = True
77
+ autodoc_typehints = "description"
78
+
79
+ # -- Options for HTML output -------------------------------------------------
80
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
81
+
82
+ html_theme = "alabaster"
83
+ html_static_path = ["_static"]
@@ -0,0 +1,9 @@
1
+ .. include:: about.rst
2
+
3
+
4
+ .. toctree::
5
+ :maxdepth: 3
6
+ :caption: Contents:
7
+
8
+ About <about>
9
+ API reference <api>
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=.
11
+ set BUILDDIR=_build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
@@ -0,0 +1,2 @@
1
+ sphinx>=8
2
+ sphinx-autodoc-typehints>=2.4
@@ -4,23 +4,26 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "sbmlmath"
7
- version = "0.0.2"
7
+ version = "0.1.1"
8
8
  authors = [
9
9
  {name = "Daniel Weindl", email = "sci@danielweindl.de"},
10
10
  ]
11
11
  description = "SBML Math <-> SymPy"
12
12
  readme = "README.md"
13
- requires-python = ">=3.10"
13
+ requires-python = ">=3.9"
14
14
  license = {text = "BSD-3-Clause"}
15
15
  dependencies = [
16
16
  "python-libsbml",
17
17
  "sympy",
18
18
  "pint",
19
- "lxml",
19
+ "lxml>=4.6.4",
20
20
  ]
21
21
 
22
22
  [project.optional-dependencies]
23
- test = ["pytest", "pre-commit"]
23
+ test = ["pytest>=7", "pre-commit>=3"]
24
24
 
25
25
  [tool.black]
26
26
  line-length = 80
27
+
28
+ [tool.pytest.ini_options]
29
+ addopts = "--doctest-modules --ignore=doc/conf.py"
@@ -3,12 +3,11 @@ from typing import Union
3
3
  import libsbml
4
4
  import sympy as sp
5
5
 
6
+ from .cfunction import *
7
+ from .csymbol import *
6
8
  from .mathml_parser import SBMLMathMLParser
7
9
  from .mathml_printer import SBMLMathMLPrinter
8
10
  from .species_symbol import SpeciesSymbol
9
- from .csymbol import *
10
- from .cfunction import *
11
-
12
11
 
13
12
  __all__ = [
14
13
  "SBMLMathMLParser",
@@ -23,7 +22,21 @@ __all__ = [
23
22
 
24
23
 
25
24
  def sympy_to_sbml_math(sp_expr: sp.Expr) -> libsbml.ASTNode:
26
- """Convert sympy expression to SBML math ASTNode"""
25
+ """Convert sympy expression to SBML math ASTNode.
26
+
27
+ This function takes a SymPy expression and converts it to an SBML math
28
+ ASTNode.
29
+
30
+ Args:
31
+ sp_expr: The SymPy expression to be converted.
32
+
33
+ Returns:
34
+ The resulting SBML math ASTNode.
35
+
36
+ Raises:
37
+ ValueError:
38
+ If there is an error in converting the math expression.
39
+ """
27
40
  mathml = SBMLMathMLPrinter().doprint(sp_expr)
28
41
 
29
42
  if ast_node := libsbml.readMathMLFromString(mathml):
@@ -37,7 +50,17 @@ def sympy_to_sbml_math(sp_expr: sp.Expr) -> libsbml.ASTNode:
37
50
  def sbml_math_to_sympy(
38
51
  sbml_obj: Union[libsbml.SBase, libsbml.ASTNode]
39
52
  ) -> sp.Expr:
40
- """Convert SBML MathML to sympy using the custom MathML parser"""
53
+ """Convert SBML MathML to sympy expression.
54
+
55
+ Conversion is done using the default settings of :class:`SBMLMathMLParser`.
56
+
57
+ Args:
58
+ sbml_obj:
59
+ The SBML object to be converted.
60
+ (Either directly the ASTNode or the surrounding SBase object).
61
+ Returns:
62
+ The resulting sympy expression.
63
+ """
41
64
  ast_node = (
42
65
  sbml_obj
43
66
  if isinstance(sbml_obj, libsbml.ASTNode)