Python Math Expression Parser
Project description
python math expression parser is a python project where you can parse or evaluate math expressions.
This algorithm does not use a decision tree. It is a recursive algorithm.
Installation
pip install pymep
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))
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__())
There is a full list of examples inside!!
Enjoy it!!
NOTE: Regarding to the OS where you excute the tests, it is possible that some tests fail due to rounding issues. The mathematical library used in this project is "math". In the future, it is possible that the math library change.
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
Built Distribution
File details
Details for the file pymep-1.0.2.tar.gz
.
File metadata
- Download URL: pymep-1.0.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ae1fb6e33f2a8997210a2605f37dca72acdbfa3ad20358f1a33f107f67292e6 |
|
MD5 | 9e85770bacc80e8d949fdb6ae7e51d01 |
|
BLAKE2b-256 | f26c411ce12295f6c5d4d0afdda5177555c8e710ffa9b5609f01911239052716 |
Provenance
File details
Details for the file pymep-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: pymep-1.0.2-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f8c509fe2e7e477bddce43f2acd83709cfda3f3ec54b5db61dbe1385c659e76 |
|
MD5 | 4a2694684eabb67b87bf2df9b2de9c6b |
|
BLAKE2b-256 | 1f4b14531c69617c137d01ba8a37f76453a14301083b899aa2c3f5f780242043 |