quantities 0.16.3__tar.gz → 0.17.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 (158) hide show
  1. {quantities-0.16.3 → quantities-0.17.0}/.github/workflows/test.yml +30 -65
  2. quantities-0.17.0/.gitlab-ci.yml +27 -0
  3. quantities-0.16.3/CHANGES.txt → quantities-0.17.0/CHANGES.rst +38 -8
  4. quantities-0.17.0/CONTRIBUTING.md +42 -0
  5. quantities-0.17.0/LICENSE +1 -0
  6. {quantities-0.16.3 → quantities-0.17.0}/MANIFEST.in +1 -1
  7. {quantities-0.16.3/quantities.egg-info → quantities-0.17.0}/PKG-INFO +18 -8
  8. {quantities-0.16.3 → quantities-0.17.0}/README.rst +13 -2
  9. {quantities-0.16.3 → quantities-0.17.0}/codemeta.json +3 -3
  10. quantities-0.17.0/doc/devel/architecture.rst +140 -0
  11. quantities-0.17.0/doc/devel/devnotes.rst +13 -0
  12. {quantities-0.16.3 → quantities-0.17.0}/doc/devel/index.rst +6 -2
  13. quantities-0.17.0/doc/devel/maintenance.rst +79 -0
  14. quantities-0.17.0/doc/devel/onboarding.rst +146 -0
  15. {quantities-0.16.3 → quantities-0.17.0}/doc/devel/release.rst +2 -0
  16. quantities-0.17.0/doc/devel/workflow.rst +111 -0
  17. {quantities-0.16.3 → quantities-0.17.0}/doc/index.rst +4 -2
  18. quantities-0.17.0/doc/user/changes.rst +3 -0
  19. quantities-0.17.0/doc/user/credits.rst +75 -0
  20. {quantities-0.16.3 → quantities-0.17.0}/doc/user/index.rst +1 -0
  21. {quantities-0.16.3 → quantities-0.17.0}/doc/user/installation.rst +2 -2
  22. {quantities-0.16.3 → quantities-0.17.0}/doc/user/issues.rst +33 -17
  23. {quantities-0.16.3 → quantities-0.17.0}/pyproject.toml +29 -10
  24. {quantities-0.16.3 → quantities-0.17.0}/quantities/__init__.py +117 -74
  25. quantities-0.17.0/quantities/_version.py +24 -0
  26. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/NIST_codata.txt +1 -1
  27. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/_codata.py +1 -1
  28. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/_utils.py +2 -1
  29. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/alpha.py +1 -2
  30. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/astronomy.py +1 -2
  31. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/atomicunits.py +1 -2
  32. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/deuteron.py +1 -2
  33. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/electromagnetism.py +1 -2
  34. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/electron.py +1 -2
  35. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/helion.py +1 -3
  36. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/mathematical.py +0 -1
  37. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/muon.py +1 -2
  38. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/naturalunits.py +1 -2
  39. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/neutron.py +1 -2
  40. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/proton.py +1 -2
  41. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/quantum.py +1 -2
  42. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/relationships.py +1 -2
  43. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/statisticalmechanics.py +1 -2
  44. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/tau.py +1 -2
  45. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/triton.py +1 -2
  46. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/weak.py +1 -2
  47. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/xray.py +1 -2
  48. {quantities-0.16.3 → quantities-0.17.0}/quantities/decorators.py +6 -12
  49. {quantities-0.16.3 → quantities-0.17.0}/quantities/dimensionality.py +16 -28
  50. {quantities-0.16.3 → quantities-0.17.0}/quantities/markup.py +7 -5
  51. {quantities-0.16.3 → quantities-0.17.0}/quantities/quantity.py +87 -98
  52. {quantities-0.16.3 → quantities-0.17.0}/quantities/quantity.pyi +2 -1
  53. {quantities-0.16.3 → quantities-0.17.0}/quantities/registry.py +10 -8
  54. {quantities-0.16.3 → quantities-0.17.0}/quantities/registry.pyi +1 -2
  55. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/common.py +3 -4
  56. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_arithmetic.py +27 -2
  57. quantities-0.17.0/quantities/tests/test_constants.py +79 -0
  58. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_conversion.py +23 -14
  59. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_methods.py +62 -9
  60. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_persistence.py +8 -5
  61. quantities-0.17.0/quantities/tests/test_photometry.py +71 -0
  62. quantities-0.17.0/quantities/tests/test_tutorial.py +16 -0
  63. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_umath.py +126 -12
  64. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_uncertainty.py +61 -6
  65. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_units.py +45 -1
  66. {quantities-0.16.3 → quantities-0.17.0}/quantities/typing/quantities.pyi +4 -3
  67. {quantities-0.16.3 → quantities-0.17.0}/quantities/umath.py +42 -93
  68. {quantities-0.16.3 → quantities-0.17.0}/quantities/uncertainquantity.py +17 -15
  69. {quantities-0.16.3 → quantities-0.17.0}/quantities/unitquantity.py +15 -20
  70. {quantities-0.16.3 → quantities-0.17.0}/quantities/unitquantity.pyi +1 -1
  71. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/__init__.py +11 -1
  72. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/acceleration.pyi +1 -1
  73. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/area.pyi +0 -1
  74. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/concentration.pyi +0 -1
  75. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/dimensionless.py +1 -1
  76. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/dimensionless.pyi +0 -1
  77. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/energy.py +2 -2
  78. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/force.py +4 -5
  79. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/frequency.py +1 -2
  80. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/heat.py +3 -4
  81. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/information.py +1 -1
  82. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/information.pyi +1 -1
  83. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/mass.py +1 -1
  84. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/mass.pyi +1 -1
  85. quantities-0.17.0/quantities/units/photometry.py +50 -0
  86. quantities-0.17.0/quantities/units/photometry.pyi +15 -0
  87. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/power.py +3 -4
  88. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/pressure.py +2 -3
  89. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/radiation.py +4 -5
  90. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/temperature.py +0 -1
  91. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/time.py +1 -2
  92. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/velocity.py +1 -2
  93. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/viscosity.py +1 -2
  94. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/volume.py +2 -2
  95. {quantities-0.16.3 → quantities-0.17.0/quantities.egg-info}/PKG-INFO +18 -8
  96. {quantities-0.16.3 → quantities-0.17.0}/quantities.egg-info/SOURCES.txt +15 -1
  97. {quantities-0.16.3 → quantities-0.17.0}/quantities.egg-info/requires.txt +2 -4
  98. quantities-0.17.0/quantities.egg-info/scm_file_list.json +148 -0
  99. quantities-0.17.0/quantities.egg-info/scm_version.json +8 -0
  100. {quantities-0.16.3 → quantities-0.17.0}/setup.py +6 -2
  101. quantities-0.16.3/doc/devel/devnotes.rst +0 -8
  102. quantities-0.16.3/doc/user/credits.rst +0 -29
  103. quantities-0.16.3/quantities/_version.py +0 -34
  104. quantities-0.16.3/quantities/tests/test_constants.py +0 -4
  105. {quantities-0.16.3 → quantities-0.17.0}/.gitattributes +0 -0
  106. {quantities-0.16.3 → quantities-0.17.0}/.gitignore +0 -0
  107. {quantities-0.16.3 → quantities-0.17.0}/.readthedocs.yaml +0 -0
  108. {quantities-0.16.3 → quantities-0.17.0}/conda.recipe/bld.bat +0 -0
  109. {quantities-0.16.3 → quantities-0.17.0}/conda.recipe/build.sh +0 -0
  110. {quantities-0.16.3 → quantities-0.17.0}/conda.recipe/format_version.py +0 -0
  111. {quantities-0.16.3 → quantities-0.17.0}/conda.recipe/meta.yaml +0 -0
  112. {quantities-0.16.3 → quantities-0.17.0}/conda.recipe/run_test.py +0 -0
  113. {quantities-0.16.3 → quantities-0.17.0}/doc/Makefile +0 -0
  114. {quantities-0.16.3 → quantities-0.17.0}/doc/_templates/indexsidebar.html +0 -0
  115. {quantities-0.16.3 → quantities-0.17.0}/doc/conf.py +0 -0
  116. {quantities-0.16.3 → quantities-0.17.0}/doc/devel/documenting.rst +0 -0
  117. {quantities-0.16.3 → quantities-0.17.0}/doc/make.bat +0 -0
  118. {quantities-0.16.3 → quantities-0.17.0}/doc/rtd-requirements.txt +0 -0
  119. {quantities-0.16.3 → quantities-0.17.0}/doc/sphinxext/ipython_console_highlighting.py +0 -0
  120. {quantities-0.16.3 → quantities-0.17.0}/doc/user/license.rst +0 -0
  121. {quantities-0.16.3 → quantities-0.17.0}/doc/user/tutorial.rst +0 -0
  122. {quantities-0.16.3 → quantities-0.17.0}/quantities/constants/__init__.py +0 -0
  123. {quantities-0.16.3 → quantities-0.17.0}/quantities/dimensionality.pyi +0 -0
  124. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/__init__.py +0 -0
  125. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_comparison.py +0 -0
  126. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_dimensionality.py +0 -0
  127. {quantities-0.16.3 → quantities-0.17.0}/quantities/tests/test_formatting.py +0 -0
  128. {quantities-0.16.3 → quantities-0.17.0}/quantities/typing/__init__.py +0 -0
  129. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/acceleration.py +1 -1
  130. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/angle.py +0 -0
  131. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/angle.pyi +0 -0
  132. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/area.py +0 -0
  133. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/compound.py +0 -0
  134. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/compound.pyi +0 -0
  135. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/concentration.py +0 -0
  136. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/electromagnetism.py +5 -5
  137. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/electromagnetism.pyi +0 -0
  138. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/energy.pyi +0 -0
  139. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/force.pyi +0 -0
  140. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/frequency.pyi +0 -0
  141. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/heat.pyi +0 -0
  142. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/length.py +0 -0
  143. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/length.pyi +0 -0
  144. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/power.pyi +0 -0
  145. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/prefixes.py +0 -0
  146. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/prefixes.pyi +0 -0
  147. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/pressure.pyi +0 -0
  148. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/radiation.pyi +0 -0
  149. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/substance.py +0 -0
  150. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/substance.pyi +0 -0
  151. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/temperature.pyi +0 -0
  152. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/time.pyi +0 -0
  153. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/velocity.pyi +0 -0
  154. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/viscosity.pyi +0 -0
  155. {quantities-0.16.3 → quantities-0.17.0}/quantities/units/volume.pyi +0 -0
  156. {quantities-0.16.3 → quantities-0.17.0}/quantities.egg-info/dependency_links.txt +0 -0
  157. {quantities-0.16.3 → quantities-0.17.0}/quantities.egg-info/top_level.txt +0 -0
  158. {quantities-0.16.3 → quantities-0.17.0}/setup.cfg +0 -0
