Skip to main content

Uncertainty wrapper using estimated Jacobian

Project description

https://travis-ci.org/SunPower/UncertaintyWrapper.svg?branch=master

UncertaintyWrapper

Use @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.

Installation

Use pip install UncertaintyWrapper to install from PyPI or download a source distribution, extract and use python setup.py install.

Requirements

Optional Requirements

Usage

Example:

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)

Returns:

(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)

History

Releases are named after geological eons, periods and epochs.

v0.4.1 Paleozoic Era

  • Jagged arrays of covariance keys work now.

  • simplify

v0.4 Phanerozoic Era

  • Fixes #5, ValueError if covariance keys have multiple observations

  • fix covariance cross terms not scaled correctly

v0.3.3 Neoproterozoic Era

  • Fixes #4, ValueError if just one observation

v0.3.2 Mesoproterozoic Era

  • 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

v0.3.1 Paleoproterozoic Era

  • 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.

v0.3 Proterozoic Eon

  • new 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)

v0.2.1 Eoarchean Era

  • update documentation

v0.2 Archean Eon

  • 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

v0.1 Hadean Eon

  • adds covariance to output

  • allows __covariance__ to be passed as input

  • uses estimate Jacobian based on central finite difference method

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

uncertainty_wrapper-0.4.2a0.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

uncertainty_wrapper-0.4.2a0-py2-none-any.whl (27.3 kB view details)

Uploaded Python 2

File details

Details for the file uncertainty_wrapper-0.4.2a0.tar.gz.

File metadata

File hashes

Hashes for uncertainty_wrapper-0.4.2a0.tar.gz
Algorithm Hash digest
SHA256 2baeddc4c04f1b64341f47cac665a721bd24d9610a4084751962e6ddcc092ec6
MD5 c4589d39fad57015ae1d5c56da273d9f
BLAKE2b-256 3e12d5e8b6e1e58f0bfcaf20bd0248e7219432a1f677d10cf001d5e01ad043db

See more details on using hashes here.

File details

Details for the file uncertainty_wrapper-0.4.2a0-py2-none-any.whl.

File metadata

File hashes

Hashes for uncertainty_wrapper-0.4.2a0-py2-none-any.whl
Algorithm Hash digest
SHA256 032d83c2a70ad60730944e0b50b7181fe7040239c278570a1d68a6633013c773
MD5 ac14dc83aaeda998420a2416bd528010
BLAKE2b-256 a5c3d89869144fbff9dcb5551ce40dff66d66be69ad9edbcecbcbde84d8aaf98

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page