sciform 0.37.0__tar.gz → 0.38.1__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.37.0 → sciform-0.38.1}/.github/workflows/python-package.yml +21 -8
- {sciform-0.37.0 → sciform-0.38.1}/.pre-commit-config.yaml +2 -2
- {sciform-0.37.0 → sciform-0.38.1}/CHANGELOG.rst +92 -2
- {sciform-0.37.0 → sciform-0.38.1}/PKG-INFO +65 -54
- {sciform-0.37.0 → sciform-0.38.1}/README.rst +50 -46
- sciform-0.38.1/coverage_feature.toml +12 -0
- sciform-0.38.1/coverage_unit.toml +13 -0
- sciform-0.38.1/docs/requirements.txt +1 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/api.rst +1 -8
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/conf.py +2 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/examples.rst +214 -12
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/fsml.rst +8 -3
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/options.rst +180 -126
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/usage.rst +23 -16
- {sciform-0.37.0 → sciform-0.38.1}/examples/fit_plot_no_sciform.py +4 -1
- {sciform-0.37.0 → sciform-0.38.1}/examples/fit_plot_with_sciform.py +4 -1
- {sciform-0.37.0 → sciform-0.38.1}/examples/jupyter_output_example.ipynb +9 -1
- sciform-0.38.1/examples/outputs/fit_plot_no_sciform.png +0 -0
- sciform-0.38.1/examples/outputs/fit_plot_with_sciform.png +0 -0
- sciform-0.38.1/examples/outputs/fit_plot_with_sciform_table.txt +9 -0
- sciform-0.38.1/examples/outputs/jupyter_output.png +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/pyproject.toml +12 -3
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/__init__.py +0 -3
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/api/formatter.py +12 -22
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/api/global_configuration.py +5 -9
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/exponents.py +2 -3
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/make_strings.py +32 -22
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/numbers.py +13 -14
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/rounding.py +17 -21
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/formatting/fsml.py +23 -8
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/formatting/number_formatting.py +68 -39
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/conversion.py +2 -1
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/finalized_options.py +2 -8
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/global_options.py +3 -5
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/input_options.py +2 -3
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/option_types.py +12 -46
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/populated_options.py +4 -6
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/validation.py +69 -59
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform.egg-info/PKG-INFO +65 -54
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform.egg-info/SOURCES.txt +2 -0
- sciform-0.38.1/src/sciform.egg-info/requires.txt +24 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_options_printout.py +8 -11
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_output_conversion.py +3 -2
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_val_formatter.py +9 -13
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_val_fsml.py +10 -10
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_val_unc_formatter.py +33 -33
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_val_unc_fsml.py +229 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/test_exponent_utils.py +51 -10
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/test_make_strings.py +1 -19
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/test_number_utils.py +132 -125
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/test_rounding_utils.py +41 -117
- sciform-0.37.0/docs/requirements.txt +0 -4
- sciform-0.37.0/examples/outputs/fit_plot_no_sciform.png +0 -0
- sciform-0.37.0/examples/outputs/fit_plot_with_sciform.png +0 -0
- sciform-0.37.0/examples/outputs/fit_plot_with_sciform_table.txt +0 -9
- sciform-0.37.0/examples/outputs/jupyter_output.png +0 -0
- sciform-0.37.0/src/sciform.egg-info/requires.txt +0 -15
- {sciform-0.37.0 → sciform-0.38.1}/.github/workflows/python-publish.yml +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/.gitignore +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/.readthedocs.yaml +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/CODE_OF_CONDUCT.rst +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/CONTRIBUTING.rst +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/LICENSE +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/Makefile +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/make.bat +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/_static/css/custom.css +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/exp replacement.rst +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/index.rst +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/docs/source/project.rst +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/examples/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/examples/data/fit_data.json +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/examples/outputs/fit_plot_no_sciform_table.txt +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/ruff.toml +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/setup.cfg +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/api/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/api/formatted_number.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/api/scinum.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/exp_translations.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/format_utils/grouping.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/formatting/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/formatting/output_conversion.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/formatting/parser.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform/options/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform.egg-info/dependency_links.txt +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/src/sciform.egg-info/top_level.txt +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_global_config.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_sci_num.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_separators.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/feature/test_string_parser.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/test_docstrings.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/__init__.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/test_exp_translations.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/format_utils/test_grouping.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/test_invalid_options.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/test_options_strings.py +0 -0
- {sciform-0.37.0 → sciform-0.38.1}/tests/unit/test_validation.py +0 -0
@@ -28,22 +28,35 @@ jobs:
|
|
28
28
|
- name: Install dependencies
|
29
29
|
run: |
|
30
30
|
python -m pip install --upgrade pip
|
31
|
-
python -m pip install -e .[
|
31
|
+
python -m pip install -e .[test]
|
32
32
|
- name: Lint/format source code and docs
|
33
33
|
run: |
|
34
34
|
ruff check .
|
35
35
|
ruff format . --check
|
36
36
|
- name: Test source code and docs
|
37
37
|
run: |
|
38
|
-
coverage run
|
39
|
-
coverage report
|
40
|
-
coverage xml
|
38
|
+
coverage run --rcfile=coverage_feature.toml
|
39
|
+
coverage report --rcfile=coverage_feature.toml
|
40
|
+
coverage xml --rcfile=coverage_feature.toml
|
41
|
+
coverage run --rcfile=coverage_unit.toml
|
42
|
+
coverage report --rcfile=coverage_unit.toml
|
43
|
+
coverage xml --rcfile=coverage_unit.toml
|
41
44
|
python -m sphinx -b doctest docs/source/ docs/build/doctest/
|
42
|
-
- name: Upload coverage reports to Codecov
|
43
|
-
uses: codecov/codecov-action@
|
45
|
+
- name: Upload feature coverage reports to Codecov
|
46
|
+
uses: codecov/codecov-action@v4
|
44
47
|
with:
|
45
48
|
token: ${{ secrets.CODECOV_TOKEN }}
|
46
|
-
flags: ${{ matrix.python-version }}
|
47
|
-
|
49
|
+
flags: ${{ matrix.python-version }}, feature
|
50
|
+
file: ./cover/feature/coverage.xml
|
51
|
+
disable_search: true
|
52
|
+
fail_ci_if_error: true
|
53
|
+
verbose: true
|
54
|
+
- name: Upload unit coverage reports to Codecov
|
55
|
+
uses: codecov/codecov-action@v4
|
56
|
+
with:
|
57
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
58
|
+
flags: ${{ matrix.python-version }}, unit
|
59
|
+
file: ./cover/unit/coverage.xml
|
60
|
+
disable_search: true
|
48
61
|
fail_ci_if_error: true
|
49
62
|
verbose: true
|
@@ -9,8 +9,98 @@ Unreleased
|
|
9
9
|
----------
|
10
10
|
|
11
11
|
* Any unreleased changes can be viewed in the latest version
|
12
|
-
|
13
|
-
|
12
|
+
documentation
|
13
|
+
`changelog <https://sciform.readthedocs.io/en/latest/project.html#changelog>`_.
|
14
|
+
|
15
|
+
0.38.1 (2024-11-02)
|
16
|
+
-------------------
|
17
|
+
|
18
|
+
Added
|
19
|
+
-----
|
20
|
+
|
21
|
+
* Documented examples demonstrating the interplay between ``sciform``
|
22
|
+
formatting the ``decimal`` module configuration.
|
23
|
+
[`#183 <https://github.com/jagerber48/sciform/issues/183>`_]
|
24
|
+
* Added an example demonstrating how users can implement a "fallback"
|
25
|
+
formatter for cases when users want different formatting behavior
|
26
|
+
applied when the uncertainty is invalid or not present.
|
27
|
+
[`#177 <https://github.com/jagerber48/sciform/issues/177>`_]
|
28
|
+
|
29
|
+
----
|
30
|
+
|
31
|
+
0.38.0 (2024-11-02)
|
32
|
+
-------------------
|
33
|
+
|
34
|
+
Added
|
35
|
+
^^^^^
|
36
|
+
|
37
|
+
* Digits-past-the-decimal formatting (``round_mode="dec_place"``) is now
|
38
|
+
supported for value/uncertainty pairs.
|
39
|
+
[`#170 <https://github.com/jagerber48/sciform/issues/170>`_]
|
40
|
+
* ``round_mode="all"`` and ``round_mode="pdg"`` options can now be
|
41
|
+
accessed in the FSML using ``"A"`` and ``"P"`` flags.
|
42
|
+
[`#192 <https://github.com/jagerber48/sciform/issues/192>`_]
|
43
|
+
* Added a dark theme option (default on) for readthedocs documentation.
|
44
|
+
* Added code coverage breakdown for unit and feature tests to codecov
|
45
|
+
CI.
|
46
|
+
|
47
|
+
Changed
|
48
|
+
^^^^^^^
|
49
|
+
|
50
|
+
* **[BREAKING]** Rounding configuration has been refactored.
|
51
|
+
Previously ``round_mode`` accepted only ``"sig_fig"`` and
|
52
|
+
``"dec_place"`` string literals, all digits rounding mode was selected
|
53
|
+
by settings ``ndigits = AutoDigits`` and PDG rounding mode was
|
54
|
+
selected by setting ``pdg_sig_figs = True``.
|
55
|
+
Now ``round_mode`` accepts ``"sig_fig"``, ``"dec_place"``, ``"pdg"``
|
56
|
+
and ``"all"`` string literals, ``ndigits`` only accepts integers, and
|
57
|
+
the ``pdg_sig_figs`` option is removed.
|
58
|
+
``round_mode`` defaults to ``"all"`` and ``ndigits`` defaults to 2.
|
59
|
+
[`#185 <https://github.com/jagerber48/sciform/issues/185>`_]
|
60
|
+
* **[BREAKING]** Previously ``exp_val`` and ``ndigits`` accepted the
|
61
|
+
enums ``AutoExpVal`` and ``AutoDigits``.
|
62
|
+
Now ``exp_val`` accepts the string literal ``"auto"`` and ``ndigits``
|
63
|
+
only accepts integers.
|
64
|
+
[`#178 <https://github.com/jagerber48/sciform/issues/178>`_,
|
65
|
+
`#185 <https://github.com/jagerber48/sciform/issues/185>`_]
|
66
|
+
* Previously, significant figure rounding with a value of ``0`` would
|
67
|
+
result in trailing zeros being added in the formatted output.
|
68
|
+
For example, ``format(SciNum(0), "!3f")`` would give ``"0.00"`` or
|
69
|
+
``format(SciNum(0, float("nan")), "!2f")`` would give ``"0.0 ± nan"``.
|
70
|
+
This is not reasonable because zero doesn't have any significant
|
71
|
+
figures, so it doesn't make sense to add more trailing zeros to
|
72
|
+
indicate additional "fake" significant figures.
|
73
|
+
Now if zero is used for significant figure rounding it always appears
|
74
|
+
directly as ``"0"``.
|
75
|
+
E.g. ``format(SciNum(0), "!3f")`` gives ``"0"`` and
|
76
|
+
``format(SciNum(0, float("nan")), "!2f")`` gives ``"0 ± nan"``.
|
77
|
+
Note that, as before, trailing zeros may still be added to a zero
|
78
|
+
value if the uncertainty is less than one, e.g.
|
79
|
+
``format(SciNum(0, 0.0012), "!2f")`` gives ``"0.0000 ± 0.0012"``.
|
80
|
+
[`#189 <https://github.com/jagerber48/sciform/issues/189>`_]
|
81
|
+
* Previously the backend ``FinalizedOptions`` class ran a validation check on
|
82
|
+
itself after initialization.
|
83
|
+
This check has been removed in favor of not complicating the validation code
|
84
|
+
to handle the above change to ``exp_val`` and ``ndigits``.
|
85
|
+
Users never directly instantiate ``FinalizedOptions`` so this will hopefully
|
86
|
+
be no problem.
|
87
|
+
``InputOptions`` continue to be validated because this is the direct result
|
88
|
+
of user input.
|
89
|
+
``PopulatedOptions`` also must continue to be validated because options
|
90
|
+
conflicts due to the combination of user input with global options can arise
|
91
|
+
at options population time.
|
92
|
+
* Update ``ruff`` version in pre-commit config.
|
93
|
+
|
94
|
+
REMOVED
|
95
|
+
^^^^^^^
|
96
|
+
* The ``pdg_sig_figs`` options has been removed.
|
97
|
+
This option is now configured by setting ``round_mode="pdg"``.
|
98
|
+
|
99
|
+
FIXED
|
100
|
+
^^^^^
|
101
|
+
|
102
|
+
* The ``ruff`` version in the github CI now matches the ``ruff`` in the local precommit
|
103
|
+
configuration.
|
14
104
|
|
15
105
|
----
|
16
106
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: sciform
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.38.1
|
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
|
@@ -21,42 +21,53 @@ Classifier: Topic :: Utilities
|
|
21
21
|
Requires-Python: >=3.8
|
22
22
|
Description-Content-Type: text/x-rst
|
23
23
|
License-File: LICENSE
|
24
|
-
Provides-Extra:
|
25
|
-
Requires-Dist:
|
26
|
-
Requires-Dist:
|
27
|
-
Requires-Dist: sphinx; extra == "
|
28
|
-
Requires-Dist: sphinx-
|
29
|
-
|
30
|
-
Requires-Dist:
|
24
|
+
Provides-Extra: docs
|
25
|
+
Requires-Dist: sphinx; extra == "docs"
|
26
|
+
Requires-Dist: sphinx-rtd-dark-mode; extra == "docs"
|
27
|
+
Requires-Dist: sphinx-rtd-theme; extra == "docs"
|
28
|
+
Requires-Dist: sphinx-toolbox; extra == "docs"
|
29
|
+
Provides-Extra: test
|
30
|
+
Requires-Dist: coverage[toml]; extra == "test"
|
31
|
+
Requires-Dist: numpy; extra == "test"
|
32
|
+
Requires-Dist: ruff==0.5.5; extra == "test"
|
33
|
+
Requires-Dist: sciform[docs]; extra == "test"
|
31
34
|
Provides-Extra: examples
|
32
35
|
Requires-Dist: numpy; extra == "examples"
|
33
36
|
Requires-Dist: scipy; extra == "examples"
|
34
37
|
Requires-Dist: matplotlib; extra == "examples"
|
35
38
|
Requires-Dist: tabulate; extra == "examples"
|
36
39
|
Requires-Dist: jupyter; extra == "examples"
|
40
|
+
Provides-Extra: all
|
41
|
+
Requires-Dist: sciform[docs]; extra == "all"
|
42
|
+
Requires-Dist: sciform[test]; extra == "all"
|
43
|
+
Requires-Dist: sciform[examples]; extra == "all"
|
37
44
|
|
38
|
-
..
|
45
|
+
.. container::
|
46
|
+
|
47
|
+
|Repo Status| |pyOpenSci| |Documentation Status| |PyPI Version| |PyPI Python| |Coverage Status| |GH Workflow Status| |Zenodo|
|
48
|
+
|
49
|
+
.. |Repo Status| image:: https://www.repostatus.org/badges/latest/wip.svg
|
39
50
|
:target: https://www.repostatus.org/#wip
|
40
51
|
:alt: Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.
|
41
|
-
.. image:: https://tinyurl.com/y22nb8up
|
52
|
+
.. |pyOpenSci| image:: https://tinyurl.com/y22nb8up
|
42
53
|
:target: https://github.com/pyOpenSci/software-review/issues/121
|
43
54
|
:alt: pyOpenSci
|
44
|
-
.. image:: https://img.shields.io/readthedocs/sciform?logo=readthedocs&link=https%3A%2F%2Fsciform.readthedocs.io%2Fen%2Fstable%2F
|
55
|
+
.. |Documentation Status| image:: https://img.shields.io/readthedocs/sciform?logo=readthedocs&link=https%3A%2F%2Fsciform.readthedocs.io%2Fen%2Fstable%2F
|
45
56
|
:target: https://sciform.readthedocs.io/en/stable/
|
46
57
|
:alt: Read the Docs
|
47
|
-
.. image:: https://img.shields.io/pypi/v/sciform?logo=pypi
|
58
|
+
.. |PyPI Version| image:: https://img.shields.io/pypi/v/sciform?logo=pypi
|
48
59
|
:target: https://pypi.org/project/sciform/
|
49
60
|
:alt: PyPI - Version
|
50
|
-
.. image:: https://img.shields.io/pypi/pyversions/sciform?logo=python
|
61
|
+
.. |PyPI Python| image:: https://img.shields.io/pypi/pyversions/sciform?logo=python
|
51
62
|
:target: https://pypi.org/project/sciform/
|
52
63
|
:alt: PyPI - Python Version
|
53
|
-
.. image:: https://img.shields.io/codecov/c/github/jagerber48/sciform?logo=codecov
|
64
|
+
.. |Coverage Status| image:: https://img.shields.io/codecov/c/github/jagerber48/sciform?logo=codecov
|
54
65
|
:target: https://codecov.io/gh/jagerber48/sciform
|
55
66
|
:alt: Codecov
|
56
|
-
.. image:: https://img.shields.io/github/actions/workflow/status/jagerber48/sciform/python-package.yml?logo=github%20actions
|
67
|
+
.. |GH Workflow Status| image:: https://img.shields.io/github/actions/workflow/status/jagerber48/sciform/python-package.yml?logo=github%20actions
|
57
68
|
:target: https://github.com/jagerber48/sciform/blob/main/.github/workflows/python-package.yml
|
58
69
|
:alt: GitHub Workflow Status
|
59
|
-
.. image:: https://zenodo.org/badge/645611310.svg
|
70
|
+
.. |Zenodo| image:: https://zenodo.org/badge/645611310.svg
|
60
71
|
:target: https://zenodo.org/doi/10.5281/zenodo.10645272
|
61
72
|
:alt: Zenodo
|
62
73
|
|
@@ -65,9 +76,9 @@ Requires-Dist: jupyter; extra == "examples"
|
|
65
76
|
sciform
|
66
77
|
#######
|
67
78
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
79
|
+
| **Repository:** `<https://github.com/jagerber48/sciform>`_
|
80
|
+
| **Documentation:** `<https://sciform.readthedocs.io/en/stable/>`_
|
81
|
+
| **PyPi:** `<https://pypi.org/project/sciform/>`_
|
71
82
|
|
72
83
|
We would greatly appreciate you taking the time to fill out the
|
73
84
|
`User Experience Survey <https://forms.gle/TkkKgywYyEMKu9U37>`_ to help
|
@@ -114,55 +125,55 @@ For many more details see
|
|
114
125
|
|
115
126
|
``sciform`` provides a wide variety of formatting options which can be
|
116
127
|
controlled when constructing ``Formatter`` objects which are then used
|
117
|
-
to format numbers into strings according to the selected options
|
118
|
-
|
119
|
-
>>> from sciform import Formatter
|
120
|
-
>>> formatter = Formatter(
|
121
|
-
... round_mode="dec_place", ndigits=6, upper_separator=" ", lower_separator=" "
|
122
|
-
... )
|
123
|
-
>>> print(formatter(51413.14159265359))
|
124
|
-
51 413.141 593
|
125
|
-
>>> formatter = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
|
126
|
-
>>> print(formatter(123456.78))
|
127
|
-
123.5e+03
|
128
|
+
to format numbers into strings according to the selected options::
|
129
|
+
|
130
|
+
>>> from sciform import Formatter
|
131
|
+
>>> formatter = Formatter(
|
132
|
+
... round_mode="dec_place", ndigits=6, upper_separator=" ", lower_separator=" "
|
133
|
+
... )
|
134
|
+
>>> print(formatter(51413.14159265359))
|
135
|
+
51 413.141 593
|
136
|
+
>>> formatter = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
|
137
|
+
>>> print(formatter(123456.78))
|
138
|
+
123.5e+03
|
128
139
|
|
129
140
|
Users can also format numbers by constructing ``SciNum`` objects and
|
130
141
|
using string formatting to format the ``SciNum`` instances according
|
131
|
-
to a custom FSML
|
142
|
+
to a custom FSML::
|
132
143
|
|
133
|
-
>>> from sciform import SciNum
|
134
|
-
>>> num = SciNum(12345)
|
135
|
-
>>> print(f"{num:!2f}")
|
136
|
-
12000
|
137
|
-
>>> print(f"{num:!2r}")
|
138
|
-
12e+03
|
144
|
+
>>> from sciform import SciNum
|
145
|
+
>>> num = SciNum(12345)
|
146
|
+
>>> print(f"{num:!2f}")
|
147
|
+
12000
|
148
|
+
>>> print(f"{num:!2r}")
|
149
|
+
12e+03
|
139
150
|
|
140
151
|
In addition to formatting individual numbers, ``sciform`` can be used
|
141
152
|
to format pairs of numbers as value/uncertainty pairs.
|
142
153
|
This can be done by passing two numbers into a ``Formatter`` call or by
|
143
|
-
using the ``SciNum`` object
|
154
|
+
using the ``SciNum`` object::
|
144
155
|
|
145
|
-
>>> formatter = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
|
146
|
-
>>> print(formatter(123456.654321, 0.00345))
|
147
|
-
123 456.654 3 ± 0.003 4
|
148
|
-
>>> formatter = Formatter(ndigits=4, exp_mode="engineering")
|
149
|
-
>>> print(formatter(123456.654321, 0.00345))
|
150
|
-
(123.456654321 ± 0.000003450)e+03
|
156
|
+
>>> formatter = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
|
157
|
+
>>> print(formatter(123456.654321, 0.00345))
|
158
|
+
123 456.654 3 ± 0.003 4
|
159
|
+
>>> formatter = Formatter(ndigits=4, exp_mode="engineering")
|
160
|
+
>>> print(formatter(123456.654321, 0.00345))
|
161
|
+
(123.456654321 ± 0.000003450)e+03
|
151
162
|
|
152
|
-
>>> num = SciNum(123456.654321, 0.00345)
|
153
|
-
>>> print(f"{num:!2f}")
|
154
|
-
123456.6543 ± 0.0034
|
155
|
-
>>> print(f"{num:!2f()}")
|
156
|
-
123456.6543(34)
|
163
|
+
>>> num = SciNum(123456.654321, 0.00345)
|
164
|
+
>>> print(f"{num:!2f}")
|
165
|
+
123456.6543 ± 0.0034
|
166
|
+
>>> print(f"{num:!2f()}")
|
167
|
+
123456.6543(34)
|
157
168
|
|
158
169
|
Note that the above examples demonstrate that ``sciform`` uses
|
159
170
|
`"round-to-even" <https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even>`_
|
160
|
-
rounding
|
171
|
+
rounding::
|
161
172
|
|
162
|
-
>>> print(f"{SciNum(865):!2}")
|
163
|
-
860
|
164
|
-
>>> print(f"{SciNum(875):!2}")
|
165
|
-
880
|
173
|
+
>>> print(f"{SciNum(865):!2}")
|
174
|
+
860
|
175
|
+
>>> print(f"{SciNum(875):!2}")
|
176
|
+
880
|
166
177
|
|
167
178
|
See `Formatting Options <https://sciform.readthedocs.io/en/stable/options.html>`_,
|
168
179
|
`Format Specification Mini-Language <https://sciform.readthedocs.io/en/stable/fsml.html>`_
|
@@ -1,25 +1,29 @@
|
|
1
|
-
..
|
1
|
+
.. container::
|
2
|
+
|
3
|
+
|Repo Status| |pyOpenSci| |Documentation Status| |PyPI Version| |PyPI Python| |Coverage Status| |GH Workflow Status| |Zenodo|
|
4
|
+
|
5
|
+
.. |Repo Status| image:: https://www.repostatus.org/badges/latest/wip.svg
|
2
6
|
:target: https://www.repostatus.org/#wip
|
3
7
|
:alt: Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.
|
4
|
-
.. image:: https://tinyurl.com/y22nb8up
|
8
|
+
.. |pyOpenSci| image:: https://tinyurl.com/y22nb8up
|
5
9
|
:target: https://github.com/pyOpenSci/software-review/issues/121
|
6
10
|
:alt: pyOpenSci
|
7
|
-
.. image:: https://img.shields.io/readthedocs/sciform?logo=readthedocs&link=https%3A%2F%2Fsciform.readthedocs.io%2Fen%2Fstable%2F
|
11
|
+
.. |Documentation Status| image:: https://img.shields.io/readthedocs/sciform?logo=readthedocs&link=https%3A%2F%2Fsciform.readthedocs.io%2Fen%2Fstable%2F
|
8
12
|
:target: https://sciform.readthedocs.io/en/stable/
|
9
13
|
:alt: Read the Docs
|
10
|
-
.. image:: https://img.shields.io/pypi/v/sciform?logo=pypi
|
14
|
+
.. |PyPI Version| image:: https://img.shields.io/pypi/v/sciform?logo=pypi
|
11
15
|
:target: https://pypi.org/project/sciform/
|
12
16
|
:alt: PyPI - Version
|
13
|
-
.. image:: https://img.shields.io/pypi/pyversions/sciform?logo=python
|
17
|
+
.. |PyPI Python| image:: https://img.shields.io/pypi/pyversions/sciform?logo=python
|
14
18
|
:target: https://pypi.org/project/sciform/
|
15
19
|
:alt: PyPI - Python Version
|
16
|
-
.. image:: https://img.shields.io/codecov/c/github/jagerber48/sciform?logo=codecov
|
20
|
+
.. |Coverage Status| image:: https://img.shields.io/codecov/c/github/jagerber48/sciform?logo=codecov
|
17
21
|
:target: https://codecov.io/gh/jagerber48/sciform
|
18
22
|
:alt: Codecov
|
19
|
-
.. image:: https://img.shields.io/github/actions/workflow/status/jagerber48/sciform/python-package.yml?logo=github%20actions
|
23
|
+
.. |GH Workflow Status| image:: https://img.shields.io/github/actions/workflow/status/jagerber48/sciform/python-package.yml?logo=github%20actions
|
20
24
|
:target: https://github.com/jagerber48/sciform/blob/main/.github/workflows/python-package.yml
|
21
25
|
:alt: GitHub Workflow Status
|
22
|
-
.. image:: https://zenodo.org/badge/645611310.svg
|
26
|
+
.. |Zenodo| image:: https://zenodo.org/badge/645611310.svg
|
23
27
|
:target: https://zenodo.org/doi/10.5281/zenodo.10645272
|
24
28
|
:alt: Zenodo
|
25
29
|
|
@@ -28,9 +32,9 @@
|
|
28
32
|
sciform
|
29
33
|
#######
|
30
34
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
| **Repository:** `<https://github.com/jagerber48/sciform>`_
|
36
|
+
| **Documentation:** `<https://sciform.readthedocs.io/en/stable/>`_
|
37
|
+
| **PyPi:** `<https://pypi.org/project/sciform/>`_
|
34
38
|
|
35
39
|
We would greatly appreciate you taking the time to fill out the
|
36
40
|
`User Experience Survey <https://forms.gle/TkkKgywYyEMKu9U37>`_ to help
|
@@ -77,55 +81,55 @@ For many more details see
|
|
77
81
|
|
78
82
|
``sciform`` provides a wide variety of formatting options which can be
|
79
83
|
controlled when constructing ``Formatter`` objects which are then used
|
80
|
-
to format numbers into strings according to the selected options
|
81
|
-
|
82
|
-
>>> from sciform import Formatter
|
83
|
-
>>> formatter = Formatter(
|
84
|
-
... round_mode="dec_place", ndigits=6, upper_separator=" ", lower_separator=" "
|
85
|
-
... )
|
86
|
-
>>> print(formatter(51413.14159265359))
|
87
|
-
51 413.141 593
|
88
|
-
>>> formatter = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
|
89
|
-
>>> print(formatter(123456.78))
|
90
|
-
123.5e+03
|
84
|
+
to format numbers into strings according to the selected options::
|
85
|
+
|
86
|
+
>>> from sciform import Formatter
|
87
|
+
>>> formatter = Formatter(
|
88
|
+
... round_mode="dec_place", ndigits=6, upper_separator=" ", lower_separator=" "
|
89
|
+
... )
|
90
|
+
>>> print(formatter(51413.14159265359))
|
91
|
+
51 413.141 593
|
92
|
+
>>> formatter = Formatter(round_mode="sig_fig", ndigits=4, exp_mode="engineering")
|
93
|
+
>>> print(formatter(123456.78))
|
94
|
+
123.5e+03
|
91
95
|
|
92
96
|
Users can also format numbers by constructing ``SciNum`` objects and
|
93
97
|
using string formatting to format the ``SciNum`` instances according
|
94
|
-
to a custom FSML
|
98
|
+
to a custom FSML::
|
95
99
|
|
96
|
-
>>> from sciform import SciNum
|
97
|
-
>>> num = SciNum(12345)
|
98
|
-
>>> print(f"{num:!2f}")
|
99
|
-
12000
|
100
|
-
>>> print(f"{num:!2r}")
|
101
|
-
12e+03
|
100
|
+
>>> from sciform import SciNum
|
101
|
+
>>> num = SciNum(12345)
|
102
|
+
>>> print(f"{num:!2f}")
|
103
|
+
12000
|
104
|
+
>>> print(f"{num:!2r}")
|
105
|
+
12e+03
|
102
106
|
|
103
107
|
In addition to formatting individual numbers, ``sciform`` can be used
|
104
108
|
to format pairs of numbers as value/uncertainty pairs.
|
105
109
|
This can be done by passing two numbers into a ``Formatter`` call or by
|
106
|
-
using the ``SciNum`` object
|
110
|
+
using the ``SciNum`` object::
|
107
111
|
|
108
|
-
>>> formatter = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
|
109
|
-
>>> print(formatter(123456.654321, 0.00345))
|
110
|
-
123 456.654 3 ± 0.003 4
|
111
|
-
>>> formatter = Formatter(ndigits=4, exp_mode="engineering")
|
112
|
-
>>> print(formatter(123456.654321, 0.00345))
|
113
|
-
(123.456654321 ± 0.000003450)e+03
|
112
|
+
>>> formatter = Formatter(ndigits=2, upper_separator=" ", lower_separator=" ")
|
113
|
+
>>> print(formatter(123456.654321, 0.00345))
|
114
|
+
123 456.654 3 ± 0.003 4
|
115
|
+
>>> formatter = Formatter(ndigits=4, exp_mode="engineering")
|
116
|
+
>>> print(formatter(123456.654321, 0.00345))
|
117
|
+
(123.456654321 ± 0.000003450)e+03
|
114
118
|
|
115
|
-
>>> num = SciNum(123456.654321, 0.00345)
|
116
|
-
>>> print(f"{num:!2f}")
|
117
|
-
123456.6543 ± 0.0034
|
118
|
-
>>> print(f"{num:!2f()}")
|
119
|
-
123456.6543(34)
|
119
|
+
>>> num = SciNum(123456.654321, 0.00345)
|
120
|
+
>>> print(f"{num:!2f}")
|
121
|
+
123456.6543 ± 0.0034
|
122
|
+
>>> print(f"{num:!2f()}")
|
123
|
+
123456.6543(34)
|
120
124
|
|
121
125
|
Note that the above examples demonstrate that ``sciform`` uses
|
122
126
|
`"round-to-even" <https://en.wikipedia.org/wiki/Rounding#Rounding_half_to_even>`_
|
123
|
-
rounding
|
127
|
+
rounding::
|
124
128
|
|
125
|
-
>>> print(f"{SciNum(865):!2}")
|
126
|
-
860
|
127
|
-
>>> print(f"{SciNum(875):!2}")
|
128
|
-
880
|
129
|
+
>>> print(f"{SciNum(865):!2}")
|
130
|
+
860
|
131
|
+
>>> print(f"{SciNum(875):!2}")
|
132
|
+
880
|
129
133
|
|
130
134
|
See `Formatting Options <https://sciform.readthedocs.io/en/stable/options.html>`_,
|
131
135
|
`Format Specification Mini-Language <https://sciform.readthedocs.io/en/stable/fsml.html>`_
|
@@ -0,0 +1,12 @@
|
|
1
|
+
[tool.coverage.run]
|
2
|
+
source = ["src/sciform/"]
|
3
|
+
command_line = "-m unittest discover tests/feature/"
|
4
|
+
dynamic_context = "test_function"
|
5
|
+
data_file = "cover/feature/.coverage"
|
6
|
+
|
7
|
+
[tool.coverage.html]
|
8
|
+
directory = "cover/feature/html/"
|
9
|
+
show_contexts = true
|
10
|
+
|
11
|
+
[tool.coverage.xml]
|
12
|
+
output = "cover/feature/coverage.xml"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
[tool.coverage.run]
|
2
|
+
#source = ["src/sciform/format_utils/"]
|
3
|
+
source = ["src/sciform/"]
|
4
|
+
command_line = "-m unittest discover tests/unit/"
|
5
|
+
dynamic_context = "test_function"
|
6
|
+
data_file = "cover/unit/.coverage"
|
7
|
+
|
8
|
+
[tool.coverage.html]
|
9
|
+
directory = "cover/unit/html/"
|
10
|
+
show_contexts = true
|
11
|
+
|
12
|
+
[tool.coverage.xml]
|
13
|
+
output = "cover/unit/coverage.xml"
|
@@ -0,0 +1 @@
|
|
1
|
+
.[docs]
|
@@ -2,7 +2,7 @@ API
|
|
2
2
|
###
|
3
3
|
|
4
4
|
.. module:: sciform
|
5
|
-
:
|
5
|
+
:no-index:
|
6
6
|
|
7
7
|
Formatting
|
8
8
|
==========
|
@@ -28,13 +28,6 @@ Options
|
|
28
28
|
.. autoclass:: PopulatedOptions()
|
29
29
|
:members:
|
30
30
|
|
31
|
-
Auto Options
|
32
|
-
============
|
33
|
-
|
34
|
-
.. autoclass:: AutoExpVal()
|
35
|
-
|
36
|
-
.. autoclass:: AutoDigits()
|
37
|
-
|
38
31
|
Global Configuration
|
39
32
|
====================
|
40
33
|
|
@@ -24,6 +24,7 @@ extensions = [
|
|
24
24
|
"sphinx.ext.doctest",
|
25
25
|
"sphinx.ext.todo",
|
26
26
|
"sphinx_toolbox.collapse",
|
27
|
+
"sphinx_rtd_dark_mode",
|
27
28
|
]
|
28
29
|
|
29
30
|
templates_path = ["_templates"]
|
@@ -39,6 +40,7 @@ html_theme_options = {
|
|
39
40
|
}
|
40
41
|
todo_include_todos = True
|
41
42
|
todo_emit_warnings = True
|
43
|
+
default_dark_mode = True
|
42
44
|
|
43
45
|
autodoc_member_order = "bysource"
|
44
46
|
|