@@ -12,41 +12,14 @@ jobs:
12
12
  fail-fast: false
13
13
  matrix:
14
14
  os: [ ubuntu-latest ]
15
- python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
16
- numpy-version: [ "1.24", "1.25", "1.26", "2.0", "2.1", "2.2", "2.3", "2.4" ]
15
+ python-version: [ "3.11", "3.12", "3.13", "3.14", "3.15" ]
16
+ numpy-version: [ "2.0", "2.1", "2.2", "2.3", "2.4", "2.5" ]
17
17
  exclude:
18
- - python-version: "3.10"
19
- numpy-version: "2.3"
20
- os: ubuntu-latest
21
- - python-version: "3.10"
22
- numpy-version: "2.4"
23
- os: ubuntu-latest
24
18
  - python-version: "3.11"
25
19
  numpy-version: "2.4"
26
20
  os: ubuntu-latest
27
- - python-version: "3.12"
28
- numpy-version: "1.24"
29
- os: ubuntu-latest
30
- - python-version: "3.12"
31
- numpy-version: "1.25"
32
- os: ubuntu-latest
33
- - python-version: "3.13"
34
- numpy-version: "1.24"
35
- os: ubuntu-latest
36
- - python-version: "3.13"
37
- numpy-version: "1.25"
38
- os: ubuntu-latest
39
- - python-version: "3.13"
40
- numpy-version: "1.26"
41
- os: ubuntu-latest
42
- - python-version: "3.14"
43
- numpy-version: "1.24"
44
- os: ubuntu-latest
45
- - python-version: "3.14"
46
- numpy-version: "1.25"
47
- os: ubuntu-latest
48
- - python-version: "3.14"
49
- numpy-version: "1.26"
21
+ - python-version: "3.11"
22
+ numpy-version: "2.5"
50
23
  os: ubuntu-latest
