Automatic Error Propagation
When there are uncertainties in physics, you might need to deal with error propagation, which gets really annoying really really fast as the equation gets longer, especially if you need to write down the expression using variables for a school test or something. This package automates the process of propagating the error.
Installation
$ pip install errorpp
Function and Scope
As this is still being developed, the error propagation only supports expanding addition, multiplication, division and power of a real number. If you input anything else such as sin(x), it will throw an error. If you want see more functions implemented, open an issue, or better yet, make a pull request!
Usage
In its core, it uses sympy to process the expression. the errorpp.propagate function will take a sympy expression as the argument return the sympy expression with the error propagated. If your variables are all positive, you can pass in absolute=False to prevent the program from wrapping variables in absolute signs, which makes a cleaner output as sympy can cancel variables more easily.
You can also use the counterpart errorpp.propagate_latex which takes a string of latex expression as the argument and output the latex expression with the error propagated.
Alternatively, you directly call this module from the terminal, which takes an latex equation as its first argument and print the latex expression with the error propagated to standard output. Use --no-absolute to prevent the program from wrapping variables in absolute sign.
Since the code base is quite small, I won't make a website with the documentation, but instead I will write the explanation in the docstring in the source code.
Code Example
You can use this directly in terminal
$ errorpp '\\frac{- c_{w} m_{1} \\left(- T_{1} + T_{f}\\right) + c_{w} m_{2} \\left(T_{2} - T_{f}\\right)}{- T_{1} + T_{f}}' --no-absolute
# output
# \frac{\sqrt{\frac{c_{w}^{2} m_{1}^{2} \left(- T_{1} + T_{f}\right)^{2} \left(\frac{\Delta^{2}{\left(T_{1} \right)} + \Delta^{2}{\left(T_{f} \right)}}{\left(- T_{1} + T_{f}\right)^{2}} + \frac{\Delta^{2}{\left(m_{1} \right)}}{m_{1}^{2}} + \frac{\Delta^{2}{\left(c_{w} \right)}}{c_{w}^{2}}\right) + c_{w}^{2} m_{2}^{2} \left(T_{2} - T_{f}\right)^{2} \left(\frac{\Delta^{2}{\left(T_{2} \right)} + \Delta^{2}{\left(T_{f} \right)}}{\left(T_{2} - T_{f}\right)^{2}} + \frac{\Delta^{2}{\left(m_{2} \right)}}{m_{2}^{2}} + \frac{\Delta^{2}{\left(c_{w} \right)}}{c_{w}^{2}}\right)}{\left(- c_{w} m_{1} \left(- T_{1} + T_{f}\right) + c_{w} m_{2} \left(T_{2} - T_{f}\right)\right)^{2}} + \frac{\Delta^{2}{\left(T_{1} \right)} + \Delta^{2}{\left(T_{f} \right)}}{\left(- T_{1} + T_{f}\right)^{2}}} \left(- c_{w} m_{1} \left(- T_{1} + T_{f}\right) + c_{w} m_{2} \left(T_{2} - T_{f}\right)\right)}{- T_{1} + T_{f}}
Or import this as a module
import errorpp
import sympy
eq = sympy.parse_latex('\\frac{- c_{w} m_{1} \\left(- T_{1} + T_{f}\\right) + c_{w} m_{2} \\left(T_{2} - T_{f}\\right)}{- T_{1} + T_{f}}')
p = errorpp.propagate(eq, absolute=False)
print(pretty(eq, use_unicode=False))
# Output
# _____________________________________________________________________
# / / 2 2 2
# / 2 2 2 |Delta (T_1) + Delta (T_f) Delta (m_1) D
# / c_w *m_1 *(-T_1 + T_f) *|------------------------- + ----------- + -
# / | 2 2
# / \ (-T_1 + T_f) m_1
# / --------------------------------------------------------------------
# /
# \/ (-c_w*m_1*(
# ------------------------------------------------------------------------------
#
#
# ______________________________________________________________________________
# 2 \ / 2 2 2
# elta (c_w)| 2 2 2 |Delta (T_2) + Delta (T_f) Delta (m_2)
# ----------| + c_w *m_2 *(T_2 - T_f) *|------------------------- + -----------
# 2 | | 2 2
# c_w / \ (T_2 - T_f) m_2
# ------------------------------------------------------------------------------
# 2
# -T_1 + T_f) + c_w*m_2*(T_2 - T_f))
# ------------------------------------------------------------------------------
# -T_1 + T_f
#
# ___________________________________________
# 2 \
# Delta (c_w)|
# + -----------|
# 2 | 2 2
# c_w / Delta (T_1) + Delta (T_f)
# -------------- + ------------------------- *(-c_w*m_1*(-T_1 + T_f) + c_w*m_2*(
# 2
# (-T_1 + T_f)
# ------------------------------------------------------------------------------
#
#
#
#
#
#
#
#
# T_2 - T_f))
#
#
# -----------
#
Metadata
Release files for errorpp 0.0.7
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 |
|---|---|---|---|---|
| errorpp-0.0.7.tar.gz | 4.4 kB | Without provenance | Details for errorpp-0.0.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| errorpp-0.0.7-py3-none-any.whl | Python 3 | none | any | Details for errorpp-0.0.7-py3-none-any.whl |
Total release size: 9.4 kB
Release files / errorpp-0.0.7.tar.gz
| Download URL | errorpp-0.0.7.tar.gz |
|---|---|
| Size | 4.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5828847af530c7a7885a65789e375a44869486c86c07cd84849c2433fb72ea7d
|
|
BLAKE2b-256 checksum How to use checksums |
2186407398ceece642765a0592c8786b3753c51aa6806a6da4c038e355779598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Release files / errorpp-0.0.7-py3-none-any.whl
| Download URL | errorpp-0.0.7-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74fecf8db2af9bbc567e63eb7fcd2f181b29ffaa1a81b01c0999f16d04797b23
|
|
BLAKE2b-256 checksum How to use checksums |
2d90f4dfc4e2052f08012eab2b3725d475078a6b5e388f65321a4809f10661f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10
|
Security for errorpp 0.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.