Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
3a53d8c
A first pass on linear_combo -> ucombo
jagerber48 Aug 9, 2024
01ef70d
revert test changes
jagerber48 Aug 10, 2024
f338549
rework UCombo, delete Variable
jagerber48 Aug 11, 2024
5f64b9e
some test updates
jagerber48 Aug 11, 2024
80e3d31
Pass more tests
jagerber48 Aug 12, 2024
f939766
Merge branch 'master' into feature/linear_combo_refactor
jagerber48 Nov 5, 2024
d7b9a2e
remove large float test
jagerber48 Nov 16, 2024
48c3973
Clean up UFloat class
jagerber48 Nov 17, 2024
1731b5a
some formatting changes
jagerber48 Nov 17, 2024
f0d4225
uncertainty instead of _linear_combo
jagerber48 Nov 17, 2024
1b385f2
variety of updates and test cleanup
jagerber48 Nov 17, 2024
fe849ff
copy tests
jagerber48 Nov 17, 2024
c8fc497
pickling tests
jagerber48 Nov 17, 2024
681bef9
no negative std_dev in tests
jagerber48 Nov 17, 2024
2c1b11d
modify test
jagerber48 Nov 17, 2024
ac6b497
more tests
jagerber48 Nov 17, 2024
b3f7fb2
handle some edge cases with 0 uncertainty
jagerber48 Nov 18, 2024
fc6e592
fix test_hypot
jagerber48 Dec 5, 2024
f2bfc60
compare analytic and numerical derivatives on math functions
jagerber48 Dec 7, 2024
2361849
unumpy
jagerber48 Dec 7, 2024
3c428a2
mainly code to handle inv and pinv array function
jagerber48 Dec 12, 2024
24f1249
Merge remote-tracking branch 'lmfit/master' into feature/linear_combo…
jagerber48 Dec 12, 2024
4084e7f
fix import
jagerber48 Dec 12, 2024
ec8d7f8
slim down UCombo, especially remove __hash__
jagerber48 Dec 13, 2024
eba7ccd
Add hashes
jagerber48 Dec 13, 2024
3f78e5c
bring back is_expanded
jagerber48 Dec 13, 2024
c80dd9b
do not check std_dev during operations. This kills performance.
jagerber48 Dec 13, 2024
5fc3cbd
avoid empty ucombos, or ucombo/uatom weights exactly equal to zero.
jagerber48 Dec 13, 2024
6d53afb
special case empty uncertainty in the tests. Is this something we want??
jagerber48 Dec 13, 2024
7ad82ba
fix broken test that wasn't running
jagerber48 Dec 17, 2024
fb69b1f
ucombo clean up and refactor
jagerber48 Dec 17, 2024
7c35233
don't calculate std_dev with kwargs inputs, cleanup f_with_affine_out…
jagerber48 Dec 17, 2024
0eb135b
some correlated_values_norm cleanup
jagerber48 Dec 17, 2024
c6f116f
todo on untested, probably broken functions
jagerber48 Dec 17, 2024
a8fd413
codecov CI
jagerber48 Dec 18, 2024
0abc0f6
revert previous commit (it was made to the wrong branch and had a wro…
jagerber48 Dec 18, 2024
0086a0a
fixed ucombo hash
jagerber48 Dec 26, 2024
e6211ca
Merge branch 'master' into feature/linear_combo_refactor
jagerber48 Dec 28, 2024
7aeeed0
start updating docs
jagerber48 Dec 28, 2024
ddf2e1d
instance check for ABC real seems to be slow. See if removing that im…
jagerber48 Dec 28, 2024
40b088c
need to include int
jagerber48 Dec 28, 2024
968feef
documentation and doctest
jagerber48 Dec 30, 2024
d5edb5f
fix index
jagerber48 Dec 30, 2024
76a4b80
cast default dict to dict for ucombo expanded dict. Also don't do eag…
jagerber48 Dec 30, 2024
1da88c3
Add back make.bat
jagerber48 Dec 30, 2024
54179b7
add doctest sphinx extension in conf.py so doctests can run
jagerber48 Dec 30, 2024
e8aba3f
Merge branch 'feature/add_make.bat' into feature/linear_combo_refactor
jagerber48 Dec 30, 2024
1da127e
UAtom repr
jagerber48 Dec 30, 2024
17bc5a7
error_components doctest
jagerber48 Dec 30, 2024
34701c2
doctests
jagerber48 Dec 30, 2024
5c309d4
more documentation
jagerber48 Dec 30, 2024
79e00d0
don't document Variable
jagerber48 Dec 31, 2024
9607a0d
add tuples instead of nesting for addition. Will this be faster?
jagerber48 Dec 31, 2024
e7e327d
Merge branch 'master' into feature/linear_combo_refactor
jagerber48 Mar 15, 2025
357a37f
refactor test_power_derivatives
jagerber48 Mar 15, 2025
ee48ae2
Merge branch 'master' into feature/linear_combo_refactor
jagerber48 Apr 10, 2025
1b6bffa
Merge branch 'master' into feature/linear_combo_refactor
jagerber48 Apr 29, 2025
1b95718
fixed mangled merge ordering
jagerber48 Apr 29, 2025
cb5e067
fix import
jagerber48 Apr 29, 2025
abb3c4d
Merge branch 'main' into test_merge_2
jagerber48 May 23, 2025
3485582
fix some tests
jagerber48 May 23, 2025
951abf8
use simpler test
jagerber48 May 23, 2025
f506876
Merge branch 'main' into test_merge_2
jagerber48 May 28, 2025
6c119c9
remove unused cases and generation code
jagerber48 May 28, 2025
0003ed8
use other case strategy
jagerber48 May 28, 2025
abca48a
Merge branch 'test_merge_2' into feature/linear_combo_refactor
jagerber48 May 28, 2025
2f899e0
start handling zero weight differently
jagerber48 May 28, 2025
42542fa
rewrite tests
jagerber48 May 28, 2025
8b14818
calculated zero equality test
jagerber48 May 28, 2025
7e2bf91
Merge branch 'main' into feature/linear_combo_refactor
jagerber48 May 31, 2025
fd95a83
See if uuid1 is faster
jagerber48 Jun 6, 2025
0d7594e
pickle docs
jagerber48 Jun 6, 2025
a63b0bc
stop doctests for now
jagerber48 Jun 6, 2025
357601b
try getrandbits
jagerber48 Jun 6, 2025
1b675bd
remove checks
jagerber48 Jun 6, 2025
7688ac7
remove more checks
jagerber48 Jun 6, 2025
ceda0d3
simplify hash
jagerber48 Jun 6, 2025
4b0588c
remove the bigger performance tests
jagerber48 Jun 6, 2025
fbc05e3
back to hash calculation
jagerber48 Jun 6, 2025
d270258
Merge branch 'main' into feature/linear_combo_refactor
jagerber48 Jun 6, 2025
fcdf1a1
Merge branch 'main' into feature/linear_combo_refactor
jagerber48 Jun 6, 2025
9b9bca1
Merge branch 'main' into feature/linear_combo_refactor
jagerber48 Jun 6, 2025
a2d5bc4
ValueError
jagerber48 Jun 6, 2025
6df7b46
large number changelog
jagerber48 Jun 6, 2025
cb4f7b7
better type annotations
jagerber48 Jun 7, 2025
5d3be9a
UFloat class accepts std_dev only now for a better public API.
jagerber48 Jun 7, 2025
2d9fb89
smaller uuid
jagerber48 Jun 7, 2025
0a21c25
add correlation and covariance functions
jagerber48 Jun 8, 2025
4d584e5
changelog
jagerber48 Jun 8, 2025
1a222e1
make uncertainty and UCombo stuff private
jagerber48 Jun 8, 2025
4fb33b1
readme.rst
jagerber48 Jun 8, 2025
7f4f00f
index.rst
jagerber48 Jun 8, 2025
fda9f90
repr and str include tag
jagerber48 Jun 8, 2025
10e63e0
user_guide work
jagerber48 Jun 8, 2025
8d4c8bb
user guide
jagerber48 Jun 9, 2025
ba509bb
more user guide
jagerber48 Jun 9, 2025
87f2461
user guide work
jagerber48 Jun 9, 2025
b93b44f
numpy array if possible
jagerber48 Jun 10, 2025
87bc13d
more user guide
jagerber48 Jun 10, 2025
3805a83
more docs numpy test
jagerber48 Jun 10, 2025
9ede78c
more user guide
jagerber48 Jun 15, 2025
4f71856
random seed
jagerber48 Jun 15, 2025
f0a334f
pickling
jagerber48 Jun 15, 2025
47cae37
comparison
jagerber48 Jun 15, 2025
b21d4ff
don't need to document `isinstance`
jagerber48 Jun 15, 2025
59c44ac
linear breakdown
jagerber48 Jun 15, 2025
532e3c8
nan docs
jagerber48 Jun 15, 2025
b890d23
more documentation
jagerber48 Jun 16, 2025
c3c3cd3
ufloat as alias
jagerber48 Jun 16, 2025
4098296
remove special topics section
jagerber48 Jun 16, 2025
95060b4
doc updates
jagerber48 Jun 16, 2025
60ae418
top bar
jagerber48 Jun 16, 2025
7de5299
pass warning
jagerber48 Jun 16, 2025
703e57c
numpy guide
jagerber48 Jun 16, 2025
ca66831
formatting guide
jagerber48 Jun 16, 2025
8b0a753
bring doctest back
jagerber48 Jun 16, 2025
6583987
formatting
jagerber48 Jun 16, 2025
ac5ae02
Merge branch 'main' into feature/linear_combo_refactor
jagerber48 Jul 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Change Log
Unreleased 4.x
--------------

Adds:

- Adds `UFloat.covariance()` and `UFloat.correlation()` methods to allow easy
calclation of the correlation and covariance between two `UFloat` objects.

Changes:

- Includes the `main` branch in continuous integration automation.
Expand Down Expand Up @@ -40,6 +45,13 @@ Removes:
- [**BREAKING**] Previously if a negative `std_dev` was used to construct a `UFloat`
object a custom `NegativeStdDev` exception was raised. Now a standard `ValueError`
exception is raised.
- Previously it was possible to generate and print `UFloat` objects with very large
values, e.g. `ufloat(3.14e200, 0.1e200)`. However, applying any mathematical
operation would result in an `OverflowError` rendering these objects of minimal use.
As a result of other changes, it is no longer possible to print such large `UFloat`
objects. It is still possible to generate large `UFloat` objects, but operations
still result in `OverflowError` and their use is generally not supported.


Unreleased
----------
Expand Down
51 changes: 22 additions & 29 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,28 @@ Basic examples

.. code-block:: python

>>> from uncertainties import ufloat
>>> x = ufloat(2, 0.25)
>>> x
>>> from uncertainties import UFloat
>>> x = UFloat(2, 0.25)
>>> print(x)
2.0+/-0.25

>>> print(x**2)
>>> square = x**2
>>> square
>>> print(square)
4.0+/-1.0
>>> square.nominal_value
>>> print(square.nominal_value)
4.0
>>> square.std_dev # Standard deviation
>>> print(square.std_dev) # Standard deviation
1.0

>>> square - x*x
0.0 # Exactly 0: correlations taken into account
>>> print(square - x*x)
0.0 # Exactly 0: `uncertainties` is aware of correlations

>>> from uncertainties.umath import sin, cos # and many more.
>>> sin(1+x**2)
>>> print(sin(1+x**2))
-0.95892427466313845+/-0.2836621854632263

>>> print (2*x+1000).derivatives[x] # Automatic calculation of derivatives
>>> print(2*x+1000).derivatives[x] # Automatic calculation of derivatives
2.0

>>> from uncertainties import unumpy # Array manipulation
Expand All @@ -64,23 +65,19 @@ Main features
- **Correlations** between expressions are correctly taken into
account. Thus, ``x-x`` is exactly zero.

- **Most mathematical operations** are supported, including most
functions from the standard math_ module (sin,...). Comparison
operators (``>``, ``==``, etc.) are supported too.
- **Many mathematical operations** are supported, including many
functions from the standard math_ module (sin,...).

- Many **fast operations on arrays and matrices** of numbers with
uncertainties are supported.

- **Extensive support for printing** numbers with uncertainties
- **Extensive support for formatting** numbers with uncertainties
(including LaTeX support and pretty-printing).

- Most uncertainty calculations are performed **analytically**.

- This module also gives access to the **derivatives** of any
mathematical expression (they are used by `error
propagation theory`_, and are thus automatically calculated by this
module).

- This module gives access to the error components and weights which contributed to the
total uncertainty on any :class:`UFloat` object.

Installation or upgrade
-----------------------
Expand All @@ -89,9 +86,6 @@ To install `uncertainties`, use::

pip install uncertainties

To upgrade from an older version, use::

pip install --upgrade uncertainties

Further details are in the `on-line documentation
<https://uncertainties.readthedocs.io/en/latest/install.html>`_.
Expand All @@ -100,13 +94,12 @@ Further details are in the `on-line documentation
Git branches
------------

The GitHub ``master`` branch is the latest development version, and is intended
to be a stable pre-release version. It will be experimental, but should pass
all tests.. Tagged releases will be available on GitHub, and correspond to the
releases to PyPI. The GitHub ``gh-pages`` branch will contain a stable test version
of the documentation that can be viewed at
`<https://lmfit.github.io/uncertainties/>`_. Other Github branches should be
treated as unstable and in-progress development branches.
The GitHub ``main`` branch is the latest development version, and is intended to be a
stable pre-release version. It will be experimental, but should pass all tests. Tagged
releases will be available on GitHub, and correspond to the releases to PyPI. The
GitHub ``gh-pages`` branch will contain a stable test version of the documentation that
can be viewed at `<https://lmfit.github.io/uncertainties/>`_. Other Github branches
should be treated as unstable and in-progress development branches.


License
Expand Down
2 changes: 1 addition & 1 deletion doc/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<li>|<a href="{{ pathto('user_guide') }}">User Guide</a></li>
<li>|<a href="{{ pathto('formatting') }}">Formatting</a></li>
<li>|<a href="{{ pathto('numpy_guide') }}"> Numpy Arrays</a></li>
<li>|<a href="{{ pathto('tech_guide') }}">Advanced Topics</a>]</li> &nbsp;
<li>|<a href="{{ pathto('api') }}">API</a>]</li> &nbsp;
&nbsp;
&nbsp; &nbsp;
{% endblock %}
Expand Down
31 changes: 31 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. index:: technical details