51
24
  steps:
52
25
  - uses: actions/checkout@v4
@@ -76,7 +49,7 @@ jobs:
76
49
  python -m pip install -U setuptools
77
50
  python -m pip install -U wheel
78
51
  python -m pip install -U pytest
79
- python -m pip install "numpy==${{ matrix.numpy-version }}"
52
+ python -m pip install "numpy==${{ matrix.numpy-version }}.*"
80
53
 
81
54
  - name: Install
82
55
  run: |
@@ -85,7 +58,7 @@ jobs:
85
58
  - name: Test
86
59
  run: |
87
60
  PY_IGNORE_IMPORTMISMATCH=1 pytest
88
- python -m doctest README.rst
61
+ python -m doctest README.rst doc/user/issues.rst
89
62
 
90
63
  type-check:
91
64
  runs-on: ${{ matrix.os }}
@@ -93,41 +66,14 @@ jobs:
93
66
  fail-fast: false
94
67
  matrix:
95
68
  os: [ ubuntu-latest ]
96
- python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
97
- numpy-version: [ "1.24", "1.25", "1.26", "2.0", "2.1", "2.2", "2.3", "2.4" ]
69
+ python-version: [ "3.11", "3.12", "3.13", "3.14", "3.15" ]
70
+ numpy-version: [ "2.0", "2.1", "2.2", "2.3", "2.4", "2.5" ]
98
71
  exclude:
99
- - python-version: "3.10"
100
- numpy-version: "2.3"
101
- os: ubuntu-latest
102
- - python-version: "3.10"
103
- numpy-version: "2.4"
104
- os: ubuntu-latest
105
72
  - python-version: "3.11"
106
73
  numpy-version: "2.4"
107
74
  os: ubuntu-latest
108
- - python-version: "3.12"
109
- numpy-version: "1.24"
110
- os: ubuntu-latest
111
- - python-version: "3.12"
112
- numpy-version: "1.25"
113
- os: ubuntu-latest
114
- - python-version: "3.13"
115
- numpy-version: "1.24"
116
- os: ubuntu-latest
117
- - python-version: "3.13"
118
- numpy-version: "1.25"
119
- os: ubuntu-latest
120
- - python-version: "3.13"
121
- numpy-version: "1.26"
122
- os: ubuntu-latest
123
- - python-version: "3.14"
124
- numpy-version: "1.24"
125
- os: ubuntu-latest
126
- - python-version: "3.14"
127
- numpy-version: "1.25"
128
- os: ubuntu-latest
129
- - python-version: "3.14"
130
- numpy-version: "1.26"
75
+ - python-version: "3.11"
76
+ numpy-version: "2.5"
131
77
  os: ubuntu-latest
132
78
  steps:
133
79
  - uses: actions/checkout@v4
@@ -156,7 +102,7 @@ jobs:
156
102
  python -m pip install -U pip
157
103
  python -m pip install -U setuptools
158
104
  python -m pip install -U wheel
159
- python -m pip install "numpy==${{ matrix.numpy-version }}"
105
+ python -m pip install "numpy==${{ matrix.numpy-version }}.*"
160
106
  python -m pip install -U pytest
161
107
  python -m pip install -U mypy
162
108
 
@@ -167,3 +113,22 @@ jobs:
167
113
  - name: Check type information
168
114
  run: |
169
115
  mypy quantities
