Skip to main content

python.math.expression.parser.pymep

pymep can parse or evaluate math expressions.

This algorithm does not use a decision tree. It is a kind of Recursive Ascent Parser (https://en.wikipedia.org/wiki/Recursive_ascent_parser). In fact, it is LR parser (Left-Right Parser) without backtracking. This recursive algorithm is faster than decision trees

pypi version

https://pypi.org/project/pymep/

Installation

pip install pymep

Examples

Here you can see some examples:

Real Numbers:

from pymep.realParser import parse
from pymep.realParser import eval


#Real Expresion parser
fx="cos(10)"
print(parse(fx))

xi=5
fx = "1 + x"
print(eval(fx, xi))

var = {"x":"1+1", "Z":1}
eval(" 2*(-(((z*3)*sqrt(x^(2)))+3))",var)

For Complex Numbers:

from pymep.complexParser import parse
from pymep.complexParser import eval
from pymep.complex import Complex

#Operation with complex numbers
a = Complex(1,2)
print(a.__radd__(10).__complex__())
print(Complex.radd(10, a).__complex__())


#Complex Expresion parser
fx="cos(10+2j)"
print(parse(fx).__complex__())

xi=5
fx = "1 +j+x"
print(eval(fx, xi).__complex__())

var={"x":"1+2j", "Y":complex(2,1)}
f_x = "x-y"
eval(f_x,var).__complex__()

There is a full list of examples inside!!

Enjoy it!!

The java version of this library is: https://github.com/sbesada/java.math.expression.parser

NOTE: Regarding to the OS where you excute the tests, it is possible that some tests fail beacause of rounding issues. The mathematical library that was used in this project is "math". In the future, it is possible that the math library changes.

PD: If you think that my work deserves a donation, you can do it: https://sbesada.github.io/

Metadata

Release files for pymep 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pymep 1.0.7
File Size Uploaded Provenance
pymep-1.0.7.tar.gz 9.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pymep 1.0.7
File Interpreter ABI Platform
pymep-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 23.7 kB

Release files / pymep-1.0.7.tar.gz

Download URL pymep-1.0.7.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9dcc2cfbb9e2c3d31ac28817457e8d0d4d7bcd070cb9130829fe8661b1088471
BLAKE2b-256 checksum
How to use checksums
a19c784c3ae45d6d05cecc4e57cf3ca77346409f2fdd8f08af6d815372018dc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.4

Release files / pymep-1.0.7-py3-none-any.whl

Download URL pymep-1.0.7-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
48806faf7291f2f84fe4b302288536e57caa01eb3a9fd9ca52f918336a67a948
BLAKE2b-256 checksum
How to use checksums
90065d96d9b09e40470e05d79871a8a8a5f5b270bd2709364c45f85538306a85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.4

Security for pymep 1.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page