=========================
Advanced Topics
=========================


This page gives more in-depth technical description of the
:mod:`uncertainties` package.

.. index:: api

.. _api_funcs:


API: Application Programming Interface
==============================================

.. module:: uncertainties

The most important object is the :class:`UFloat` object.
The :class:`UFloat` object can also be constructed using the :class:`ufloat` alias.
The :func:`ufloat_from_str` function is an alternate constructor.
The :func:`wrap` function wraps user-provided functions to support :class:`UFloat`
objects with uncertainty propagation.

.. autoclass:: UFloat

.. autofunction:: ufloat_fromstr

.. autofunction:: wrap
23 changes: 11 additions & 12 deletions doc/formatting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Printing

.. Overview:

Numbers with uncertainties can be printed conveniently:
The :mod:`uncertainties` package provides functionality for convenient formatting of
:class:`UFloat` objects:

>>> from uncertainties import ufloat
>>> x = ufloat(0.2, 0.01)
Expand All @@ -34,8 +35,7 @@ Standard formats

.. Formatting method:

More **control over the format** can be obtained (in Python 2.6+)
through the usual :func:`format` method of strings:
The formatting can be controlled using various means of formatting python strings:

>>> print('Result = {:10.2f}'.format(x))
Result = 0.20+/- 0.01
Expand All @@ -48,10 +48,9 @@ with the ``n`` format type. In particular, a fill character, an
alignment option, a sign or zero option, a width, or the ``%`` format
type are all supported.

