{"id":3847,"library":"uncertainties","title":"Uncertainties: Error Propagation Library","description":"The `uncertainties` package is an open-source Python library for doing calculations on numbers that have uncertainties (like 3.14±0.01). It automatically propagates uncertainties and handles correlations using linear error propagation theory. Maintained by the lmfit organization, it is actively developed, with version 3.2.4 released in January 2026, and a major 4.0.0 release is forthcoming.","status":"active","version":"3.2.4","language":"python","source_language":"en","source_url":"https://github.com/lmfit/uncertainties","tags":["scientific computing","error propagation","numerical analysis","uncertainty","physics","engineering"],"install":[{"cmd":"pip install uncertainties","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Optional dependency for array and matrix operations (unumpy submodule), not required for core functionality.","package":"numpy","optional":true}],"imports":[{"symbol":"ufloat","correct":"from uncertainties import ufloat"},{"note":"Provides mathematical functions for `ufloat` objects. Some functions are deprecated as of 3.2.2.","symbol":"umath","correct":"from uncertainties.umath import sin, cos"},{"note":"Provides NumPy-like array and matrix operations for `ufloat` objects. `unumpy.umatrix` is deprecated.","symbol":"unumpy","correct":"from uncertainties import unumpy"}],"quickstart":{"code":"from uncertainties import ufloat\nfrom uncertainties.umath import sin\n\nx = ufloat(2, 0.1)  # x = 2 +/- 0.1\ny = ufloat(3, 0.2)  # y = 3 +/- 0.2\n\nresult_sum = x + y\nresult_product = x * y\nresult_sin = sin(x)\n\nprint(f\"Sum: {result_sum}\")\nprint(f\"Product: {result_product}\")\nprint(f\"Sin(x): {result_sin}\")\n\n# Accessing nominal value and standard deviation\nprint(f\"Nominal value of sum: {result_sum.nominal_value}\")\nprint(f\"Standard deviation of sum: {result_sum.std_dev}\")","lang":"python","description":"Create numbers with uncertainties using `ufloat` and perform standard arithmetic or mathematical operations, with uncertainties automatically propagated."},"warnings":[{"fix":"Review the 4.0.0 release notes and documentation upon release for specific migration instructions.","message":"Version 4.0.0 is under development and will introduce significant breaking changes, notably making `UFloat` objects immutable. Plan for migration once 4.0 is released.","severity":"breaking","affected_versions":"Future (4.0.0+)"},{"fix":"Ensure `numpy` is installed (`pip install numpy`) if you intend to use `uncertainties.unumpy` or other `numpy`-dependent features.","message":"The handling of `numpy` as an optional dependency changed in version 3.2.3. Previously, importing a `numpy`-dependent function without `numpy` installed would raise an `ImportError`. Now, such functions can be imported, but attempting to execute them will raise a `NotImplementedError`.","severity":"breaking","affected_versions":">=3.2.3"},{"fix":"Replace usage of `unumpy.umatrix` with `unumpy.uarray` and standard NumPy array operations on `ufloat` objects, which are well-supported.","message":"`uncertainties.unumpy.umatrix` is deprecated as of version 3.2.2 and will be removed in version 4.0. This aligns with the broader discouragement of `numpy.matrix` in NumPy itself.","severity":"deprecated","affected_versions":">=3.2.2 (removal in 4.0.0+)"},{"fix":"Consult the `uncertainties` documentation for alternatives or use standard Python operations where applicable.","message":"Several functions in `uncertainties.umath` (e.g., `ceil`, `fabs`, `floor`, `trunc`) and methods on `AffineScalarFunc`/`UFloat` objects (e.g., `__floordiv__`, `__mod__`, `__abs__`) were deprecated in 3.2.2 and will be removed in a future release.","severity":"deprecated","affected_versions":">=3.2.2"},{"fix":"Review code for instances where `ufloat` is initialized with a standard deviation of zero if unexpected warnings appear.","message":"As of version 3.2.4, the stacklevel of the warning for `std_dev==0` has been increased. This means the warning will now point to the user's calling code rather than `ufloat()`, making it easier to diagnose the source of zero standard deviation inputs.","severity":"gotcha","affected_versions":">=3.2.4"}],"env_vars":null,"search_vec":"'0.01':25 '2026':53 '3.14':24 '3.2.4':49 '4.0.0':57 'activ':45 'analysi':66 'automat':27 'calcul':17 'comput':62 'correl':32 'develop':46 'engin':69 'error':2,35,63 'forthcom':60 'handl':31 'januari':52 'librari':4,14 'like':23 'linear':34 'lmfit':41 'maintain':38 'major':56 'number':19 'numer':65 'open':11 'open-sourc':10 'organ':42 'packag':7 'physic':68 'propag':3,28,36,64 'python':13 'releas':50,58 'scientif':61 'sourc':12 'theori':37 'uncertainti':1,6,22,29,67 'use':33 'version':48","created_at":"2026-04-11T17:47:13.758187+00:00","updated_at":"2026-04-16T23:54:21.493878+00:00","problems":[{"fix":"Install the package using pip: `pip install uncertainties`","cause":"The `uncertainties` package is not installed in the current Python environment or is not accessible on the PYTHONPATH.","error":"ModuleNotFoundError: No module named 'uncertainties'"},{"fix":"Use functions from `uncertainties.umath` (e.g., `umath.sin`) or wrap the original function with `uncertainties.wrap()`.","cause":"Standard `math` module functions do not know how to handle `ufloat` objects directly, expecting a standard float.","error":"TypeError: a float is required"},{"fix":"Access the nominal value using `.n` and the standard deviation (uncertainty) using `.s` (e.g., `my_ufloat_obj.n`, `my_ufloat_obj.s`).","cause":"Users often guess attribute names for accessing the nominal value or standard deviation of a `ufloat` object.","error":"AttributeError: 'ufloat' object has no attribute 'value'"},{"fix":"To create an array of uncertain numbers, use `uncertainties.unumpy.uarray` with separate lists for nominal values and uncertainties, or create a list of individual `ufloat` objects.","cause":"The `ufloat` constructor expects a single numerical value and its single uncertainty, not a list of values or uncertainties.","error":"TypeError: 'list' object cannot be interpreted as an uncertainty value"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"3.2.3","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/lmfit/uncertainties","docs":"https://uncertainties.readthedocs.io/","changelog":"https://github.com/lmfit/uncertainties/blob/master/CHANGES.rst","pypi":"https://pypi.org/project/uncertainties/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-29","next_check":"2026-07-28","install_tag":null}}