116
+
117
+ lint:
118
+ runs-on: ubuntu-latest
119
+ steps:
120
+ - uses: actions/checkout@v4
121
+
122
+ - name: Set up Python
123
+ uses: actions/setup-python@v5
124
+ with:
125
+ python-version: "3.12"
126
+
127
+ - name: Install Ruff
128
+ run: |
129
+ python -m pip install -U pip
130
+ python -m pip install -U ruff
131
+
132
+ - name: Run Ruff
133
+ run: |
134
+ ruff check quantities
@@ -0,0 +1,27 @@
1
+ # GitLab CI configuration for the EBRAINS GitLab mirror.
2
+ #
3
+ # The canonical CI is GitHub Actions (see .github/workflows/). This pipeline
4
+ # runs on the EBRAINS GitLab mirror only, and exists primarily to compute and
5
+ # publish a code-coverage badge. The badge URL is derived from this project's
6
+ # slug on gitlab.ebrains.eu:
7
+ #
8
+ # https://gitlab.ebrains.eu/<group>/<project>/badges/master/coverage.svg
9
+
10
+ stages:
11
+ - test
12
+
13
+ coverage:
14
+ stage: test
15
+ image: python:3.13
16
+ before_script:
17
+ - python -m pip install --upgrade pip
18
+ - pip install -e ".[test]"
19
+ script:
20
+ - pytest --cov=quantities --cov-report=term --cov-report=xml
21
+ coverage: '/^TOTAL.*\s+(\d+(?:\.\d+)?)%/'
22
+ artifacts:
23
+ when: always
24
+ reports:
25
+ coverage_report:
26
+ coverage_format: cobertura
27
+ path: coverage.xml
@@ -1,13 +1,43 @@
1
1
  =======
2
- CHANGES
2
+ Changes
3
3
  =======
4
4
 
5
+ ------
6
+ 0.17.0
7
+ ------
8
+
9
+ - Drop support for Python 3.10 and NumPy 1.x, following NEP 29 plus one year, and add CI testing for Python 3.15 and NumPy 2.5 (`PR#277 <https://github.com/python-quantities/python-quantities/pull/277>`_)
10
+ - **Behaviour change:** a NumPy ufunc whose ``out`` argument is a view of a Quantity now raises ``ValueError`` if the result would change the units of the view, as in-place operators already did. Values already written to ``out`` are not rolled back (`PR#276 <https://github.com/python-quantities/python-quantities/pull/276>`_)
11
+ - Fix ``np.nanstd``, and the units of ufunc results written to an existing Quantity with ``out``, with NumPy 2 (`#223 <https://github.com/python-quantities/python-quantities/issues/223>`_, `PR#276 <https://github.com/python-quantities/python-quantities/pull/276>`_)
12
+ - Add lumen, lux, foot-candle, phot, nit and stilb photometric units (`#286 <https://github.com/python-quantities/python-quantities/issues/286>`_, `PR#288 <https://github.com/python-quantities/python-quantities/pull/288>`_)
13
+ - Support unary ``+`` (``np.positive``) on quantities (`#94 <https://github.com/python-quantities/python-quantities/issues/94>`_, `PR#273 <https://github.com/python-quantities/python-quantities/pull/273>`_)
14
+ - Correct the pond force unit to 0.00980665 N (one gram-force); it was previously 1000 times too large (`#44 <https://github.com/python-quantities/python-quantities/issues/44>`_, `PR#275 <https://github.com/python-quantities/python-quantities/pull/275>`_)
15
+ - Fix ``np.ptp`` dropping the units of a Quantity with NumPy 2 (`PR#281 <https://github.com/python-quantities/python-quantities/pull/281>`_)
16
+ - Allow numeric bounds when clipping dimensionless quantities (`#108 <https://github.com/python-quantities/python-quantities/issues/108>`_, `PR#282 <https://github.com/python-quantities/python-quantities/pull/282>`_)
17
+ - Convert quantity-valued ``ediff1d`` boundary differences (``to_begin``, ``to_end``) to the input units (`PR#283 <https://github.com/python-quantities/python-quantities/pull/283>`_)
18
+ - ``rescale()`` to the same units now returns a new Quantity built in the same way as for different units, so ``.base`` is no longer ``None`` (`#42 <https://github.com/python-quantities/python-quantities/issues/42>`_)
19
+ - Fix constructing an ``UncertainQuantity`` from another ``UncertainQuantity`` without an explicit uncertainty, which raised ``AttributeError`` (`PR#289 <https://github.com/python-quantities/python-quantities/pull/289>`_)
20
+ - Adding or subtracting a number or Quantity without an uncertainty to or from an ``UncertainQuantity`` now treats it as exact, instead of raising ``AttributeError`` (`#45 <https://github.com/python-quantities/python-quantities/issues/45>`_)
21
+ - ``Quantity.nanmax()``, ``nanmin()``, ``nanargmax()`` and ``nanargmin()`` now honour ``axis`` and ``out``; they used to reduce over the whole array and ignore ``out`` (`PR#294 <https://github.com/python-quantities/python-quantities/pull/294>`_)
22
+ - ``quantities.umath.trapz`` now always uses ``numpy.trapezoid``; SciPy is no longer used, and the ``scipy`` optional dependency has been removed (`PR#285 <https://github.com/python-quantities/python-quantities/pull/285>`_)
23
+ - Functions in ``quantities.umath`` no longer emit a spurious ``QuantitiesDeprecationWarning`` about the ``copy`` argument (`PR#285 <https://github.com/python-quantities/python-quantities/pull/285>`_)
24
+ - Fix the import of ``__version__`` when the package is built with setuptools_scm older than 7.0, which is now the minimum required (`#224 <https://github.com/python-quantities/python-quantities/issues/224>`_)
25
+ - Fix type checking with NumPy 2.5 (`PR#277 <https://github.com/python-quantities/python-quantities/pull/277>`_)
26
+ - Documentation: the tutorial is updated for Python 3, covers ``.magnitude`` and ``.units``, and is now tested; the documentation now says which operations propagate the uncertainty of an ``UncertainQuantity`` (`#214 <https://github.com/python-quantities/python-quantities/issues/214>`_, `#46 <https://github.com/python-quantities/python-quantities/issues/46>`_, `PR#291 <https://github.com/python-quantities/python-quantities/pull/291>`_)
27
+ - Development: extended documentation for developers and maintainers (`PR#274 <https://github.com/python-quantities/python-quantities/pull/274>`_); tests for ``quantities.constants`` (`PR#280 <https://github.com/python-quantities/python-quantities/pull/280>`_); the generated constants file records the CODATA edition instead of a timestamp (`PR#279 <https://github.com/python-quantities/python-quantities/pull/279>`_); f-strings throughout (`PR#230 <https://github.com/python-quantities/python-quantities/pull/230>`_); Ruff linting, now enforced in CI (`PR#290 <https://github.com/python-quantities/python-quantities/pull/290>`_)
28
+
29
+ ------
30
+ 0.16.4
31
+ ------
32
+
33
+ - Fix problems with v0.16.3: deepcopy was not copying all necessary attributes of UnitQuantity; in-place arithmetic didn't handle multiplying by scalars
34
+
5
35
  ------