The usual **float formats with a precision** retain their original
meaning (e.g. ``.2e`` uses two digits after the decimal point): code
that works with floats produces similar results when running with
numbers with uncertainties.
The usual **float formats with a precision** retain their original meaning (e.g. ``.2e``
uses two digits after the decimal point): code that works with floats produces similar
results when running used with :class:`UFloat` objects.

Precision control
-----------------
Expand Down Expand Up @@ -203,7 +202,7 @@ It is sometimes useful to have a **consistent formatting** across
multiple parts of a program. Python's `string.Formatter class
<https://docs.python.org/3/library/string.html#custom-string-formatting>`_
allows one to do just that. Here is how it can be used to consistently
use the shorthand notation for numbers with uncertainties:
use the shorthand notation for :class:`UFloat` objects:

.. code-block:: python

Expand All @@ -230,10 +229,10 @@ Customizing the pretty-print and LaTeX outputs

The pretty print and LaTeX outputs themselves can be customized.

For example, the pretty-print representation of numbers with uncertainty can
display multiplication with a centered dot (⋅) instead of the default symbol
(×), like in ``(2.00±0.10)⋅10⁻¹``; this is easily done through the global
setting ``uncertainties.core.MULT_SYMBOLS["pretty-print"] = "⋅"``.
For example, the pretty-print representation of :class:`UFloat` objects can display
multiplication with a centered dot (⋅) instead of the default symbol (×), like in
``(2.00±0.10)⋅10⁻¹``; this is easily done through the global setting
``uncertainties.core.MULT_SYMBOLS["pretty-print"] = "⋅"``.

