Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos in ufloat_fromstr doctring examples #286

Merged
merged 2 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Adds:

Fixes:

- add note on string not containing uncertainty to `ufloat_fromstr` doctring (#287)
- fix typos in `ufloat_fromstr` docstring examples (#285)
- fix `readthedocs` configuration so that the build passes (#254)
- adjust `codecov.io` configuration so that minor code coverage changes will not result
in indications that tests are failing. Rather code coverage reports will be purely
Expand Down
18 changes: 12 additions & 6 deletions uncertainties/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,19 +985,25 @@ def ufloat_fromstr(representation, tag=None):
That is, "1.25(3)" is the same as `ufloat(1.25, 0.03)`,
while "1.25(3.)" is the same as `ufloat(1.25, 3.)`

3. If the representation does not contain an uncertainty, an
uncertainty of 1 in the least significant digit is assigned to
the nominal value. For nominal values corresponding to "nan", an
uncertainty of 1 is assigned.

Examples:
-----------

>>> x = ufloat_fromsstr("12.58+/-0.23") # = ufloat(12.58, 0.23)
>>> x = ufloat_fromsstr("12.58 ± 0.23") # = ufloat(12.58, 0.23)
>>> x = ufloat_fromsstr("3.85e5 +/- 2.3e4") # = ufloat(3.8e5, 2.3e4)
>>> x = ufloat_fromsstr("(38.5 +/- 2.3)e4") # = ufloat(3.8e5, 2.3e4)
>>> x = ufloat_fromstr("12.58+/-0.23") # = ufloat(12.58, 0.23)
>>> x = ufloat_fromstr("12.58 ± 0.23") # = ufloat(12.58, 0.23)
>>> x = ufloat_fromstr("3.85e5 +/- 2.3e4") # = ufloat(3.8e5, 2.3e4)
>>> x = ufloat_fromstr("(38.5 +/- 2.3)e4") # = ufloat(3.8e5, 2.3e4)

>>> x = ufloat_fromsstr("72.1(2.2)") # = ufloat(72.1, 2.2)
>>> x = ufloat_fromsstr("72.15(4)") # = ufloat(72.15, 0.04)
>>> x = ufloat_fromstr("72.1(2.2)") # = ufloat(72.1, 2.2)
>>> x = ufloat_fromstr("72.15(4)") # = ufloat(72.15, 0.04)
>>> x = ufloat_fromstr("680(41)e-3") # = ufloat(0.68, 0.041)
>>> x = ufloat_fromstr("23.2") # = ufloat(23.2, 0.1)
>>> x = ufloat_fromstr("23.29") # = ufloat(23.29, 0.01)
>>> x = ufloat_fromstr("nan") # = ufloat(numpy.nan, 1.0)

>>> x = ufloat_fromstr("680.3(nan)") # = ufloat(680.3, numpy.nan)
"""
Expand Down
Loading