6
36
  0.16.3
7
37
  ------
8
38
 
9
39
  - Fix broken `deepcopy` behaviour when using quantities with NumPy 2.x (`PR#257 <https://github.com/python-quantities/python-quantities/pull/257>`_)
10
- - Fixes for assorted breakages that appear with recent NumPy versions (`PR#262 <https://github.com/python-quantities/python-quantities/pull/262>`_, `PR#267 <<https://github.com/python-quantities/python-quantities/pull/267>`_)
40
+ - Fixes for assorted breakages that appear with recent NumPy versions (`PR#262 <https://github.com/python-quantities/python-quantities/pull/262>`_, `PR#267 <https://github.com/python-quantities/python-quantities/pull/267>`_)
11
41
  - Revert to previous behaviour where spaces around units were allowed (`PR#270 <https://github.com/python-quantities/python-quantities/pull/270>`_)
12
42
  - Fix broken in-place arithmetic when using quantities with NumPy 2.x (`PR#271 <https://github.com/python-quantities/python-quantities/pull/271>`_)
13
43
  - Add CI testing for Python 3.13 and 3.14, drop support for Python 3.9
@@ -137,9 +167,9 @@ Bugs fixed
137
167
 
138
168
  https://github.com/python-quantities/python-quantities/issues?utf8=✓&q=is%3Aclosed%20closed%3A2017-08-02..2017-08-30
139
169
 
140
- -----
170
+ ------
141
171
  0.12.0
142
- -----
172
+ ------
143
173
 
144
174
  Removed support for Python 2.6, since NumPy removed support for it as of
145
175
  version 1.12. Numpy-1.8.2 or later is now required.
@@ -153,9 +183,9 @@ Bugs fixed
153
183
  https://github.com/python-quantities/python-quantities/issues?utf8=✓&q=is%3Aissue%20is%3Aclosed%20closed%3A2015-12-06..2017-08-01
154
184
 
155
185
 
156
- -----
186
+ ------
157
187
  0.11.0
158
- -----
188
+ ------
159
189
 
160
190
  Added many new unit definitions, including aliases for American/British spellings of liter/litre
161
191
  The Quantity class can now be subclassed.
@@ -169,9 +199,9 @@ Bugs fixed
169
199
  https://github.com/python-quantities/python-quantities/issues?utf8=✓&q=is%3Aissue%20is%3Aclosed%20closed%3A2011-09-27..2015-12-06
170
200
 
171
201
 
172
- -----
202
+ ------
173
203
  0.10.0
174
- -----
204
+ ------
175
205
 
176
206
  The dalton has been added as an alias for the unified atomic mass
177
207
  unit, in response to the 2005 IUPAP report recognizing that both
