sciform 0.33.0__tar.gz → 0.34.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. {sciform-0.33.0 → sciform-0.34.0}/CHANGELOG.rst +70 -2
  2. {sciform-0.33.0 → sciform-0.34.0}/PKG-INFO +13 -9
  3. {sciform-0.33.0 → sciform-0.34.0}/README.rst +12 -8
  4. sciform-0.34.0/docs/source/api.rst +49 -0
  5. {sciform-0.33.0 → sciform-0.34.0}/docs/source/examples.rst +45 -46
  6. {sciform-0.33.0 → sciform-0.34.0}/docs/source/exp replacement.rst +3 -3
  7. {sciform-0.33.0 → sciform-0.34.0}/docs/source/fsml.rst +5 -5
  8. {sciform-0.33.0 → sciform-0.34.0}/docs/source/options.rst +114 -114
  9. {sciform-0.33.0 → sciform-0.34.0}/docs/source/usage.rst +332 -143
  10. {sciform-0.33.0 → sciform-0.34.0}/examples/jupyter_output_example.ipynb +2 -2
  11. sciform-0.34.0/src/sciform/__init__.py +30 -0
  12. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/formatter.py +149 -90
  13. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/formatting.py +92 -5
  14. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/fsml.py +4 -4
  15. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/global_configuration.py +35 -28
  16. sciform-0.34.0/src/sciform/options/__init__.py +1 -0
  17. sciform-0.34.0/src/sciform/options/conversion.py +120 -0
  18. sciform-0.33.0/src/sciform/rendered_options.py → sciform-0.34.0/src/sciform/options/finalized_options.py +7 -11
  19. {sciform-0.33.0/src/sciform → sciform-0.34.0/src/sciform/options}/global_options.py +10 -10
  20. sciform-0.34.0/src/sciform/options/input_options.py +104 -0
  21. sciform-0.34.0/src/sciform/options/populated_options.py +136 -0
  22. sciform-0.34.0/src/sciform/options/validation.py +101 -0
  23. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/output_conversion.py +2 -2
  24. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/scinum.py +13 -12
  25. {sciform-0.33.0 → sciform-0.34.0}/src/sciform.egg-info/PKG-INFO +13 -9
  26. {sciform-0.33.0 → sciform-0.34.0}/src/sciform.egg-info/SOURCES.txt +9 -4
  27. {sciform-0.33.0 → sciform-0.34.0}/tests/test_config.py +16 -16
  28. sciform-0.34.0/tests/test_docstrings.py +13 -0
  29. {sciform-0.33.0 → sciform-0.34.0}/tests/test_float_formatter.py +25 -7
  30. {sciform-0.33.0 → sciform-0.34.0}/tests/test_float_fsml.py +5 -6
  31. {sciform-0.33.0 → sciform-0.34.0}/tests/test_invalid_options.py +6 -5
  32. sciform-0.34.0/tests/test_options_printout.py +125 -0
  33. {sciform-0.33.0 → sciform-0.34.0}/tests/test_output_conversion.py +8 -2
  34. {sciform-0.33.0 → sciform-0.34.0}/tests/test_separators.py +6 -6
  35. {sciform-0.33.0 → sciform-0.34.0}/tests/test_val_unc_formatter.py +11 -11
  36. {sciform-0.33.0 → sciform-0.34.0}/tests/test_val_unc_fsml.py +7 -7
  37. sciform-0.33.0/docs/source/api.rst +0 -41
  38. sciform-0.33.0/src/sciform/__init__.py +0 -22
  39. sciform-0.33.0/src/sciform/user_options.py +0 -188
  40. sciform-0.33.0/tests/test_print.py +0 -69
  41. {sciform-0.33.0 → sciform-0.34.0}/.github/workflows/python-package.yml +0 -0
  42. {sciform-0.33.0 → sciform-0.34.0}/.github/workflows/python-publish.yml +0 -0
  43. {sciform-0.33.0 → sciform-0.34.0}/.gitignore +0 -0
  44. {sciform-0.33.0 → sciform-0.34.0}/.pre-commit-config.yaml +0 -0
  45. {sciform-0.33.0 → sciform-0.34.0}/.readthedocs.yaml +0 -0
  46. {sciform-0.33.0 → sciform-0.34.0}/CODE_OF_CONDUCT.rst +0 -0
  47. {sciform-0.33.0 → sciform-0.34.0}/CONTRIBUTING.rst +0 -0
  48. {sciform-0.33.0 → sciform-0.34.0}/LICENSE +0 -0
  49. {sciform-0.33.0 → sciform-0.34.0}/docs/Makefile +0 -0
  50. {sciform-0.33.0 → sciform-0.34.0}/docs/make.bat +0 -0
  51. {sciform-0.33.0 → sciform-0.34.0}/docs/requirements.txt +0 -0
  52. {sciform-0.33.0 → sciform-0.34.0}/docs/source/_static/css/custom.css +0 -0
  53. {sciform-0.33.0 → sciform-0.34.0}/docs/source/conf.py +0 -0
  54. {sciform-0.33.0 → sciform-0.34.0}/docs/source/index.rst +0 -0
  55. {sciform-0.33.0 → sciform-0.34.0}/docs/source/project.rst +0 -0
  56. {sciform-0.33.0 → sciform-0.34.0}/examples/__init__.py +0 -0
  57. {sciform-0.33.0 → sciform-0.34.0}/examples/data/fit_data.json +0 -0
  58. {sciform-0.33.0 → sciform-0.34.0}/examples/fit_plot_no_sciform.py +0 -0
  59. {sciform-0.33.0 → sciform-0.34.0}/examples/fit_plot_with_sciform.py +0 -0
  60. {sciform-0.33.0 → sciform-0.34.0}/examples/outputs/fit_plot_no_sciform.png +0 -0
  61. {sciform-0.33.0 → sciform-0.34.0}/examples/outputs/fit_plot_no_sciform_table.txt +0 -0
  62. {sciform-0.33.0 → sciform-0.34.0}/examples/outputs/fit_plot_with_sciform.png +0 -0
  63. {sciform-0.33.0 → sciform-0.34.0}/examples/outputs/fit_plot_with_sciform_table.txt +0 -0
  64. {sciform-0.33.0 → sciform-0.34.0}/examples/outputs/jupyter_output.png +0 -0
  65. {sciform-0.33.0 → sciform-0.34.0}/pyproject.toml +0 -0
  66. {sciform-0.33.0 → sciform-0.34.0}/setup.cfg +0 -0
  67. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/format_utils.py +0 -0
  68. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/grouping.py +0 -0
  69. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/modes.py +0 -0
  70. {sciform-0.33.0 → sciform-0.34.0}/src/sciform/prefix.py +0 -0
  71. {sciform-0.33.0 → sciform-0.34.0}/src/sciform.egg-info/dependency_links.txt +0 -0
  72. {sciform-0.33.0 → sciform-0.34.0}/src/sciform.egg-info/requires.txt +0 -0
  73. {sciform-0.33.0 → sciform-0.34.0}/src/sciform.egg-info/top_level.txt +0 -0
  74. {sciform-0.33.0 → sciform-0.34.0}/tests/__init__.py +0 -0
  75. {sciform-0.33.0 → sciform-0.34.0}/tests/test_modes_strings.py +0 -0
  76. {sciform-0.33.0 → sciform-0.34.0}/tests/test_sci_num.py +0 -0
