Skip to content

Commit

Permalink
Release/0.33.0 (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
jagerber48 authored Jan 31, 2024
2 parents b1a4492 + a059e3a commit a52f125
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ This project adheres to `Semantic Versioning <https://semver.org/>`_.
Unreleased
----------

* There are no unreleased changes.

----

0.33.0 (2024-01-31)
-------------------

Added
^^^^^

Expand Down
16 changes: 5 additions & 11 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ available formatting options.
>>> num = 314159.27
>>> unc = 1618
>>> sform = Formatter(
... exp_mode="engineering_shifted",
... pdg_sig_figs=True,
... paren_uncertainty=True
... exp_mode="engineering_shifted", pdg_sig_figs=True, paren_uncertainty=True
... )
>>> print(sform(num, unc))
(0.3142(16))e+06
Expand Down Expand Up @@ -115,15 +113,15 @@ has two significant figures.
The ``()`` indicates that the value/uncertainty pair should be formatted
using the parentheses uncertainty format.

>>> print(f'{SciNum(123):ex-3p}')
>>> print(f"{SciNum(123):ex-3p}")
123000 m

In the preceding example the ``e`` indicates that scientific notation
should be used.
The ``x-3`` indicates that the exponent will be forced to equal ``-3``.
Finally the ``p`` indicates that the SI prefix mode should be used.

>>> print(f'{SciNum(123): .-1f}')
>>> print(f"{SciNum(123): .-1f}")
120

In this example the leading space indicates a leading space should be
Expand Down Expand Up @@ -322,13 +320,9 @@ makes this easy.
>>> import numpy as np
>>>
>>> vec_sform = np.vectorize(sform)
>>> arr = np.array([[1e6, 2e6, 3e6],
... [4e6, 5e6, 6e6],
... [7e6, 8e6, 9e6]])
>>> arr = np.array([[1e6, 2e6, 3e6], [4e6, 5e6, 6e6], [7e6, 8e6, 9e6]])
>>>
>>> arr_err = np.array([[9e4, 8e4, 7e4],
... [6e4, 5e4, 4e4],
... [3e4, 2e4, 1e4]])
>>> arr_err = np.array([[9e4, 8e4, 7e4], [6e4, 5e4, 4e4], [3e4, 2e4, 1e4]])
>>>
>>> print(vec_sform(arr))
[['1 M' '2 M' '3 M']
Expand Down
4 changes: 2 additions & 2 deletions docs/source/fsml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ usage examples.


>>> from sciform import SciNum
>>> print(f'{SciNum(123456):!4f}')
>>> print(f"{SciNum(123456):!4f}")
123500

In this example ``!4`` indicates the number should be formatted with
four significant figures and ``f`` indicates the number should be
formatted in fixed point mode.

>>> print(f'{SciNum(12345, 789):!1r}')
>>> print(f"{SciNum(12345, 789):!1r}")
(12.3 ± 0.8)e+03

In this example ``!1`` indicates the number will be formatted so that
Expand Down
4 changes: 2 additions & 2 deletions docs/source/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ specified in the extra translations dictionary:
>>> sform = Formatter(
... exp_mode="scientific",
... exp_format="prefix",
... extra_si_prefixes={-2: 'zzz'},
... extra_si_prefixes={-2: "zzz"},
... add_c_prefix=True,
... )
>>> print(sform(0.012))
Expand All @@ -327,7 +327,7 @@ used.
... exp_format="prefix",
... add_c_prefix=True,
... )
>>> with GlobalDefaultsContext(extra_si_prefixes={1: 'zzz'}):
>>> with GlobalDefaultsContext(extra_si_prefixes={1: "zzz"}):
... print(sform(12.4))
1.24e+01

Expand Down
12 changes: 2 additions & 10 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,7 @@ These conversions can be accessed via the
>>> print(f"{formatted_str} -> {formatted_str.as_ascii()}")
(12.345_678 ± 0.000_255)% -> (12.345_678 +/- 0.000_255)%

>>> sform = Formatter(
... exp_mode="engineering",
... exp_format="prefix",
... ndigits=4
... )
>>> sform = Formatter(exp_mode="engineering", exp_format="prefix", ndigits=4)
>>> formatted_str = sform(314.159e-6, 2.71828e-6)
>>> print(f"{formatted_str} -> {formatted_str.as_latex()}")
(314.159 ± 2.718) μ -> $(314.159\:\pm\:2.718)\:\text{\textmu}$
Expand All @@ -289,11 +285,7 @@ These conversions can be accessed via the
The LaTeX enclosing ``"$"`` math environment symbols can be optionally
stripped:

>>> sform = Formatter(
... exp_mode="engineering",
... exp_format="prefix",
... ndigits=4
... )
>>> sform = Formatter(exp_mode="engineering", exp_format="prefix", ndigits=4)
>>> formatted_str = sform(314.159e-6, 2.71828e-6)
>>> print(f"{formatted_str} -> {formatted_str.as_latex(strip_math_mode=False)}")
(314.159 ± 2.718) μ -> $(314.159\:\pm\:2.718)\:\text{\textmu}$
Expand Down

0 comments on commit a52f125

Please sign in to comment.