sciform 0.28.2__tar.gz → 0.29.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.
- {sciform-0.28.2 → sciform-0.29.0}/CHANGELOG.rst +107 -3
- {sciform-0.28.2 → sciform-0.29.0}/PKG-INFO +2 -2
- {sciform-0.28.2 → sciform-0.29.0}/README.rst +1 -1
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/examples.rst +1 -1
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/fsml.rst +4 -4
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/options.rst +18 -4
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/usage.rst +1 -1
- {sciform-0.28.2 → sciform-0.29.0}/examples/fit_plot_with_sciform.py +4 -3
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/format_options.py +2 -2
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/formatting.py +4 -1
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform.egg-info/PKG-INFO +2 -2
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_val_unc_formatter.py +41 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_val_unc_fsml.py +4 -4
- {sciform-0.28.2 → sciform-0.29.0}/.flake8 +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/.github/workflows/python-package.yml +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/.github/workflows/python-publish.yml +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/.gitignore +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/.readthedocs.yaml +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/LICENSE +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/Makefile +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/make.bat +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/requirements.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/_static/css/custom.css +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/api.rst +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/conf.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/exp replacement.rst +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/index.rst +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/docs/source/project.rst +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/data/fit_data.json +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/fit_plot_no_sciform.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/outputs/fit_plot_no_sciform.png +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/outputs/fit_plot_no_sciform_table.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/outputs/fit_plot_with_sciform.png +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/outputs/fit_plot_with_sciform_table.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/examples/requirements.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/pyproject.toml +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/requirements.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/setup.cfg +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/__init__.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/format_utils.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/formatter.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/fsml.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/grouping.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/modes.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/prefix.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform/scinum.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform.egg-info/SOURCES.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform.egg-info/dependency_links.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/src/sciform.egg-info/top_level.txt +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_config.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_float_formatter.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_float_fsml.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_invalid_options.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_print.py +0 -0
- {sciform-0.28.2 → sciform-0.29.0}/tests/test_sci_num_and_sci_num_unc.py +0 -0
@@ -1,7 +1,47 @@
|
|
1
|
+
This project adheres to `Semantic Versioning <https://semver.org/>`_.
|
2
|
+
|
3
|
+
----
|
4
|
+
|
1
5
|
Unreleased
|
2
6
|
----------
|
3
7
|
|
4
|
-
*
|
8
|
+
* There are no unreleased changes
|
9
|
+
|
10
|
+
----
|
11
|
+
|
12
|
+
0.29.0 (2023-09-05)
|
13
|
+
-------------------
|
14
|
+
|
15
|
+
Changed
|
16
|
+
^^^^^^^
|
17
|
+
|
18
|
+
* Previously, when using ``bracket_unc=True`` with any exponent string
|
19
|
+
(such as ``e-06``, ``μ`` or ``ppm``), the value and uncertainty were
|
20
|
+
always wrapped in parentheses, e.g. ``(1.03(25))e-06``,
|
21
|
+
``(1.03(25)) μ`` or ``(1.03(25)) ppm``.
|
22
|
+
Now, when using ``bracket_unc=True`` with prefix or parts-per exponent
|
23
|
+
format modes, if the exponent is replaced with an alphabetic
|
24
|
+
replacement, then the value and uncertainty are no longer wrapped in
|
25
|
+
parentheses, e.g. ``1.03(25) μ`` and ``1.03(25) ppm``.
|
26
|
+
This is consistent with
|
27
|
+
`BIPM Guide Section 7.2.2 <https://www.bipm.org/documents/20126/2071204/JCGM_100_2008_E.pdf/cb0ef43f-baa5-11cf-3f85-4dcd86f77bd6#page=37>`_.
|
28
|
+
Specifically, any time ``bracket_unc=False`` the value and uncertainty
|
29
|
+
are always wrapped in parentheses, and any time notation like ``e+02``
|
30
|
+
or ``b+02`` is used to indicate the exponent then the value and
|
31
|
+
uncertainty are always wrapped in parentheses.
|
32
|
+
|
33
|
+
Fixed
|
34
|
+
^^^^^
|
35
|
+
|
36
|
+
* Correct ``fit_plot_with_sciform.py`` example script to use new
|
37
|
+
``exp_format=ExpFormat.PREFIX`` instead of old ``prefix_exp=True``.
|
38
|
+
|
39
|
+
Improved
|
40
|
+
^^^^^^^^
|
41
|
+
|
42
|
+
* Documentation improvements including typos and neatening up changelog.
|
43
|
+
|
44
|
+
----
|
5
45
|
|
6
46
|
0.28.2 (2023-08-31)
|
7
47
|
-------------------
|
@@ -30,6 +70,8 @@ Fixed
|
|
30
70
|
In the future a flag may be added to select "parts-per" formatting
|
31
71
|
using the format specification mini-language.
|
32
72
|
|
73
|
+
----
|
74
|
+
|
33
75
|
0.28.1 (2023-08-28)
|
34
76
|
-------------------
|
35
77
|
|
@@ -44,6 +86,8 @@ Fixed
|
|
44
86
|
* Test against Python 3.11.
|
45
87
|
* List supported Python versions in ``pyproject.toml`` classifiers.
|
46
88
|
|
89
|
+
----
|
90
|
+
|
47
91
|
0.28.0 (2023-08-27)
|
48
92
|
-------------------
|
49
93
|
|
@@ -51,7 +95,7 @@ Fixed
|
|
51
95
|
with an ``exp_format`` option which can be configured to
|
52
96
|
``ExpFormat.STANDARD``, ``ExpFormat.PREFIX`` or
|
53
97
|
``ExpFormat.PARTS_PER``.
|
54
|
-
* Previously
|
98
|
+
* Previously formatting a non-finite number in percent mode would always
|
55
99
|
display a ``'%'`` symbol, e.g. ``'(nan)%'``.
|
56
100
|
Now the brackets and ``'%'`` symbol will be omitted unless
|
57
101
|
``nan_inf_exp=True``.
|
@@ -70,11 +114,15 @@ Fixed
|
|
70
114
|
Rounding and truncating are not properly implemented in binary mode
|
71
115
|
yet.
|
72
116
|
|
117
|
+
----
|
118
|
+
|
73
119
|
0.27.4 (2023-08-25)
|
74
120
|
-------------------
|
75
121
|
|
76
122
|
* Setup github action to automatically build and publish on release.
|
77
123
|
|
124
|
+
----
|
125
|
+
|
78
126
|
0.27.3 (2023-08-23)
|
79
127
|
-------------------
|
80
128
|
|
@@ -84,12 +132,16 @@ Fixed
|
|
84
132
|
``setuptools_scm``.
|
85
133
|
* Stopped encouraging ``import FormatOptions as Fo``.
|
86
134
|
|
135
|
+
----
|
136
|
+
|
87
137
|
0.27.2 (2023-08-20)
|
88
138
|
-------------------
|
89
139
|
|
90
140
|
* Add ``__repr__()`` for ``FormatOptions`` and
|
91
141
|
``RenderedFormatOptions``.
|
92
142
|
|
143
|
+
----
|
144
|
+
|
93
145
|
0.27.1 (2023-08-18)
|
94
146
|
-------------------
|
95
147
|
|
@@ -98,6 +150,8 @@ Fixed
|
|
98
150
|
outputs which appear in the documentation.
|
99
151
|
* Remove extra ``readthedocs.yaml`` file.
|
100
152
|
|
153
|
+
----
|
154
|
+
|
101
155
|
0.27.0 (2023-08-18)
|
102
156
|
-------------------
|
103
157
|
|
@@ -106,6 +160,8 @@ Fixed
|
|
106
160
|
``ndigits=AutoRound``. Furthermore, ``AutoRound`` could likely be
|
107
161
|
confused as being an option for ``round_mode``, which it is not.
|
108
162
|
|
163
|
+
----
|
164
|
+
|
109
165
|
0.26.2 (2023-08-18)
|
110
166
|
-------------------
|
111
167
|
|
@@ -115,11 +171,15 @@ Fixed
|
|
115
171
|
The bug is fixed by re-checking the options combinations after merging
|
116
172
|
in the global defaults but before formatting.
|
117
173
|
|
174
|
+
----
|
175
|
+
|
118
176
|
0.26.1 (2023-08-18)
|
119
177
|
-------------------
|
120
178
|
|
121
179
|
* Add unit tests, increase test coverage.
|
122
180
|
|
181
|
+
----
|
182
|
+
|
123
183
|
0.26.0 (2023-08-15)
|
124
184
|
-------------------
|
125
185
|
|
@@ -147,16 +207,22 @@ Fixed
|
|
147
207
|
* Better explanations of ``AutoExpVal`` and ``AutoRound`` behavior.
|
148
208
|
* More accurate descriptions of some invalid options combinations.
|
149
209
|
|
210
|
+
----
|
211
|
+
|
150
212
|
0.25.2 (2023-08-11)
|
151
213
|
-------------------
|
152
214
|
|
153
215
|
* Update roadmap
|
154
216
|
|
217
|
+
----
|
218
|
+
|
155
219
|
0.25.1 (2023-08-10)
|
156
220
|
-------------------
|
157
221
|
|
158
222
|
* Refactor ``get_pdg_round_digit()`` into a dedicated function.
|
159
223
|
|
224
|
+
----
|
225
|
+
|
160
226
|
0.25.0 (2023-08-02)
|
161
227
|
-------------------
|
162
228
|
|
@@ -166,6 +232,8 @@ Fixed
|
|
166
232
|
``FormatOptions`` instances using the ``merge()`` method.
|
167
233
|
* Minor documentation improvements.
|
168
234
|
|
235
|
+
----
|
236
|
+
|
169
237
|
0.24.0 (2023-07-30)
|
170
238
|
-------------------
|
171
239
|
|
@@ -173,6 +241,8 @@ Fixed
|
|
173
241
|
``ExpMode.PERCENT``.
|
174
242
|
There is no longer a ``percent`` keyword argument.
|
175
243
|
|
244
|
+
----
|
245
|
+
|
176
246
|
0.23.0 (2023-07-29)
|
177
247
|
-------------------
|
178
248
|
|
@@ -188,17 +258,23 @@ Fixed
|
|
188
258
|
``SciNumUnc`` objects.
|
189
259
|
* Change ``pyproject.toml`` description
|
190
260
|
|
261
|
+
----
|
262
|
+
|
191
263
|
0.22.2 (2023-07-27)
|
192
264
|
-------------------
|
193
265
|
|
194
266
|
* Add ``.readthedocs.yaml`` and update documentation
|
195
267
|
``requirements.txt`` for reproducible documentation builds.
|
196
268
|
|
269
|
+
----
|
270
|
+
|
197
271
|
0.22.1 (2023-07-27)
|
198
272
|
-------------------
|
199
273
|
|
200
274
|
* Fix a date typo in the changelog for the entry for version ``0.22.0``.
|
201
275
|
|
276
|
+
----
|
277
|
+
|
202
278
|
0.22.0 (2023-07-27)
|
203
279
|
-------------------
|
204
280
|
|
@@ -227,6 +303,8 @@ Fixed
|
|
227
303
|
was corrected.
|
228
304
|
* Add "under construction" message to README.
|
229
305
|
|
306
|
+
----
|
307
|
+
|
230
308
|
0.21.0 (2023-07-22)
|
231
309
|
-------------------
|
232
310
|
|
@@ -235,7 +313,9 @@ Fixed
|
|
235
313
|
``float`` and more reliable rounding behavior.
|
236
314
|
* Update particle data group uncertainty rounding unit tests since edge
|
237
315
|
cases are now handled property as a result of adopting ``Decimal``.
|
238
|
-
* Minor cleanup of ``sfloat``
|
316
|
+
* Minor cleanup of ``sfloat`` arithmetic functions.
|
317
|
+
|
318
|
+
----
|
239
319
|
|
240
320
|
0.20.1 (2023-06-24)
|
241
321
|
-------------------
|
@@ -248,6 +328,8 @@ Fixed
|
|
248
328
|
``format_float()`` and ``format_val_unc()`` directly instead of
|
249
329
|
creating a ``Formatter`` object first.
|
250
330
|
|
331
|
+
----
|
332
|
+
|
251
333
|
0.20.0 (2023-06-22)
|
252
334
|
-------------------
|
253
335
|
|
@@ -263,6 +345,8 @@ Fixed
|
|
263
345
|
mode: e.g. ``\text{Mi}``.
|
264
346
|
* Link to test cases on examples page.
|
265
347
|
|
348
|
+
----
|
349
|
+
|
266
350
|
0.19.0 (2023-06-22)
|
267
351
|
-------------------
|
268
352
|
|
@@ -270,11 +354,15 @@ Fixed
|
|
270
354
|
doc testing, and flake8 scans during github pull requests.
|
271
355
|
* Minor flake8 cleanup
|
272
356
|
|
357
|
+
----
|
358
|
+
|
273
359
|
0.18.1 (2023-06-21)
|
274
360
|
-------------------
|
275
361
|
|
276
362
|
* Documentation improvements
|
277
363
|
|
364
|
+
----
|
365
|
+
|
278
366
|
0.18.0 (2023-06-19)
|
279
367
|
-------------------
|
280
368
|
|
@@ -288,6 +376,8 @@ Fixed
|
|
288
376
|
* Expose ``AutoPrec`` and ``AutoExp`` sentinel classes so that users can
|
289
377
|
explicitly indicate automatic precision and exponent selection.
|
290
378
|
|
379
|
+
----
|
380
|
+
|
291
381
|
0.17.1 (2023-06-19)
|
292
382
|
-------------------
|
293
383
|
|
@@ -295,6 +385,8 @@ Fixed
|
|
295
385
|
including more verbose clarifying comments.
|
296
386
|
* Minor documentation cleanup
|
297
387
|
|
388
|
+
----
|
389
|
+
|
298
390
|
0.17.0 (2023-06-19)
|
299
391
|
-------------------
|
300
392
|
|
@@ -303,6 +395,8 @@ Fixed
|
|
303
395
|
* Fix typos in binary IEC prefixes table.
|
304
396
|
* Fix some cross links in documentation.
|
305
397
|
|
398
|
+
----
|
399
|
+
|
306
400
|
0.16.0 (2023-06-18)
|
307
401
|
-------------------
|
308
402
|
|
@@ -310,16 +404,22 @@ Fixed
|
|
310
404
|
* Refactor exponent string conversion.
|
311
405
|
* Percent mode for non-finite numbers.
|
312
406
|
|
407
|
+
----
|
408
|
+
|
313
409
|
0.15.2 (2023-06-18)
|
314
410
|
-------------------
|
315
411
|
|
316
412
|
* Fix a bug involving space filling and separators.
|
317
413
|
|
414
|
+
----
|
415
|
+
|
318
416
|
0.15.1 (2023-06-17)
|
319
417
|
-------------------
|
320
418
|
|
321
419
|
* Changelog formatting typo.
|
322
420
|
|
421
|
+
----
|
422
|
+
|
323
423
|
0.15.0 (2023-06-17)
|
324
424
|
-------------------
|
325
425
|
|
@@ -327,8 +427,12 @@ Fixed
|
|
327
427
|
* Forbid percent mode unless using fixed point exponent mode.
|
328
428
|
* Add PyPi link to readme.
|
329
429
|
|
430
|
+
----
|
431
|
+
|
330
432
|
0.14.0 (2023-06-17)
|
331
433
|
-------------------
|
332
434
|
|
333
435
|
* Add Changelog.
|
334
436
|
* Add ``unicode_pm`` option with documentation and tests.
|
437
|
+
|
438
|
+
----
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sciform
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.29.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
|
@@ -77,7 +77,7 @@ continue to change until version ``1.0.0`` is released.
|
|
77
77
|
API changes will be announced after new releases in the
|
78
78
|
`changelog <https://sciform.readthedocs.io/en/stable/project.html#changelog>`_.
|
79
79
|
If you have an idea or opinion about how ``sciform`` should be designed,
|
80
|
-
now is a great to
|
80
|
+
now is a great time to
|
81
81
|
`post a discussion topic <https://github.com/jagerber48/sciform/discussions>`_
|
82
82
|
about it!
|
83
83
|
|
@@ -60,7 +60,7 @@ continue to change until version ``1.0.0`` is released.
|
|
60
60
|
API changes will be announced after new releases in the
|
61
61
|
`changelog <https://sciform.readthedocs.io/en/stable/project.html#changelog>`_.
|
62
62
|
If you have an idea or opinion about how ``sciform`` should be designed,
|
63
|
-
now is a great to
|
63
|
+
now is a great time to
|
64
64
|
`post a discussion topic <https://github.com/jagerber48/sciform/discussions>`_
|
65
65
|
about it!
|
66
66
|
|
@@ -248,5 +248,5 @@ We can see the plot and table are immediately much more legible.
|
|
248
248
|
Less characters are needed to communicate the data in both
|
249
249
|
visualizations.
|
250
250
|
The relative scaling of parameters between datasets and the relative
|
251
|
-
|
251
|
+
scaling between the value and uncertainty for each entry are
|
252
252
|
immediately clear.
|
@@ -14,7 +14,7 @@ configured using :class:`FormatOptions` instances, users can construct
|
|
14
14
|
:class:`SciNum` or :class:`SciNumUnc` instances and format them using
|
15
15
|
string formatting with format specification strings from the
|
16
16
|
:mod:`sciform` format specification mini-language (FSML).
|
17
|
-
This is
|
17
|
+
This is analogous to how python :class:`int`, :class:`float`, and
|
18
18
|
:class:`Decimal` instances can be formatted using the built-in
|
19
19
|
`format specification mini-language <https://docs.python.org/3/library/string.html#format-specification-mini-language>`_.
|
20
20
|
The :mod:`sciform` format specification mini-language is given by::
|
@@ -158,9 +158,9 @@ for scientific formatting.
|
|
158
158
|
* Inclusion of a hanging decimal point, e.g. ``123.``.
|
159
159
|
:mod:`sciform` never includes a hanging decimal point.
|
160
160
|
|
161
|
-
* For :class:`float` instances, Python formatting uses a default
|
162
|
-
of 6 for ``f``, ``F``, ``%``, ``e``, and ``E`` modes if no
|
163
|
-
precision (``ndigits``) is supplied.
|
161
|
+
* For :class:`float` instances, Python formatting uses a default
|
162
|
+
precision of 6 for ``f``, ``F``, ``%``, ``e``, and ``E`` modes if no
|
163
|
+
explicit precision (``ndigits``) is supplied.
|
164
164
|
:mod:`sciform`, instead, converts :class:`float` instances into
|
165
165
|
:class:`str` and then :class:`Decimal` so that they are displayed with
|
166
166
|
as many digits as necessary to "round-trip" when no ``ndigits`` is
|
@@ -48,7 +48,7 @@ Percent
|
|
48
48
|
-------
|
49
49
|
|
50
50
|
Percent mode is similar to fixed point mode.
|
51
|
-
For percent mode, the number is
|
51
|
+
For percent mode, the number is multiplied by 100 and a ``%`` symbol is
|
52
52
|
appended to the end of the formatted string.
|
53
53
|
|
54
54
|
>>> sform = Formatter(FormatOptions(exp_mode=ExpMode.PERCENT))
|
@@ -90,7 +90,7 @@ exponent is chosen to be an integer multiple of 3.
|
|
90
90
|
In standard engineering notation, the mantissa ``m`` satisfies
|
91
91
|
``1 <= m < 1000``.
|
92
92
|
Engineering notation is compatible with the SI prefixes which are
|
93
|
-
defined for any integer
|
93
|
+
defined for any integer multiple of 3 exponent, e.g.::
|
94
94
|
|
95
95
|
369,000,00 Hz = 369e+06 Hz = 369 MHz
|
96
96
|
|
@@ -372,7 +372,7 @@ rounded to ``12.99``.
|
|
372
372
|
>>> print(sform(12345.678))
|
373
373
|
12.3457e+03
|
374
374
|
|
375
|
-
It is
|
375
|
+
It is possible for ``ndigits <= 0``:
|
376
376
|
|
377
377
|
>>> from sciform import RoundMode
|
378
378
|
>>> sform = Formatter(FormatOptions(
|
@@ -446,7 +446,7 @@ decimal separator.
|
|
446
446
|
>>> print(sform(1234567.7654321))
|
447
447
|
1 234 567,765_432_1
|
448
448
|
|
449
|
-
NIST discourages the use of ``','`` or ``'.'`` as thousands
|
449
|
+
NIST discourages the use of ``','`` or ``'.'`` as thousands separators
|
450
450
|
because they can be confused with the decimal separators depending on
|
451
451
|
the locality. See
|
452
452
|
`NIST Guide to the SI 10.5.3 <https://www.nist.gov/pml/special-publication-811/nist-guide-si-chapter-10-more-printing-and-using-symbols-and-numbers#1053>`_.
|
@@ -743,6 +743,20 @@ Or with other options:
|
|
743
743
|
>>> print(sform(123.456, 0.789))
|
744
744
|
(1.2346(79))e+02
|
745
745
|
|
746
|
+
When ``bracket_unc=True`` is used with the prefix or parts-per exponent
|
747
|
+
formats, if the exponent string is replaced, then the enclosing brackets
|
748
|
+
around the value/uncertainty pair are omitted.
|
749
|
+
This is consistent with
|
750
|
+
`BIPM Guide Section 7.2.2 <https://www.bipm.org/documents/20126/2071204/JCGM_100_2008_E.pdf/cb0ef43f-baa5-11cf-3f85-4dcd86f77bd6#page=37>`_.
|
751
|
+
|
752
|
+
>>> from sciform import ExpFormat
|
753
|
+
>>> sform = Formatter(FormatOptions(
|
754
|
+
... exp_mode=ExpMode.ENGINEERING,
|
755
|
+
... exp_format=ExpFormat.PREFIX,
|
756
|
+
... bracket_unc=True))
|
757
|
+
>>> print(sform(523.4e-3, 1.2e-3))
|
758
|
+
523.4(1.2) m
|
759
|
+
|
746
760
|
Remove Separators for Bracket Uncertainty
|
747
761
|
--------------------------------------------
|
748
762
|
|
@@ -387,7 +387,7 @@ Here I would like to highlight two specific issues.
|
|
387
387
|
In Table 2 the :sup:`87` Rb ground-state hyperfine splitting is cited
|
388
388
|
as ``6 834 682 610.904 312 6 Hz`` with 17 digits. Suppose the last
|
389
389
|
digit was a ``5`` instead of a ``6``. Python :class:`float` cannot
|
390
|
-
tell the
|
390
|
+
tell the difference:
|
391
391
|
``float(6834682610.9043126) == float(6834682610.9043125)`` returns
|
392
392
|
``True``.
|
393
393
|
|
@@ -7,7 +7,8 @@ import matplotlib.pyplot as plt
|
|
7
7
|
from scipy.optimize import curve_fit
|
8
8
|
from tabulate import tabulate
|
9
9
|
|
10
|
-
from sciform import Formatter, ExpMode, RoundMode, SignMode, FormatOptions
|
10
|
+
from sciform import (Formatter, ExpMode, RoundMode, SignMode, FormatOptions,
|
11
|
+
ExpFormat)
|
11
12
|
|
12
13
|
|
13
14
|
def get_scale_and_offset_from_offset_str(
|
@@ -54,11 +55,11 @@ def prefix_exp_ticks(ax: plt.Axes, axis: Literal['x', 'y'],
|
|
54
55
|
exp_mode = ExpMode.ENGINEERING_SHIFTED
|
55
56
|
tick_formatter = Formatter(FormatOptions(
|
56
57
|
exp_mode=exp_mode,
|
57
|
-
|
58
|
+
exp_format=ExpFormat.PREFIX))
|
58
59
|
offset_formatter = Formatter(FormatOptions(
|
59
60
|
sign_mode=SignMode.ALWAYS,
|
60
61
|
exp_mode=exp_mode,
|
61
|
-
|
62
|
+
exp_format=ExpFormat.PREFIX))
|
62
63
|
|
63
64
|
ax.ticklabel_format(axis=axis, style='sci')
|
64
65
|
|
@@ -262,7 +262,7 @@ class FormatOptions:
|
|
262
262
|
**_merge_dicts(asdict(defaults), asdict(self))
|
263
263
|
)
|
264
264
|
except ValueError as e:
|
265
|
-
raise ValueError('Invalid format options
|
265
|
+
raise ValueError('Invalid format options resulting from merging '
|
266
266
|
'with default options.') from e
|
267
267
|
|
268
268
|
return rendered_format_options
|
@@ -275,7 +275,7 @@ def validate_options(options: Union[FormatOptions, RenderedFormatOptions]):
|
|
275
275
|
if options.round_mode is RoundMode.SIG_FIG:
|
276
276
|
if isinstance(options.ndigits, int):
|
277
277
|
if options.ndigits < 1:
|
278
|
-
raise ValueError(f'
|
278
|
+
raise ValueError(f'ndigits must be >= 1 for sig fig '
|
279
279
|
f'rounding, not {options.ndigits}.')
|
280
280
|
|
281
281
|
if (options.pdg_sig_figs and options.ndigits is not None
|
@@ -318,7 +318,10 @@ def format_val_unc(val: Decimal, unc: Decimal,
|
|
318
318
|
extra_iec_prefixes=options.extra_iec_prefixes,
|
319
319
|
extra_parts_per_forms=options.extra_parts_per_forms
|
320
320
|
)
|
321
|
-
|
321
|
+
if options.bracket_unc and not re.match(r'^[eEbB][+-]\d+$', exp_str):
|
322
|
+
val_unc_exp_str = f'{val_unc_str}{exp_str}'
|
323
|
+
else:
|
324
|
+
val_unc_exp_str = f'({val_unc_str}){exp_str}'
|
322
325
|
else:
|
323
326
|
val_unc_exp_str = val_unc_str
|
324
327
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sciform
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.29.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
|
@@ -77,7 +77,7 @@ continue to change until version ``1.0.0`` is released.
|
|
77
77
|
API changes will be announced after new releases in the
|
78
78
|
`changelog <https://sciform.readthedocs.io/en/stable/project.html#changelog>`_.
|
79
79
|
If you have an idea or opinion about how ``sciform`` should be designed,
|
80
|
-
now is a great to
|
80
|
+
now is a great time to
|
81
81
|
`post a discussion topic <https://github.com/jagerber48/sciform/discussions>`_
|
82
82
|
about it!
|
83
83
|
|
@@ -41,6 +41,47 @@ class TestFormatting(unittest.TestCase):
|
|
41
41
|
|
42
42
|
self.run_val_unc_formatter_cases(cases_list)
|
43
43
|
|
44
|
+
def test_prefix(self):
|
45
|
+
cases_list = [
|
46
|
+
((123.456, 0.789), [
|
47
|
+
(FormatOptions(bracket_unc=True,
|
48
|
+
exp_mode=ExpMode.ENGINEERING,
|
49
|
+
exp_format=ExpFormat.PREFIX), '123.456(789)'),
|
50
|
+
(FormatOptions(bracket_unc=True,
|
51
|
+
exp_mode=ExpMode.ENGINEERING_SHIFTED,
|
52
|
+
exp_format=ExpFormat.PREFIX),
|
53
|
+
'0.123456(789) k'),
|
54
|
+
]),
|
55
|
+
((123456, 789), [
|
56
|
+
(FormatOptions(bracket_unc=True,
|
57
|
+
exp_mode=ExpMode.FIXEDPOINT,
|
58
|
+
exp_format=ExpFormat.PREFIX), '123456(789)'),
|
59
|
+
(FormatOptions(bracket_unc=True,
|
60
|
+
exp_mode=ExpMode.ENGINEERING,
|
61
|
+
exp_format=ExpFormat.PREFIX), '123.456(789) k'),
|
62
|
+
(FormatOptions(bracket_unc=True,
|
63
|
+
exp_mode=ExpMode.ENGINEERING_SHIFTED,
|
64
|
+
exp_format=ExpFormat.PREFIX), '0.123456(789) M')
|
65
|
+
]),
|
66
|
+
((123456e-9, 789e-9), [
|
67
|
+
(FormatOptions(bracket_unc=True,
|
68
|
+
exp_mode=ExpMode.ENGINEERING,
|
69
|
+
exp_format=ExpFormat.PARTS_PER),
|
70
|
+
'123.456(789) ppm'),
|
71
|
+
(FormatOptions(bracket_unc=True,
|
72
|
+
exp_mode=ExpMode.ENGINEERING,
|
73
|
+
exp_format=ExpFormat.PREFIX),
|
74
|
+
'123.456(789) μ'),
|
75
|
+
(FormatOptions(bracket_unc=True,
|
76
|
+
exp_mode=ExpMode.ENGINEERING_SHIFTED,
|
77
|
+
exp_format=ExpFormat.PARTS_PER,
|
78
|
+
add_ppth_form=True),
|
79
|
+
'0.123456(789) ppth')
|
80
|
+
])
|
81
|
+
]
|
82
|
+
|
83
|
+
self.run_val_unc_formatter_cases(cases_list)
|
84
|
+
|
44
85
|
def test_percent(self):
|
45
86
|
cases_list = [
|
46
87
|
((0.123_456_78, 0.000_002_55), [
|
@@ -13,12 +13,12 @@ class TestFormatting(unittest.TestCase):
|
|
13
13
|
def run_val_unc_fsml_cases(self, cases_list: ValUncFSMLCases):
|
14
14
|
for (val, unc), formats_list in cases_list:
|
15
15
|
for format_spec, expected_str in formats_list:
|
16
|
-
|
17
|
-
|
16
|
+
snum = SciNumUnc(val, unc)
|
17
|
+
snum_str = f'{snum:{format_spec}}'
|
18
18
|
with self.subTest(val=val, unc=unc, format_spec=format_spec,
|
19
19
|
expected_str=expected_str,
|
20
|
-
actual_str=
|
21
|
-
self.assertEqual(
|
20
|
+
actual_str=snum_str):
|
21
|
+
self.assertEqual(snum_str, expected_str)
|
22
22
|
|
23
23
|
def test_fixed(self):
|
24
24
|
cases_list = [
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|