From 908be3168a1fd978c712f83edabd59bfb8da79e2 Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 31 Jan 2024 14:04:52 -0700 Subject: [PATCH 1/2] changelog --- CHANGELOG.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b73cf973..3214f00c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,6 +8,13 @@ This project adheres to `Semantic Versioning `_. Unreleased ---------- +* There are no unreleased changes. + +---- + +0.33.0 (2024-01-31) +------------------- + Added ^^^^^ From a059e3ad79d0608d0f01f0c651f1afa64b1a04cd Mon Sep 17 00:00:00 2001 From: Justin Date: Wed, 31 Jan 2024 14:05:51 -0700 Subject: [PATCH 2/2] blackdoc --- docs/source/examples.rst | 16 +++++----------- docs/source/fsml.rst | 4 ++-- docs/source/options.rst | 4 ++-- docs/source/usage.rst | 12 ++---------- 4 files changed, 11 insertions(+), 25 deletions(-) diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 66f3117f..3b3f61a5 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -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 @@ -115,7 +113,7 @@ 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 @@ -123,7 +121,7 @@ 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 @@ -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'] diff --git a/docs/source/fsml.rst b/docs/source/fsml.rst index c518cd58..33dab6a7 100644 --- a/docs/source/fsml.rst +++ b/docs/source/fsml.rst @@ -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 diff --git a/docs/source/options.rst b/docs/source/options.rst index 4267e6bf..31bf3dd3 100644 --- a/docs/source/options.rst +++ b/docs/source/options.rst @@ -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)) @@ -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 diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 3f39f050..9595edb2 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -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}$ @@ -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}$