@@ -12,6 +12,76 @@ Unreleased
12
12
 
13
13
  ----
14
14
 
15
+ 0.34.0 (2024-02-04)
16
+ -------------------
17
+
18
+ Added
19
+ ^^^^^
20
+
21
+ * The ``Formatter`` now exposes the ``input_options`` and
22
+ ``populated_options`` attributes.
23
+ The ``input_options`` attribute holds an ``InputOptions`` object which
24
+ stores a record of the input options passed into the ``Formatter``.
25
+ The ``populated_options`` attribute returns a ``PopulatedOptions``
26
+ object which shows the complete set of populated options which will be
27
+ used for formatting after merging with the global options.
28
+ Note that the ``populated_options`` attribute is re-calculated each
29
+ time it is access so that it reflects the current global options.
30
+ Both the ``InputOptions`` and ``PopulatedOptions`` objects can be used
31
+ to provide string representations of the options, or provide
32
+ programmatic access to the options via either attribute access or the
33
+ ``as_dict()`` methods.
34
+ [`#110 <https://github.com/jagerber48/sciform/issues/110>`_]
35
+ * The ``PopulatedOptions`` used during formatting of a given
36
+ ``FormattedNumber`` instance are stored on that instance for future
37
+ reference.
38
+ * Added ``get_default_global_options()``.
39
+ * Now integer ``0`` can be passed into ``left_pad_char`` to get the same
40
+ behavior as string ``"0"``.
41
+ * Added tests for docstrings.
42
+
43
+ Changed
44
+ ^^^^^^^
45
+
46
+ * **[BREAKING]** Renamed functions for configuring global options:
47
+
48
+ * ``set_global_defaults()`` -> ``set_global_options()``
49
+ * ``reset_global_defaults()`` -> ``reset_global_options()``
50
+ * ``GlobalDefaultsContext()`` -> ``GlobalOptionsContext()``
51
+
52
+ * Refactored backend options handling code.
53
+ Previously, ``UserOptions`` were rendered into ``RenderedOptions``.
54
+ During rendering the global options were appropriately merged in and
55
+ some string literal options were replaced with enums for internal use.
56
+ These two classes were private.
57
+ Now there are ``InputOptions`` (which try to faithfully record user
58
+ input), ``PopulatedOptions`` (which capture the result of merging
59
+ the global options into the input options, but still using
60
+ user-friendly string representations of all options), and
61
+ ``FinalizedOptions`` (which use the internal enum representations of
62
+ certain options).
63
+ The ``InputOptions`` and ``PopulatedOptions`` are now public while the
64
+ ``FinalizedOptions`` is still private to shield the enum
65
+ representations from the users.
66
+ This sizable refactor was precipitated by the publicizing of the
67
+ options.
68
+ [`#110 <https://github.com/jagerber48/sciform/issues/110>`_]
69
+
70
+ Removed
71
+ ^^^^^^^
72
+
73
+ * **[BREAKING]** Removed ``print_global_defaults()`` in favor of
74
+ ``get_global_defaults()`` which now returns a ``PopulatedOptions``
75
+ object which can be printed by the user if desired.
76
+
77
+ Fixed
78
+ ^^^^^
79
+
80
+ * Fixed a bug where ``SciNum`` formatting resulted in ``str`` objects
81
+ instead of ``FormattedNumber`` objects.
82
+
83
+ ----
84
+
15
85
  0.33.0 (2024-01-31)
