@unc_wrapper decorator to wrap any Python callable to append the
covariance and Jacobian matrices to the return values. See documentation and
tests for usage and examples.
pip install UncertaintyWrapper to install from
PyPI or download a source
distribution, extract and use
python setup.py install.
from uncertainty_wrapper import unc_wraper import numpy as np @unc_wrapper def f(x): return np.exp(x) x, cov = np.array([[1.0]]), np.array([[0.1]]) f(x, __covariance__=cov)
(array([[ 2.71828183]]), # exp(1.0) array([[[ 0.73890561]]]), # (delta-f)^2 = (df/dx)^2 * (delta-x)^2 array([[[ 2.71828183]]])) # df/dx = exp(x)
Releases are named after geological eons, periods and epochs.
- Jagged arrays of covariance keys work now.
- Fixes #5,
ValueErrorif covariance keys have multiple observations
- fix covariance cross terms not scaled correctly
- Fixes #4,
ValueErrorif just one observation
- Fixes #2, don't need to tile scalar x for multiple observations
- Fixes #3, use sparse matrices for dot product instead of dense
- uses pvlib example instead of proprietary solar_utils
- Fixes #1 works with Pint's @ureg.wraps()
- Use indices for positional arguments. Don't use inspect.argspec since not guaranteed to be the same for wrapped or decorated functions
- Test Jacobian estimate for IV with AlgoPy
- Show Jacobian errors plot in getting started docs.
unc_wrapper_args()allows selection of independent variables that the partial derivatives are with respect to and also grouping those arguments together so that in the original function they can stay unpacked.
- return values are grouped correctly so that they can remain unpacked in original function. These allow Uncertainty Wrapper to be used with Pint's wrapper
- covariance now specified as dimensionaless fraction of square of arguments
- more complex tests: IV curve and solar position (requires NREL's solpos)
- update documentation
- Fix nargs and nf order mixup in Jacobian
- add more complex test
- fix tile cov by nobs
- move partial derivative to subfunction
- try threading, but same speed, and would only work with NumPy anyway
- adds covariance to output
- allows __covariance__ to be passed as input
- uses estimate Jacobian based on central finite difference method