LaTeXcalc
What is this?
LaTeXcalc is a LaTeX-Calculation-library for python3.
This calculates a mathematical formula written as a LaTeX-string. It can use a given value-dict for variables in the formula. The return-value is int or float.
Supported features
LaTeXcalc can handle the following LaTeX-operations:
- apply
+,-,*,/operators and the-as algebraic sign - multiplication and division first, then addition and subtraction
- power
^ - brackets
(),[]and{}(also with\left(..\right)) - squareroot
\sqrt{} - trigonometric functions like
\sinor\arctan(radian measure) - exponential numbers linke
1e+12 \ln(natural log),\log(base 10) ande^\piorpiandeas default-valuesmath.piandmath.e\frac{}{}(works as abbreviated\frac 1 2as well)
make sure you always use * (or \cdot), because xy != x*y, in that case xy would be a value!
How to use
You can install this by using pip: pip install latexcalc or alternatively by including the folder latexcalc in your python3-project.
Then all you need to do is
import latexcalc
c = latexcalc.calc('\sqrt{3^2+4^2}')
# or with variables:
c = latexcalc.calc('\sqrt(a^2+b^2)', {'a':3,'b':4})
print(c) # 5.0
Limitations
All testet cases work, but there might still be wrong calculations in special cases, so test it for your needs!
Anything wrong? Something missing?
Feel free to submit an issue if you find a bug or if you think something important is missing.
Just check out the latest code on GitHub and test your issue as it is done for some cases in the test.py. Then please add a Line for the test.py to your report to show the desired operation!
Alternatives
There are some other libraries out there doing similar things, but at time of writing I didn't find anything that fulfilled my needs (lightweight, working with variables, ...). So depending on your requirements this or maybe something else might be the right choise, thank's for cheching this out!
Metadata
Release files for latexcalc 0.8.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| latexcalc-0.8.1.tar.gz | 16.9 kB | Without provenance | Details for latexcalc-0.8.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| latexcalc-0.8.1-py3-none-any.whl | Python 3 | none | any | Details for latexcalc-0.8.1-py3-none-any.whl |
Total release size: 34.4 kB
Release files / latexcalc-0.8.1.tar.gz
| Download URL | latexcalc-0.8.1.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87c2e418cab0e03868d0cd73605c93ac83bed91781b90c871ed988f42089fc80
|
|
BLAKE2b-256 checksum How to use checksums |
0d31f48e7f213feab83284bc2ce1a489a0b5a6fa1f05723096e80ff77133ca11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.3
|
Release files / latexcalc-0.8.1-py3-none-any.whl
| Download URL | latexcalc-0.8.1-py3-none-any.whl |
|---|---|
| Size | 17.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b7e0ab1ee8a72432932c40b8617f3b88fb75a892d64f9d6ae6e0b9115c4a63e3
|
|
BLAKE2b-256 checksum How to use checksums |
a63322fe70b9032e773adff9a732aeddcecd768b8c6998f17d0587ff77854d64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.7.3
|
Security for latexcalc 0.8.1
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.