16
86
  -------------------
17
87
 
@@ -65,8 +135,6 @@ Changed
65
135
  Hopefully this can be replaced when ``ruff`` provides
66
136
  functionality for formatting ``.rst`` files.
67
137
 
68
-
69
-
70
138
  Fixed
71
139
  ^^^^^
72
140
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciform
3
- Version: 0.33.0
3
+ Version: 0.34.0
4
4
  Summary: A package for formatting numbers into scientific formatted strings.
5
5
  Author-email: Justin Gerber <justin.gerber48@gmail.com>
6
6
  Project-URL: homepage, https://github.com/jagerber48/sciform
@@ -132,18 +132,22 @@ You can view the on-going review
132
132
  Usage
133
133
  =====
134
134
 
135
+ Here we provide a few key usage examples.
136
+ For many more details see
137
+ `Usage <https://sciform.readthedocs.io/en/stable/usage.html>`_.
138
+
135
139
  ``sciform`` provides a wide variety of formatting options which can be
136
140
  controlled when constructing ``Formatter`` objects which are then used
137
141
  to format numbers into strings according to the selected options.
138
142
 
139
143
  >>> from sciform import Formatter
140
- >>> sform = Formatter(
144
+ >>> formatter = Formatter(
141
145
  ... round_mode="dec_place", ndigits=6, upper_separator=" ", lower_separator=" "
142
146
  ... )
143
- >>> print(sform(51413.14159265359))
147
+ >>> print(formatter(51413.14159265359))
144
148
  51 413.141 593
145
- >>> sform = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
146
- >>> print(sform(123456.78))
149
+ >>> formatter = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
150
+ >>> print(formatter(123456.78))
147
151
  123.5e+03
148
152
 
149
153
  Users can also format numbers by constructing ``SciNum`` objects and
@@ -162,11 +166,11 @@ to format pairs of numbers as value/uncertainty pairs.
162
166
  This can be done by passing two numbers into a ``Formatter`` call or by
163
167
  using the ``SciNum`` object.
164
168
 
165
- >>> sform = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
166
- >>> print(sform(123456.654321, 0.00345))
169
+ >>> formatter = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
170
+ >>> print(formatter(123456.654321, 0.00345))
167
171
  123 456.654 3 ± 0.003 4
168
- >>> sform = Formatter(ndigits=4, exp_mode="engineering")
169
- >>> print(sform(123456.654321, 0.00345))
172
+ >>> formatter = Formatter(ndigits=4, exp_mode="engineering")
173
+ >>> print(formatter(123456.654321, 0.00345))
170
174
  (123.456654321 ± 0.000003450)e+03
171
175
 
172
176
  >>> num = SciNum(123456.654321, 0.00345)
@@ -97,18 +97,22 @@ You can view the on-going review
97
97
  Usage
98
98
  =====
99
99
 
100
+ Here we provide a few key usage examples.
101
+ For many more details see
102
+ `Usage <https://sciform.readthedocs.io/en/stable/usage.html>`_.
103
+
100
104
  ``sciform`` provides a wide variety of formatting options which can be
101
105
  controlled when constructing ``Formatter`` objects which are then used
102
106
  to format numbers into strings according to the selected options.
103
107
 
104
108
  >>> from sciform import Formatter
105
- >>> sform = Formatter(
109
+ >>> formatter = Formatter(
106
110
  ... round_mode="dec_place", ndigits=6, upper_separator=" ", lower_separator=" "
107
111
  ... )
108
- >>> print(sform(51413.14159265359))
112
+ >>> print(formatter(51413.14159265359))
109
113
  51 413.141 593
110
- >>> sform = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
111
- >>> print(sform(123456.78))
114
+ >>> formatter = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
115
+ >>> print(formatter(123456.78))
112
116
  123.5e+03
113
117
 
114
118
  Users can also format numbers by constructing ``SciNum`` objects and
@@ -127,11 +131,11 @@ to format pairs of numbers as value/uncertainty pairs.
127
131
  This can be done by passing two numbers into a ``Formatter`` call or by
128
132
  using the ``SciNum`` object.
129
133
 
130
- >>> sform = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
131
- >>> print(sform(123456.654321, 0.00345))
134
+ >>> formatter = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
135
+ >>> print(formatter(123456.654321, 0.00345))
132
136
  123 456.654 3 ± 0.003 4
133
- >>> sform = Formatter(ndigits=4, exp_mode="engineering")
134
- >>> print(sform(123456.654321, 0.00345))
137
+ >>> formatter = Formatter(ndigits=4, exp_mode="engineering")
138
+ >>> print(formatter(123456.654321, 0.00345))
135
139
  (123.456654321 ± 0.000003450)e+03
136
140
 
137
141
  >>> num = SciNum(123456.654321, 0.00345)
@@ -0,0 +1,49 @@
1
+ API
2
+ ###
3
+
4
+ .. module:: sciform
5
+ :noindex:
6
+
7
+ Formatting
8
+ ==========
9
+
10
+ .. autoclass:: Formatter(...)
11
+ :members:
12
+
13
+ .. automethod:: __init__(...)
14
+ .. automethod:: __call__
15
+
16
+ .. autoclass:: SciNum
17
+
18
+ .. autoclass:: FormattedNumber()
19
+ :members:
20
+ :private-members:
21
+
22
+ Options
23
+ =======
24
+
25
+ .. autoclass:: InputOptions()
26
+ :members:
27
+
28
+ .. autoclass:: PopulatedOptions()
29
+ :members:
30
+
31
+ Auto Options
32
+ ============
33
+
34
+ .. autoclass:: AutoExpVal()
35
+
36
+ .. autoclass:: AutoDigits()
37
+
38
+ Global Configuration
39
+ ====================
40
+
41
+ .. autofunction:: get_default_global_options
42
+
43
+ .. autofunction:: get_global_options
44
+
45
+ .. autofunction:: set_global_options(...)
46
+
47
+ .. autofunction:: reset_global_options
48
+
49
+ .. autoclass:: GlobalOptionsContext(...)
@@ -20,66 +20,66 @@ available formatting options.
20
20
 
21
21
  >>> from sciform import Formatter
22
22
  >>> num = 12345.54321
23
- >>> sform = Formatter(exp_mode="scientific", round_mode="sig_fig", ndigits=4)
24
- >>> print(sform(num))
23
+ >>> formatter = Formatter(exp_mode="scientific", round_mode="sig_fig", ndigits=4)
24
+ >>> print(formatter(num))
25
25
  1.235e+04
26
- >>> sform = Formatter(
26
+ >>> formatter = Formatter(
27
27
  ... exp_mode="engineering",
28
28
  ... round_mode="dec_place",
29
29
  ... ndigits=10,
30
30
  ... sign_mode=" ",
31
31
  ... superscript=True,
32
32
  ... )
33
- >>> print(sform(num))
33
+ >>> print(formatter(num))
34
34
  12.3455432100×10³
35
- >>> sform = Formatter(
35
+ >>> formatter = Formatter(
36
36
  ... exp_mode="fixed_point",
37
37
  ... upper_separator=" ",
38
38
  ... decimal_separator=",",
39
39
  ... lower_separator="_",
40
40
  ... sign_mode="+",
41
41
  ... )
42
- >>> print(sform(num))
42
+ >>> print(formatter(num))
43
43
  +12 345,543_21
44
44
 
45
45
  >>> num = 0.076543
46
- >>> sform = Formatter(
46
+ >>> formatter = Formatter(
47
47
  ... exp_mode="scientific", exp_val=-3, exp_format="parts_per", add_ppth_form=True
48
48
  ... )
49
- >>> print(sform(num))
49
+ >>> print(formatter(num))
50
50
  76.543 ppth
51
- >>> sform = Formatter(
51
+ >>> formatter = Formatter(
52
52
  ... exp_mode="scientific", exp_val=-2, exp_format="prefix", add_c_prefix=True
53
53
  ... )
54
- >>> print(sform(num))
54
+ >>> print(formatter(num))
55
55
  7.6543 c
56
- >>> sform = Formatter(exp_mode="scientific", exp_val=-6, exp_format="prefix")
57
- >>> print(sform(num))
56
+ >>> formatter = Formatter(exp_mode="scientific", exp_val=-6, exp_format="prefix")
57
+ >>> print(formatter(num))
58
58
  76543 μ
59
- >>> sform = Formatter(exp_mode="percent")
60
- >>> print(sform(num))
59
+ >>> formatter = Formatter(exp_mode="percent")
60
+ >>> print(formatter(num))
61
61
  7.6543%
62
62
 
63
63
  >>> num = 3141592.7
64
64
  >>> unc = 1618
65
- >>> sform = Formatter()
66
- >>> print(sform(num, unc))
65
+ >>> formatter = Formatter()
66
+ >>> print(formatter(num, unc))
67
67
  3141593 ± 1618
68
- >>> sform = Formatter(
68
+ >>> formatter = Formatter(
69
69
  ... exp_mode="engineering",
70
70
  ... exp_format="prefix",
71
71
  ... pdg_sig_figs=True,
72
72
  ... pm_whitespace=False,
73
73
  ... )
74
- >>> print(sform(num, unc))
74
+ >>> print(formatter(num, unc))
75
75
  (3.1416±0.0016) M
76
76
 
77
77
  >>> num = 314159.27
78
78
  >>> unc = 1618
79
- >>> sform = Formatter(
79
+ >>> formatter = Formatter(
80
80
  ... exp_mode="engineering_shifted", pdg_sig_figs=True, paren_uncertainty=True
81
81
  ... )
82
- >>> print(sform(num, unc))
82
+ >>> print(formatter(num, unc))
83
83
  (0.3142(16))e+06
84
84
 
85
85
  .. _fsml_examples:
@@ -137,52 +137,51 @@ SciNum, and Global Options
137
137
  Here are a small selection of examples which demonstrate some of the
138
138
  available string formatting options.
139
139
  Note that many options are not available through the :ref:`fsml`, so
140
- these options must be selected by configuring the global default options
141
- during formatting.
142
- Here this is done using the :class:`GlobalDefaultsContext` context
143
- manager, but this could have been done using :func:`set_global_defaults`
140
+ these options must be selected by configuring the global options.
141
+ Here this is done using the :class:`GlobalOptionsContext` context
142
+ manager, but this could have been done using :func:`set_global_options`
144
143
  instead.
145
144
 
146
- >>> from sciform import SciNum, GlobalDefaultsContext
147
- >>> snum = SciNum(12345.54321)
148
- >>> print(f"{snum:!4e}")
145
+ >>> from sciform import SciNum, GlobalOptionsContext
146
+ >>> num = SciNum(12345.54321)
147
+ >>> print(f"{num:!4e}")
149
148
  1.235e+04
150
- >>> print(f"{snum: .10r}")
149
+ >>> print(f"{num: .10r}")
151
150
  12.3455432100e+03
152
- >>> with GlobalDefaultsContext(
151
+ >>> with GlobalOptionsContext(
153
152
  ... upper_separator=" ",
154
153
  ... decimal_separator=",",
155
154
  ... lower_separator="_",
156
155
  ... ):
157
- ... print(f"{snum:+}")
156
+ ... print(f"{num:+}")
158
157
  +12 345,543_21
159
158
 
160
- >>> snum = SciNum(0.076543)
161
- >>> with GlobalDefaultsContext(exp_format="parts_per", add_ppth_form=True):
162
- ... print(f"{snum:ex-3}")
159
+ >>> num = SciNum(0.076543)
160
+ >>> with GlobalOptionsContext(exp_format="parts_per", add_ppth_form=True):
161
+ ... print(f"{num:ex-3}")
163
162
  ...
164
163
  76.543 ppth
165
- >>> with GlobalDefaultsContext(exp_format="prefix", add_c_prefix=True):
166
- ... print(f"{snum:ex-2}")
164
+ >>> with GlobalOptionsContext(exp_format="prefix", add_c_prefix=True):
165
+ ... print(f"{num:ex-2}")
167
166
  ...
168
167
  7.6543 c
169
- >>> with GlobalDefaultsContext(exp_mode="scientific", exp_val=-6, exp_format="prefix"):
170
- ... print(f"{snum:ex-6}")
168
+ >>> with GlobalOptionsContext(exp_mode="scientific", exp_val=-6, exp_format="prefix"):
169
+ ... print(f"{num:ex-6}")
171
170
  ...
172
171
  76543 μ
173
- >>> print(f"{snum:%}")
172
+ >>> print(f"{num:%}")
174
173
  7.6543%
175
174
 
176
175
  >>> num_unc = SciNum(3141592.7, 1618)
177
176
  >>> print(f"{num_unc}")
178
177
  3141593 ± 1618
179
- >>> with GlobalDefaultsContext(pdg_sig_figs=True, pm_whitespace=False):
178
+ >>> with GlobalOptionsContext(pdg_sig_figs=True, pm_whitespace=False):
180
179
  ... print(f"{num_unc:rp}")
181
180
  ...
182
181
  (3.1416±0.0016) M
183
182
 
184
183
  >>> num_unc = SciNum(314159.27, 1618)
185
- >>> with GlobalDefaultsContext(pdg_sig_figs=True):
184
+ >>> with GlobalOptionsContext(pdg_sig_figs=True):
186
185
  ... print(f"{num_unc:#r()}")
187
186
  ...
188
187
  (0.3142(16))e+06
@@ -296,7 +295,7 @@ lists, arrays, etc.) of numbers.
296
295
 
297
296
  >>> from sciform import Formatter
298
297
  >>>
299
- >>> sform = Formatter(
298
+ >>> formatter = Formatter(
300
299
  ... exp_mode="engineering",
301
300
  ... exp_format="prefix",
302
301
  ... pdg_sig_figs=True,
@@ -305,11 +304,11 @@ lists, arrays, etc.) of numbers.
305
304
  >>> val_list = [1000, 2000, 3000]
306
305
  >>> err_list = [200, 400, 600]
307
306
  >>>
308
- >>> val_str_list = list(map(sform, val_list))
307
+ >>> val_str_list = list(map(formatter, val_list))
309
308
  >>> print(val_str_list)
310
309
  ['1 k', '2 k', '3 k']
311
310
  >>>
312
- >>> val_err_str_list = list(map(sform, val_list, err_list))
311
+ >>> val_err_str_list = list(map(formatter, val_list, err_list))
313
312
  >>> print(val_err_str_list)
314
313
  ['1.00(20) k', '2.0(4) k', '3.0(6) k']
315
314
 
@@ -319,16 +318,16 @@ makes this easy.
319
318
 
320
319
  >>> import numpy as np
321
320
  >>>
322
- >>> vec_sform = np.vectorize(sform)
321
+ >>> vec_formatter = np.vectorize(formatter)
323
322
  >>> arr = np.array([[1e6, 2e6, 3e6], [4e6, 5e6, 6e6], [7e6, 8e6, 9e6]])
324
323
  >>>
325
324
  >>> arr_err = np.array([[9e4, 8e4, 7e4], [6e4, 5e4, 4e4], [3e4, 2e4, 1e4]])
326
325
  >>>
327
- >>> print(vec_sform(arr))
326
+ >>> print(vec_formatter(arr))
328
327
  [['1 M' '2 M' '3 M']
329
328
  ['4 M' '5 M' '6 M']
330
329
  ['7 M' '8 M' '9 M']]
331
- >>> print(vec_sform(arr, arr_err))
330
+ >>> print(vec_formatter(arr, arr_err))
332
331
  [['1.00(9) M' '2.00(8) M' '3.00(7) M']
333
332
  ['4.00(6) M' '5.00(5) M' '6.00(4) M']
334
333
  ['7.000(30) M' '8.000(20) M' '9.000(10) M']]
@@ -152,14 +152,14 @@ Note that it is possible, using the ``extra_parts_per_forms`` option to
152
152
  override the standard mappings listed above.
153
153
 
154
154
  >>> from sciform import Formatter
155
- >>> sform = Formatter(
155
+ >>> formatter = Formatter(
156
156
  ... exp_mode="engineering",
157
157
  ... exp_format="parts_per",
158
158
  ... extra_parts_per_forms={-9: None, -12: "ppb"},
159
159
  ... )
160
- >>> print(sform(33e-9))
160
+ >>> print(formatter(33e-9))
161
161
  33e-09
162
- >>> print(sform(33e-12))
162
+ >>> print(formatter(33e-12))
163
163
  33 ppb
164
164
 
165
165
  IEC Prefixes
@@ -139,11 +139,11 @@ for scientific formatting.
139
139
  not compatible with the explicit formatting options preferred by
140
140
  :mod:`sciform`. The built-in automation features include
141
141
 
142
- * Automated selection of fixed-point or scientific notation. For
143
- :mod:`sciform`, the exponent is either explicitly indicated by the
144
- user or resolved from the global default options.
145
- * Truncation of trailing zeros without the ``#`` option. For
146
- :mod:`sciform`, trailing zeros are never truncated if they fall
142
+ * Automated selection of fixed-point or scientific notation.
143
+ For :mod:`sciform`, the exponent mode is either explicitly indicated
144
+ by the user or resolved from the global options.
145
+ * Truncation of trailing zeros without the ``#`` option.
146
+ For :mod:`sciform`, trailing zeros are never truncated if they fall
147
147
  within the user-selected decimal place or significant figures
148
148
  rounding.
149
149
  * Inclusion of a hanging decimal point, e.g. ``123.``.