sciform 0.37.0__tar.gz → 0.38.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 (100) hide show
  1. {sciform-0.37.0 → sciform-0.38.0}/.github/workflows/python-package.yml +21 -8
  2. {sciform-0.37.0 → sciform-0.38.0}/.pre-commit-config.yaml +2 -2
  3. {sciform-0.37.0 → sciform-0.38.0}/CHANGELOG.rst +76 -0
  4. {sciform-0.37.0 → sciform-0.38.0}/PKG-INFO +65 -54
  5. {sciform-0.37.0 → sciform-0.38.0}/README.rst +50 -46
  6. sciform-0.38.0/coverage_feature.toml +12 -0
  7. sciform-0.38.0/coverage_unit.toml +13 -0
  8. sciform-0.38.0/docs/requirements.txt +1 -0
  9. {sciform-0.37.0 → sciform-0.38.0}/docs/source/api.rst +1 -8
  10. {sciform-0.37.0 → sciform-0.38.0}/docs/source/conf.py +2 -0
  11. {sciform-0.37.0 → sciform-0.38.0}/docs/source/examples.rst +97 -12
  12. {sciform-0.37.0 → sciform-0.38.0}/docs/source/fsml.rst +8 -3
  13. {sciform-0.37.0 → sciform-0.38.0}/docs/source/options.rst +180 -126
  14. {sciform-0.37.0 → sciform-0.38.0}/docs/source/usage.rst +23 -16
  15. {sciform-0.37.0 → sciform-0.38.0}/examples/fit_plot_no_sciform.py +4 -1
  16. {sciform-0.37.0 → sciform-0.38.0}/examples/fit_plot_with_sciform.py +4 -1
  17. {sciform-0.37.0 → sciform-0.38.0}/examples/jupyter_output_example.ipynb +9 -1
  18. sciform-0.38.0/examples/outputs/fit_plot_no_sciform.png +0 -0
  19. sciform-0.38.0/examples/outputs/fit_plot_with_sciform.png +0 -0
  20. sciform-0.38.0/examples/outputs/fit_plot_with_sciform_table.txt +9 -0
  21. sciform-0.38.0/examples/outputs/jupyter_output.png +0 -0
  22. {sciform-0.37.0 → sciform-0.38.0}/pyproject.toml +12 -3
  23. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/__init__.py +0 -3
  24. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/api/formatter.py +12 -22
  25. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/api/global_configuration.py +5 -9
  26. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/exponents.py +2 -3
  27. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/make_strings.py +32 -22
  28. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/numbers.py +13 -14
  29. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/rounding.py +17 -21
  30. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/formatting/fsml.py +23 -8
  31. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/formatting/number_formatting.py +68 -39
  32. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/conversion.py +2 -1
  33. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/finalized_options.py +2 -8
  34. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/global_options.py +3 -5
  35. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/input_options.py +2 -3
  36. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/option_types.py +12 -46
  37. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/populated_options.py +4 -6
  38. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/validation.py +69 -59
  39. {sciform-0.37.0 → sciform-0.38.0}/src/sciform.egg-info/PKG-INFO +65 -54
  40. {sciform-0.37.0 → sciform-0.38.0}/src/sciform.egg-info/SOURCES.txt +2 -0
  41. sciform-0.38.0/src/sciform.egg-info/requires.txt +24 -0
  42. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_options_printout.py +8 -11
  43. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_output_conversion.py +3 -2
  44. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_val_formatter.py +9 -13
  45. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_val_fsml.py +10 -10
  46. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_val_unc_formatter.py +33 -33
  47. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_val_unc_fsml.py +229 -0
  48. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/test_exponent_utils.py +51 -10
  49. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/test_make_strings.py +1 -19
  50. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/test_number_utils.py +132 -125
  51. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/test_rounding_utils.py +41 -117
  52. sciform-0.37.0/docs/requirements.txt +0 -4
  53. sciform-0.37.0/examples/outputs/fit_plot_no_sciform.png +0 -0
  54. sciform-0.37.0/examples/outputs/fit_plot_with_sciform.png +0 -0
  55. sciform-0.37.0/examples/outputs/fit_plot_with_sciform_table.txt +0 -9
  56. sciform-0.37.0/examples/outputs/jupyter_output.png +0 -0
  57. sciform-0.37.0/src/sciform.egg-info/requires.txt +0 -15
  58. {sciform-0.37.0 → sciform-0.38.0}/.github/workflows/python-publish.yml +0 -0
  59. {sciform-0.37.0 → sciform-0.38.0}/.gitignore +0 -0
  60. {sciform-0.37.0 → sciform-0.38.0}/.readthedocs.yaml +0 -0
  61. {sciform-0.37.0 → sciform-0.38.0}/CODE_OF_CONDUCT.rst +0 -0
  62. {sciform-0.37.0 → sciform-0.38.0}/CONTRIBUTING.rst +0 -0
  63. {sciform-0.37.0 → sciform-0.38.0}/LICENSE +0 -0
  64. {sciform-0.37.0 → sciform-0.38.0}/docs/Makefile +0 -0
  65. {sciform-0.37.0 → sciform-0.38.0}/docs/make.bat +0 -0
  66. {sciform-0.37.0 → sciform-0.38.0}/docs/source/_static/css/custom.css +0 -0
  67. {sciform-0.37.0 → sciform-0.38.0}/docs/source/exp replacement.rst +0 -0
  68. {sciform-0.37.0 → sciform-0.38.0}/docs/source/index.rst +0 -0
  69. {sciform-0.37.0 → sciform-0.38.0}/docs/source/project.rst +0 -0
  70. {sciform-0.37.0 → sciform-0.38.0}/examples/__init__.py +0 -0
  71. {sciform-0.37.0 → sciform-0.38.0}/examples/data/fit_data.json +0 -0
  72. {sciform-0.37.0 → sciform-0.38.0}/examples/outputs/fit_plot_no_sciform_table.txt +0 -0
  73. {sciform-0.37.0 → sciform-0.38.0}/ruff.toml +0 -0
  74. {sciform-0.37.0 → sciform-0.38.0}/setup.cfg +0 -0
  75. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/api/__init__.py +0 -0
  76. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/api/formatted_number.py +0 -0
  77. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/api/scinum.py +0 -0
  78. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/__init__.py +0 -0
  79. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/exp_translations.py +0 -0
  80. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/format_utils/grouping.py +0 -0
  81. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/formatting/__init__.py +0 -0
  82. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/formatting/output_conversion.py +0 -0
  83. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/formatting/parser.py +0 -0
  84. {sciform-0.37.0 → sciform-0.38.0}/src/sciform/options/__init__.py +0 -0
  85. {sciform-0.37.0 → sciform-0.38.0}/src/sciform.egg-info/dependency_links.txt +0 -0
  86. {sciform-0.37.0 → sciform-0.38.0}/src/sciform.egg-info/top_level.txt +0 -0
  87. {sciform-0.37.0 → sciform-0.38.0}/tests/__init__.py +0 -0
  88. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/__init__.py +0 -0
  89. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_global_config.py +0 -0
  90. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_sci_num.py +0 -0
  91. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_separators.py +0 -0
  92. {sciform-0.37.0 → sciform-0.38.0}/tests/feature/test_string_parser.py +0 -0
  93. {sciform-0.37.0 → sciform-0.38.0}/tests/test_docstrings.py +0 -0
  94. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/__init__.py +0 -0
  95. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/__init__.py +0 -0
  96. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/test_exp_translations.py +0 -0
  97. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/format_utils/test_grouping.py +0 -0
  98. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/test_invalid_options.py +0 -0
  99. {sciform-0.37.0 → sciform-0.38.0}/tests/unit/test_options_strings.py +0 -0
  100. {sciform-0.37.0 → sciform-0.38.0}/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 .[dev]
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 -m unittest
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@v3
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
- files: coverage.xml
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
@@ -1,10 +1,10 @@
1
1
  repos:
