Skip to main content

SBML Math <-> SymPy

Project description

sbmlmath — a Python library for handling SBML MathML

PyPI - Version DOI

sbmlmath is a Python library for interconverting SymPy expressions and SBML-MathML. SBML uses a subset of MathML that this library aims to support. This is not (intended to be) a general MathML parser.

Main functionality:

  • sympy -> SBML MathML
  • SBML MathML -> sympy
    • in particular for cases where sympy.sympify(libsbml.formulaToL3String(...)) won't do the job (mind, e.g., the differences in operator precedence between sympy/Python and libsbml L3 formulas!)
    • retaining unit annotations and other <ci> attributes

NOTE: This is under development and the API is to be considered unstable

Python support policy: sbmlmath follows NEP 29.

Usage

from sbmlmath import SBMLMathMLPrinter, SBMLMathMLParser
import sympy as sp

sympy_expr = sp.sympify("A ** B + exp(C) * D")
mathml = SBMLMathMLPrinter().doprint(sympy_expr)
print(mathml)

cycled_sympy = SBMLMathMLParser().parse_str(mathml)
print(cycled_sympy)
assert sympy_expr == cycled_sympy

Documentation

Under construction at sbmlmath.readthedocs.io.

Installation

Releases from PyPI:

pip install sbmlmath

The latest development version from GitHub:

pip install git+https://github.com/dweindl/sbmlmath.git#egg=sbmlmath

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sbmlmath-0.4.1.tar.gz (24.1 kB view details)

Uploaded Source

File details

Details for the file sbmlmath-0.4.1.tar.gz.

File metadata

  • Download URL: sbmlmath-0.4.1.tar.gz
  • Upload date:
  • Size: 24.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sbmlmath-0.4.1.tar.gz
Algorithm Hash digest
SHA256 43f535a74e9d0a135173c35aa7fe3d9376d4d6d6fe292fb435a98f9d8a778b8f
MD5 080982aad719b5b9efdab34d0e0afbda
BLAKE2b-256 6d2aac44ff69317579485332d60a1261914864c5dd0a8cc4496dd5b59dbc40db

See more details on using hashes here.

Provenance

The following attestation bundles were made for sbmlmath-0.4.1.tar.gz:

Publisher: deploy_release.yaml on dweindl/sbmlmath

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page