{"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":"en","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,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}