@@ -0,0 +1,42 @@
1
+ # Contributing to quantities
2
+
3
+ Contributions to *quantities*, whether bug reports, bug fixes, new units or constants, documentation improvements, or new features, are welcome.
4
+
5
+ ## Reporting bugs and requesting features
6
+
7
+ Please use the [GitHub issue
8
+ tracker](https://github.com/python-quantities/python-quantities/issues).
9
+
10
+ For bug reports, please include:
11
+
12
+ - the version of *quantities* and of NumPy you are using,
13
+ - your Python version and operating system,
14
+ - a minimal example that reproduces the problem,
15
+ - the actual output and the output you expected.
16
+
17
+ ## Submitting changes
18
+
19
+ Development happens on GitHub via pull requests against the `master` branch.
20
+ A short walkthrough — from cloning the repository to opening your first PR —
21
+ is in the [Onboarding guide][onboarding] in the developer documentation,
22
+ and the [Development workflow][workflow] page covers branching, review,
23
+ versioning and the deprecation policy.
24
+
25
+ Before opening a pull request:
26
+
27
+ 1. Make sure the test suite passes locally (`pytest`).
28
+ 2. Add a test for any bug fix or new feature.
29
+ 3. Add an entry to `CHANGES.rst` describing the change.
30
+
31
+ [onboarding]: https://python-quantities.readthedocs.io/en/latest/devel/onboarding.html
32
+ [workflow]: https://python-quantities.readthedocs.io/en/latest/devel/workflow.html
33
+
34
+ ## Licensing of contributions
35
+
36
+ *quantities* is distributed under the BSD 3-Clause License (see
37
+ [`doc/user/license.rst`](doc/user/license.rst)).
38
+ By submitting a contribution (for example by opening
39
+ a pull request) you agree that your contribution is licensed under the same
40
+ license and that you have the right to make it under those terms.
41
+
42
+ No separate Contributor License Agreement (CLA) is required.
@@ -0,0 +1 @@
1
+ see doc/user/license.rst
@@ -1,3 +1,3 @@
1
- include CHANGES.txt
1
+ include CHANGES.rst
2
2
  include quantities/constants/NIST_codata.txt
3
3
  exclude conda.recipe
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: quantities
3
- Version: 0.16.3
3
+ Version: 0.17.0
4
4
  Summary: Support for physical quantities with units, based on numpy
5
5
  Author-email: Darren Dale <dsdale24@gmail.com>
6
6
  Maintainer-email: Andrew Davison <andrew.davison@cnrs.fr>
7
7
  Project-URL: documentation, http://python-quantities.readthedocs.io/
8
8
  Project-URL: repository, https://github.com/python-quantities/python-quantities
9
- Project-URL: changelog, https://github.com/python-quantities/python-quantities/blob/master/CHANGES.txt
9
+ Project-URL: changelog, https://github.com/python-quantities/python-quantities/blob/master/CHANGES.rst
10
10
  Project-URL: download, http://pypi.python.org/pypi/quantities
11
11
  Keywords: quantities,units,physical,constants
12
12
  Classifier: Development Status :: 4 - Beta
@@ -19,17 +19,16 @@ Classifier: Operating System :: OS Independent
19
19
  Classifier: Programming Language :: Python
20
20
  Classifier: Topic :: Education
21
21
  Classifier: Topic :: Scientific/Engineering
22
- Requires-Python: >=3.10
22
+ Requires-Python: >=3.11
23
23
  Description-Content-Type: text/x-rst
24
24
  License-File: doc/user/license.rst
25
- Requires-Dist: numpy>=1.24
25
+ Requires-Dist: numpy>=2.0
26
26
  Provides-Extra: test
27
27
  Requires-Dist: pytest; extra == "test"
28
28
  Requires-Dist: wheel; extra == "test"
29
+ Requires-Dist: ruff; extra == "test"
29
30
  Provides-Extra: doc
30
31
  Requires-Dist: sphinx; extra == "doc"
31
- Provides-Extra: scipy
32
- Requires-Dist: scipy; extra == "scipy"
33
32
  Dynamic: license-file
34
33
 
35
34
  ==========
@@ -43,14 +42,18 @@ for examples. Quantities builds on the popular numpy library and is
43
42
  designed to work with numpy ufuncs, many of which are already
44
43
  supported. Quantities is actively developed, and while the current features
45
44
  and API are stable, test coverage is incomplete so the package is not
46
- suggested for mission-critical applications.
45
+ suggested for mission-critical applications. Support for uncertainties is
46
+ incomplete: many numpy functions do not propagate uncertainty (see the
47
+ tutorial_ for details).
47
48
 
48
- |pypi version|_ |Build status|_
49
+ |pypi version|_ |Build status|_ |Coverage Status|_
49
50
 
50
51
  .. |pypi version| image:: https://img.shields.io/pypi/v/quantities.png
51
52
  .. _`pypi version`: https://pypi.python.org/pypi/quantities
52
53
  .. |Build status| image:: https://github.com/python-quantities/python-quantities/actions/workflows/test.yml/badge.svg?branch=master
53
54
  .. _`Build status`: https://github.com/python-quantities/python-quantities/actions/workflows/test.yml
55
+ .. |Coverage Status| image:: https://gitlab.ebrains.eu/NeuralEnsemble/python-quantities/badges/master/coverage.svg
56
+ .. _`Coverage Status`: https://gitlab.ebrains.eu/NeuralEnsemble/python-quantities/-/pipelines
54
57
  .. _tutorial: http://python-quantities.readthedocs.io/en/latest/user/tutorial.html
55
58
 
56
59
 
@@ -111,6 +114,13 @@ And run::
111
114
  in the current directory. The master branch is automatically tested by
112
115
  GitHub Actions.
113
116
 
117
+ Contributing
118
+ ------------
119
+ Bug reports, fixes, and pull requests are welcome. Please see
120
+ `CONTRIBUTING.md <CONTRIBUTING.md>`_ for a quick overview, and the
121
+ `developer documentation <https://python-quantities.readthedocs.io/en/latest/devel/index.html>`_
122
+ for the onboarding guide, architecture overview, and development workflow.
123
+
114
124
  Author
115
125
  ------
116
126
  quantities was originally written by Darren Dale, and has received contributions from `many people`_.
@@ -9,14 +9,18 @@ for examples. Quantities builds on the popular numpy library and is
9
9
  designed to work with numpy ufuncs, many of which are already
10
10
  supported. Quantities is actively developed, and while the current features
11
11
  and API are stable, test coverage is incomplete so the package is not
12
- suggested for mission-critical applications.
12
+ suggested for mission-critical applications. Support for uncertainties is
13
+ incomplete: many numpy functions do not propagate uncertainty (see the
14
+ tutorial_ for details).
13
15
 
14
- |pypi version|_ |Build status|_
16
+ |pypi version|_ |Build status|_ |Coverage Status|_
15
17
 
16
18
  .. |pypi version| image:: https://img.shields.io/pypi/v/quantities.png
17
19
  .. _`pypi version`: https://pypi.python.org/pypi/quantities
18
20
  .. |Build status| image:: https://github.com/python-quantities/python-quantities/actions/workflows/test.yml/badge.svg?branch=master
19
21
  .. _`Build status`: https://github.com/python-quantities/python-quantities/actions/workflows/test.yml
22
+ .. |Coverage Status| image:: https://gitlab.ebrains.eu/NeuralEnsemble/python-quantities/badges/master/coverage.svg
23
+ .. _`Coverage Status`: https://gitlab.ebrains.eu/NeuralEnsemble/python-quantities/-/pipelines
20
24
  .. _tutorial: http://python-quantities.readthedocs.io/en/latest/user/tutorial.html
21
25
 
22
26
 
@@ -77,6 +81,13 @@ And run::
77
81
  in the current directory. The master branch is automatically tested by
78
82
  GitHub Actions.
79
83
 
84
+ Contributing
85
+ ------------
86
+ Bug reports, fixes, and pull requests are welcome. Please see
87
+ `CONTRIBUTING.md <CONTRIBUTING.md>`_ for a quick overview, and the
88
+ `developer documentation <https://python-quantities.readthedocs.io/en/latest/devel/index.html>`_
89
+ for the onboarding guide, architecture overview, and development workflow.
90
+
80
91
  Author
81
92
  ------
82
93
  quantities was originally written by Darren Dale, and has received contributions from `many people`_.
@@ -163,15 +163,15 @@
163
163
  "dateModified": "2026-01-16",
164
164
  "datePublished": "2009-10-13",
165
165
  "description": "A Python package for handling physical quantities.\n\nQuantities is designed to handle arithmetic and conversions of physical quantities, which have a magnitude, dimensionality specified by various units, and possibly an uncertainty. Quantities builds on the popular NumPy library and is designed to work with NumPy ufuncs, many of which are already supported.",
166
- "downloadUrl": "https://files.pythonhosted.org/packages/<FIX THIS>/quantities-0.16.3.tar.gz",
166
+ "downloadUrl": "https://files.pythonhosted.org/packages/aa/50/19194d2cf428239ecbda876d81bbfddb76697a248c5a7478ae83d0b98fee/quantities-0.16.4.tar.gz",
167
167
  "license": "https://spdx.org/licenses/BSD-3-Clause",
168
168
  "name": "quantities",
169
169
  "operatingSystem": ["Linux", "Windows", "macOS"],
170
170
  "programmingLanguage": "Python 3",
171
171
  "relatedLink": "https://python-quantities.readthedocs.io/",
172
- "releaseNotes": "https://github.com/python-quantities/python-quantities/blob/master/CHANGES.txt",
172
+ "releaseNotes": "https://github.com/python-quantities/python-quantities/blob/master/CHANGES.rst",
173
173
  "softwareRequirements": "https://pypi.org/project/numpy/",
174
- "version": "0.16.3",
174
+ "version": "0.16.4",
175
175
  "continuousIntegration": "https://github.com/python-quantities/python-quantities/actions",
176
176
  "developmentStatus": "active",
177
177
  "issueTracker": "https://github.com/python-quantities/python-quantities/issues"
@@ -0,0 +1,140 @@
1
+ .. _architecture-overview:
2
+
3
+ *********************
4
+ Architecture Overview
5
+ *********************
6
+
7
+ This page gives a high-level view of how *quantities* is put together
8
+ internally, intended for new contributors who want to understand the design
9
+ before making non-trivial changes.
10
+
11
+ For the user-facing API, see the :doc:`user guide </user/index>`.
12
+
13
+
14
+ Design rationale
15
+ ================
16
+
17
+ *quantities* is a NumPy extension library. Rather than implement its own
18
+ array machinery, it subclasses :class:`numpy.ndarray` so that
19
+ :class:`Quantity` instances behave like regular arrays — they participate
20
+ in vectorised arithmetic, broadcasting, ufuncs and indexing — while also
21
+ carrying dimensional (unit) information that is validated and propagated
22
+ through every operation.
23
+
24
+ The design has three pillars:
25
+
26
+ 1. **Dimensionality** is data, not a string. Units multiply, divide and
27
+ raise to integer powers; *quantities* stores those exponents in a
28
+ mapping and uses it both for arithmetic and for display.
29
+ 2. **Conversions** are pure scalar multiplications. The unit registry
30
+ produces conversion factors that are simply numbers; the dimensional
31
+ bookkeeping lives in the :class:`Dimensionality` mapping.
32
+ 3. **Interoperability with NumPy is paramount.** *quantities* hooks into
33
+ the ufunc machinery so that ``np.sin``, ``np.sqrt``, ``np.add`` and so
34
+ on work as expected on :class:`Quantity` arrays.
35
+
36
+
37
+ Class hierarchy
38
+ ===============
39
+
40
+ The core type hierarchy is::
41
+
42
+ numpy.ndarray
43
+ Quantity # quantity.py
44
+ UnitQuantity # unitquantity.py
45
+ UnitLength # quantities/units/length.py
46
+ UnitMass # quantities/units/mass.py
47
+ UnitTime # quantities/units/time.py
48
+ ... # one subclass per SI base dimension
49
+ CompoundUnit # preserves compound expressions
50
+ UncertainQuantity # uncertainquantity.py
51
+
52
+ :class:`Quantity`
53
+ Array values plus a ``_dimensionality`` attribute. This is what users
54
+ create with expressions such as ``42 * pq.metre``.
55
+
56
+ :class:`UnitQuantity`
57
+ A scalar :class:`Quantity` with magnitude 1 that represents a named
58
+ unit (``pq.metre``, ``pq.second``, …). Every :class:`UnitQuantity`
59
+ self-registers in the global ``unit_registry`` on construction.
60
+
61
+ :class:`UnitLength`, :class:`UnitMass`, …
62
+ SI-base-dimension subclasses of :class:`UnitQuantity`. They behave the
63
+ same as :class:`UnitQuantity` but their type marks the base dimension
64
+ they represent.
65
+
66
+ :class:`CompoundUnit`
67
+ A :class:`UnitQuantity` that preserves the compound expression
68
+ (e.g. ``m**2/m**3``) instead of simplifying it. Useful for display
69
+ when the user wants the original notation kept.
70
+
71
+ :class:`UncertainQuantity`
72
+ A :class:`Quantity` subclass that carries a ``_uncertainty`` attribute
73
+ (itself a :class:`Quantity`) and propagates uncertainty through
74
+ arithmetic.
75
+
76
+
77
+ Dimensionality
78
+ ==============
79
+
80
+ :class:`Dimensionality` (``dimensionality.py``) is a :class:`dict`
81
+ subclass that maps :class:`UnitQuantity` objects to integer exponents.
82
+ For example, the dimensionality of a velocity is::
83
+
84
+ {metre: 1, second: -1}
85
+
86
+ The class supports several text representations — ``.string``, ``.unicode``,
87
+ ``.latex`` and ``.html`` — produced by ``markup.py``. Dimension checking
88
+ and conversion-factor computation happen in ``quantity.py``
89
+ (``get_conversion_factor``, ``validate_dimensionality``).
90
+
91
+
92
+ The unit registry
93
+ =================
94
+
95
+ :class:`UnitRegistry` (``registry.py``) is a singleton that maps string
96
+ names and symbols to :class:`UnitQuantity` objects. When the user writes::
97
+
98
+ q.units = "kg*m/s**2"
99
+
100
+ the string is parsed by the registry. To avoid arbitrary code execution,
101
+ the parser uses Python's :mod:`ast` module and only allows a restricted
102
+ set of node types (names, numeric literals, binary arithmetic, power).
103
+ This is safer than ``eval`` and is verified by the test suite.
104
+
105
+ :class:`UnitQuantity` subclasses register themselves in this registry on
106
+ construction via their ``__init__``, so importing a module from
107
+ ``quantities/units/`` is enough to make all the units it defines
108
+ available.
109
+
110
+
111
+ Math support
112
+ ============
113
+
114
+ ``umath.py`` wraps NumPy ufuncs and reductions (trigonometric functions,
115
+ ``cumsum``, ``gradient``, ``trapz``, …) so they handle dimensional
116
+ analysis correctly. For example, ``pq.sin`` checks that the input has
117
+ units of angle, whereas plain ``np.sin`` silently extracts the magnitude.
118
+
119
+ The ``known issues`` section of the user guide documents which NumPy
120
+ operations are not yet dimension-aware.
121
+
122
+
123
+ The ``PREFERRED`` list
124
+ ======================
125
+
126
+ ``quantity.py`` defines a module-level list called ``PREFERRED`` which
127
+ downstream packages can mutate to express their preferred units for
128
+ display and simplification. This is the main extension point used by
129
+ domain-specific consumers of *quantities*.
130
+
131
+
132
+ Units and constants data
133
+ ========================
134
+
135
+ * ``quantities/units/`` — one module per physical dimension. Each module
136
+ defines :class:`UnitQuantity` instances which self-register.
137
+ * ``quantities/constants/`` — physical constants as :class:`UnitConstant`
138
+ objects (a subclass of :class:`UncertainQuantity`). The values come
139
+ from ``NIST_codata.txt``; ``_codata.py`` is auto-generated from that
140
+ file by ``python setup.py data``.
@@ -0,0 +1,13 @@
1
+ .. _development:
2
+
3
+ Development
4
+ ===========
5
+
6
+ Quantities development uses the principles of test-driven development. New
7
+ features or bug fixes need to be accompanied by unit tests, which can be run
8
+ with::
9
+
10
+ pytest
11
+
12
+ For a full walkthrough of setting up an environment, the project layout, and
13
+ submitting your first contribution, see :ref:`onboarding`.
@@ -7,6 +7,10 @@ Developer's Guide
7
7
  .. toctree::
8
8
  :maxdepth: 2
9
9
 
10
- documenting.rst
11
- devnotes.rst
10
+ onboarding
11
+ architecture
12
+ workflow
13
+ documenting
14
+ devnotes
12
15
  release
16
+ maintenance