Beyond this multiplication symbol, the "±" symbol, the parentheses and the
exponent representations can also be customized globally. The details can be
Expand Down
19 changes: 9 additions & 10 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ The :mod:`uncertainties` package takes the pain and
complexity out of uncertainty calculations and error propagation. Here is a
quick taste of how to use :mod:`uncertainties`:

>>> from uncertainties import ufloat
>>> x = ufloat(2, 0.1) # x = 2+/-0.1
>>> y = ufloat(3, 0.2) # y = 3+/-0.2
>>> from uncertainties import UFloat
>>> x = UFloat(2, 0.1) # x = 2+/-0.1
>>> y = UFloat(3, 0.2) # y = 3+/-0.2
>>> print(2*x)
4.00+/-0.20
>>> print(x+y)
Expand All @@ -25,12 +25,11 @@ quick taste of how to use :mod:`uncertainties`:
6.0+/-0.5

The :mod:`uncertainties` library calculates uncertainties using linear `error
propagation theory`_ by automatically :ref:`calculating derivatives
<derivatives>` and analytically propagating these to the results. Correlations
between variables are automatically handled. This library can also yield the
derivatives of any expression with respect to the variables that have uncertain
values. For other approaches, see soerp_ (using higher-order terms) and mcerp_
(using a Monte-Carlo approach).
propagation theory`_ by automatically calculating derivatives and analytically
propagating these to the results.
Correlations between variables are automatically handled.
For other approaches, see soerp_ (using higher-order terms) and mcerp_ (using a
Monte-Carlo approach).

The `source code`_ for the uncertainties package is licensed under the `Revised
BSD License`_. This documentation is licensed under the `CC-SA-3 License`_.
Expand Down Expand Up @@ -58,4 +57,4 @@ Table of Contents
user_guide
numpy_guide
formatting
tech_guide
api
Loading
Loading