Skip to main content
https://travis-ci.org/BreakingBytes/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.2 Terreneuvian Series

  • futurize

  • remove pint

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

Metadata

Release files for uncertainty-wrapper 0.4.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uncertainty-wrapper 0.4.2
File Size Uploaded
uncertainty_wrapper-0.4.2.tar.gz 22.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uncertainty-wrapper 0.4.2
File Interpreter ABI Platform
uncertainty_wrapper-0.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 48.5 kB

Release files / uncertainty_wrapper-0.4.2.tar.gz

Download URL uncertainty_wrapper-0.4.2.tar.gz
Size 22.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b8592d281fc906daf4a5eeaecef35d94d579ac91b7011ce2fb50aa0b62885f8b
BLAKE2b-256 checksum
How to use checksums
e8800fd3332908d3cd67485b8fdc72ce1f4ad99857569d381036df4f8c311641
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

Release files / uncertainty_wrapper-0.4.2-py3-none-any.whl

Download URL uncertainty_wrapper-0.4.2-py3-none-any.whl
Size 26.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32c5756a9fdde4aabeb279b9cc14dcfe3649a52220cd614a63eeaad908ac0a3a
BLAKE2b-256 checksum
How to use checksums
fe6df3e3aeaa4d9cee173519c089e4a2c936b9a04ea5206560e053647a2bb95f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.8

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files

0.4.1

2 release files

0.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3

2 release files

0.2.1

2 release files

0.2

2 release files

0.1

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page