2
2
  - repo: https://github.com/astral-sh/ruff-pre-commit
3
3
  # Ruff version.
4
- rev: v0.1.9
4
+ rev: v0.5.5
5
5
  hooks:
6
6
  # Run the linter.
7
7
  - id: ruff
8
+ args: [--fix]
8
9
  # Run the formatter.
9
10
  - id: ruff-format
10
- args: [--check]
@@ -14,6 +14,82 @@ Unreleased
14
14
 
15
15
  ----
16
16
 
17
+ 0.38.0 (2024-11-02)
18
+ -------------------
19
+
20
+ Added
21
+ ^^^^^
22
+
23
+ * Digits-past-the-decimal formatting (``round_mode="dec_place"``) is now
24
+ supported for value/uncertainty pairs.
25
+ [`#170 <https://github.com/jagerber48/sciform/issues/170>`_]
26
+ * ``round_mode="all"`` and ``round_mode="pdg"`` options can now be
27
+ accessed in the FSML using ``"A"`` and ``"P"`` flags.
28
+ [`#192 <https://github.com/jagerber48/sciform/issues/192>`_]
29
+ * Added a dark theme option (default on) for readthedocs documentation.
30
+ * Added code coverage breakdown for unit and feature tests to codecov
31
+ CI.
32
+
33
+ Changed
34
+ ^^^^^^^
35
+
36
+ * **[BREAKING]** Rounding configuration has been refactored.
37
+ Previously ``round_mode`` accepted only ``"sig_fig"`` and
38
+ ``"dec_place"`` string literals, all digits rounding mode was selected
39
+ by settings ``ndigits = AutoDigits`` and PDG rounding mode was
40
+ selected by setting ``pdg_sig_figs = True``.
41
+ Now ``round_mode`` accepts ``"sig_fig"``, ``"dec_place"``, ``"pdg"``
42
+ and ``"all"`` string literals, ``ndigits`` only accepts integers, and
43
+ the ``pdg_sig_figs`` option is removed.
44
+ ``round_mode`` defaults to ``"all"`` and ``ndigits`` defaults to 2.
45
+ [`#185 <https://github.com/jagerber48/sciform/issues/185>`_]
46
+ * **[BREAKING]** Previously ``exp_val`` and ``ndigits`` accepted the
47
+ enums ``AutoExpVal`` and ``AutoDigits``.
48
+ Now ``exp_val`` accepts the string literal ``"auto"`` and ``ndigits``
49
+ only accepts integers.
50
+ [`#178 <https://github.com/jagerber48/sciform/issues/178>`_,
51
+ `#185 <https://github.com/jagerber48/sciform/issues/185>`_]
52
+ * Previously, significant figure rounding with a value of ``0`` would
53
+ result in trailing zeros being added in the formatted output.
54
+ For example, ``format(SciNum(0), "!3f")`` would give ``"0.00"`` or
55
+ ``format(SciNum(0, float("nan")), "!2f")`` would give ``"0.0 ± nan"``.
56
+ This is not reasonable because zero doesn't have any significant
57
+ figures, so it doesn't make sense to add more trailing zeros to
58
+ indicate additional "fake" significant figures.
59
+ Now if zero is used for significant figure rounding it always appears
60
+ directly as ``"0"``.
61
+ E.g. ``format(SciNum(0), "!3f")`` gives ``"0"`` and
62
+ ``format(SciNum(0, float("nan")), "!2f")`` gives ``"0 ± nan"``.
63
+ Note that, as before, trailing zeros may still be added to a zero
64
+ value if the uncertainty is less than one, e.g.
65
+ ``format(SciNum(0, 0.0012), "!2f")`` gives ``"0.0000 ± 0.0012"``.
66
+ [`#189 <https://github.com/jagerber48/sciform/issues/189>`_]
67
+ * Previously the backend ``FinalizedOptions`` class ran a validation check on
68
+ itself after initialization.
69
+ This check has been removed in favor of not complicating the validation code
70
+ to handle the above change to ``exp_val`` and ``ndigits``.
71
+ Users never directly instantiate ``FinalizedOptions`` so this will hopefully
72
+ be no problem.
73
+ ``InputOptions`` continue to be validated because this is the direct result
74
+ of user input.
75
+ ``PopulatedOptions`` also must continue to be validated because options
76
+ conflicts due to the combination of user input with global options can arise
77
+ at options population time.
78
+ * Update ``ruff`` version in pre-commit config.
79
+
80
+ REMOVED
81
+ ^^^^^^^
82
+ * The ``pdg_sig_figs`` options has been removed.
83
+ This option is now configured by setting ``round_mode="pdg"``.
84
+
85
+ FIXED
86
+ ^^^^^
87
+
88
+ * The ``ruff`` version in the github CI now matches the ``ruff`` in the local precommit
89
+ configuration.
90
+
91
+ ----
92
+
17
93
  0.37.0 (2024-03-07)
18
94
  -------------------
19
95
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sciform
3
- Version: 0.37.0
3
+ Version: 0.38.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
@@ -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: dev
25
- Requires-Dist: ruff; extra == "dev"
26
- Requires-Dist: coverage; extra == "dev"
27
- Requires-Dist: sphinx; extra == "dev"
28
- Requires-Dist: sphinx-rtd-theme; extra == "dev"
29
- Requires-Dist: sphinx-toolbox; extra == "dev"
30
- Requires-Dist: numpy; extra == "dev"
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
- .. image:: https://www.repostatus.org/badges/latest/wip.svg
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
- | **Repository:** `<https://github.com/jagerber48/sciform>`_
69
- | **Documentation:** `<https://sciform.readthedocs.io/en/stable/>`_
70
- | **PyPi:** `<https://pypi.org/project/sciform/>`_
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
- .. image:: https://www.repostatus.org/badges/latest/wip.svg
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
- | **Repository:** `<https://github.com/jagerber48/sciform>`_
32
- | **Documentation:** `<https://sciform.readthedocs.io/en/stable/>`_
33
- | **PyPi:** `<https://pypi.org/project/sciform/>`_
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
- :noindex:
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