TypedUnit 0.0.8__tar.gz → 0.2.4__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 (62) hide show
  1. typedunit-0.2.4/.coveragerc +22 -0
  2. {typedunit-0.0.8 → typedunit-0.2.4}/.github/dependabot.yml +1 -2
  3. typedunit-0.2.4/.github/workflows/deploy_PyPi.yml +18 -0
  4. typedunit-0.2.4/.github/workflows/deploy_anaconda.yml +21 -0
  5. typedunit-0.2.4/.github/workflows/deploy_coverage.yml +21 -0
  6. typedunit-0.2.4/.github/workflows/deploy_documentation.yml +58 -0
  7. typedunit-0.2.4/.github/workflows/quality.yml +22 -0
  8. typedunit-0.2.4/.github/workflows/tests.yml +26 -0
  9. {typedunit-0.0.8 → typedunit-0.2.4}/.gitignore +9 -1
  10. {typedunit-0.0.8 → typedunit-0.2.4}/.pre-commit-config.yaml +0 -2
  11. typedunit-0.2.4/CONTRIBUTING.md +7 -0
  12. typedunit-0.2.4/Makefile +15 -0
  13. {typedunit-0.0.8 → typedunit-0.2.4}/PKG-INFO +5 -5
  14. {typedunit-0.0.8 → typedunit-0.2.4}/README.rst +0 -2
  15. typedunit-0.2.4/TypedUnit/__init__.py +10 -0
  16. typedunit-0.2.4/TypedUnit/_version.py +24 -0
  17. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit/directories.py +10 -10
  18. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit/helper.py +19 -7
  19. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit/units.py +8 -8
  20. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit.egg-info/PKG-INFO +5 -5
  21. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit.egg-info/SOURCES.txt +16 -2
  22. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit.egg-info/requires.txt +3 -2
  23. typedunit-0.2.4/TypedUnit.egg-info/scm_file_list.json +50 -0
  24. typedunit-0.2.4/TypedUnit.egg-info/scm_version.json +8 -0
  25. {typedunit-0.0.8 → typedunit-0.2.4/conda.recipe}/meta.yaml +5 -5
  26. typedunit-0.2.4/docs/redirect.html +12 -0
  27. typedunit-0.2.4/docs/source/_static/favicon.svg +1 -0
  28. typedunit-0.2.4/docs/source/_static/layout.css +89 -0
  29. typedunit-0.2.4/docs/source/_static/logo.svg +1 -0
  30. typedunit-0.2.4/docs/source/conf.py +27 -0
  31. {typedunit-0.0.8 → typedunit-0.2.4}/pyproject.toml +10 -24
  32. typedunit-0.2.4/pytest.ini +21 -0
  33. {typedunit-0.0.8 → typedunit-0.2.4}/tests/test_0.py +197 -143
  34. typedunit-0.2.4/tools/next_release_version.py +33 -0
  35. typedunit-0.2.4/tools/release_tag.py +46 -0
  36. typedunit-0.0.8/.github/workflows/deploy_PyPi.yml +0 -20
  37. typedunit-0.0.8/.github/workflows/deploy_anaconda.yml +0 -21
  38. typedunit-0.0.8/.github/workflows/deploy_coverage.yml +0 -25
  39. typedunit-0.0.8/.github/workflows/deploy_documentation.yml +0 -24
  40. typedunit-0.0.8/TypedUnit/__init__.py +0 -10
  41. typedunit-0.0.8/TypedUnit/_version.py +0 -34
  42. typedunit-0.0.8/docs/source/conf.py +0 -167
  43. {typedunit-0.0.8 → typedunit-0.2.4}/.flake8 +0 -0
  44. {typedunit-0.0.8 → typedunit-0.2.4}/LICENSE +0 -0
  45. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit/utils.py +0 -0
  46. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit.egg-info/dependency_links.txt +0 -0
  47. {typedunit-0.0.8 → typedunit-0.2.4}/TypedUnit.egg-info/top_level.txt +0 -0
  48. {typedunit-0.0.8 → typedunit-0.2.4}/docs/Makefile +0 -0
  49. {typedunit-0.0.8 → typedunit-0.2.4}/docs/examples/README.rst +0 -0
  50. {typedunit-0.0.8 → typedunit-0.2.4}/docs/examples/example_0.py +0 -0
  51. {typedunit-0.0.8 → typedunit-0.2.4}/docs/examples/example_1.py +0 -0
  52. {typedunit-0.0.8 → typedunit-0.2.4}/docs/images/logo.png +0 -0
  53. {typedunit-0.0.8 → typedunit-0.2.4}/docs/make.bat +0 -0
  54. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/_static/default.css +0 -0
  55. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/_static/thumbnail.png +0 -0
  56. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/code.rst +0 -0
  57. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/index.rst +0 -0
  58. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/references.rst +0 -0
  59. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/sg_execution_times.rst +0 -0
  60. {typedunit-0.0.8 → typedunit-0.2.4}/docs/source/theory.rst +0 -0
  61. {typedunit-0.0.8 → typedunit-0.2.4}/setup.cfg +0 -0
  62. {typedunit-0.0.8 → typedunit-0.2.4}/tests/__init__.py +0 -0
@@ -0,0 +1,22 @@
1
+ # .coveragerc
2
+ [run]
3
+ source = TypedUnit
4
+ branch = True
5
+ relative_files = True
6
+ parallel = True
7
+ omit =
8
+ **/__init__.py
9
+ TypedUnit/_version.py
10
+ TypedUnit/directories.py
11
+ TypedUnit/**/__main__.py
12
+
13
+ [report]
14
+ skip_covered = True
15
+ show_missing = True
16
+ precision = 2
17
+
18
+ [html]
19
+ directory = htmlcov
20
+
21
+ [xml]
22
+ output = coverage.xml
@@ -6,6 +6,5 @@ updates:
6
6
  directory: "/"
7
7
  target-branch: "master"
8
8
  schedule:
9
- interval: "monthly"
10
- day: "sunday"
9
+ interval: "quarterly"
11
10
  time: "09:00"
@@ -0,0 +1,18 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ publish:
12
+ uses: MartinPdeS/MPSActions/.github/workflows/publish_pure_package_to_PyPi.yml@a01969bc5af90666281f9d37acffdf6a4629763a
13
+ with:
14
+ python-version: "3.11"
15
+ # The reusable workflow wraps this command in double quotes.
16
+ test-command: python -c 'import TypedUnit; print(TypedUnit.__version__)'
17
+ secrets:
18
+ PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: Publish Conda package
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ permissions:
8
+ contents: read
9
+
10
+ jobs:
11
+ publish:
12
+ uses: MartinPdeS/MPSActions/.github/workflows/publish_compiled_package_to_anaconda.yml@a01969bc5af90666281f9d37acffdf6a4629763a
13
+ with:
14
+ # One noarch archive supports all declared Python versions; test it on 3.14.
15
+ python_versions: '["3.14"]'
16
+ os_list: '["ubuntu-latest"]'
17
+ package_name: typedunit
18
+ recipe_path: conda.recipe
19
+ test_import: TypedUnit
20
+ secrets:
21
+ ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
@@ -0,0 +1,21 @@
1
+ name: Publish coverage
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ permissions:
10
+ contents: write
11
+ pull-requests: write
12
+
13
+ jobs:
14
+ coverage:
15
+ uses: MartinPdeS/MPSActions/.github/workflows/publish_coverage.yml@a01969bc5af90666281f9d37acffdf6a4629763a
16
+ with:
17
+ python-version: "3.11"
18
+ apt-package: xvfb
19
+ coverage-package: TypedUnit
20
+ secrets:
21
+ _GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,58 @@
1
+ name: Publish documentation
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ tags: ["v*"]
7
+
8
+ permissions:
9
+ contents: write
10
+ pages: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ documentation:
15
+ uses: MartinPdeS/MPSActions/.github/workflows/publish_documentation.yml@a01969bc5af90666281f9d37acffdf6a4629763a
16
+ with:
17
+ python-version: "3.11"
18
+ package-name: TypedUnit
19
+ apt-package: xvfb jq
20
+
21
+ maintain_documentation:
22
+ needs: documentation
23
+ if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
24
+ runs-on: ubuntu-latest
25
+ steps:
26
+ - name: Install documentation landing page
27
+ uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
28
+ with:
29
+ ref: documentation_page
30
+ fetch-depth: 0
31
+ - run: |
32
+ set -Eeuo pipefail
33
+ git show "${GITHUB_SHA}:docs/redirect.html" > index.html
34
+ test -s docs/latest/index.html
35
+ git config user.name "github-actions[bot]"
36
+ git config user.email "github-actions[bot]@users.noreply.github.com"
37
+ git add index.html
38
+ if git diff --cached --quiet; then exit 0; fi
39
+ git commit -m "Update documentation landing page [skip ci]"
40
+ git push origin HEAD:documentation_page
41
+
42
+ publish_pages:
43
+ needs: maintain_documentation
44
+ if: ${{ github.event_name == 'push' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/v')) }}
45
+ runs-on: ubuntu-latest
46
+ environment:
47
+ name: github-pages
48
+ url: ${{ steps.deployment.outputs.page_url }}
49
+ steps:
50
+ - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09
51
+ with:
52
+ ref: documentation_page
53
+ - uses: actions/configure-pages@v5
54
+ - uses: actions/upload-pages-artifact@v3
55
+ with:
56
+ path: .
57
+ - id: deployment
58
+ uses: actions/deploy-pages@v4
@@ -0,0 +1,22 @@
1
+ name: Static quality checks
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ quality:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - name: Set up Python and CI dependencies
17
+ uses: MartinPdeS/MPSActions/actions/setup-python@a01969bc5af90666281f9d37acffdf6a4629763a
18
+ with:
19
+ python-version: "3.11"
20
+ install-command: >-
21
+ python -m pip install --upgrade pip && python -m pip install "ruff>=0.6,<1"
22
+ - run: python -m ruff check TypedUnit tests
@@ -0,0 +1,26 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+ pull_request:
7
+ branches: [master]
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ tests:
14
+ runs-on: ubuntu-latest
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ python-version: ["3.11", "3.14"]
19
+ steps:
20
+ - name: Set up Python and CI dependencies
21
+ uses: MartinPdeS/MPSActions/actions/setup-python@a01969bc5af90666281f9d37acffdf6a4629763a
22
+ with:
23
+ python-version: "${{ matrix.python-version }}"
24
+ install-command: >-
25
+ python -m pip install --upgrade pip && python -m pip install -e ".[testing]"
26
+ - run: python -m pytest -q
@@ -14,11 +14,18 @@
14
14
  !.gitignore
15
15
  !.pre-commit-config.yaml
16
16
  !LICENSE
17
- !meta.yaml
17
+ !conda.recipe
18
+ !conda.recipe/meta.yaml
18
19
  !pyproject.toml
19
20
  !README.rst
21
+ !CONTRIBUTING.md
22
+ !/Makefile
23
+ !tools
24
+ !tools/*.py
20
25
  !notebook.ipynb
21
26
  !CMakeLists.txt
27
+ !pytest.ini
28
+ !.coveragerc
22
29
 
23
30
  # But ignore docs/build inside docs and code
24
31
  docs/build/
@@ -29,5 +36,6 @@ docs/source/gallery/
29
36
  *.DS_Store*
30
37
  *.so*
31
38
  *.a*
39
+ !Makefile
32
40
 
33
41
  # Package specifics
@@ -5,8 +5,6 @@ repos:
5
5
  - id: check-merge-conflict
6
6
  - id: end-of-file-fixer
7
7
  - id: mixed-line-ending
8
- - id: check-yaml
9
- - id: check-toml
10
8
  - id: detect-private-key
11
9
  - id: check-json
12
10
  - id: check-case-conflict
@@ -0,0 +1,7 @@
1
+ # Contributing to TypedUnit
2
+
3
+ Use Python 3.10 or newer. Install development dependencies with `python -m pip install -e ".[testing,documentation]"`, then run `python -m pytest`.
4
+
5
+ Releases use semantic version tags. Run `make patch`, `make minor`, or `make major` from a clean `master` checkout; the command creates the release commit, tags it, and pushes both. Publishing workflows run only for `v*` tags.
6
+
7
+ The Conda recipe is at `conda.recipe/meta.yaml`. Do not commit generated documentation, virtual environments, build artefacts, or caches.
@@ -0,0 +1,15 @@
1
+ PYTHON ?= python3
2
+
3
+ .PHONY: release tag patch minor major
4
+
5
+ release:
6
+ @set -eu; release_tag="$$( $(PYTHON) tools/next_release_version.py $(BUMP) )"; \
7
+ $(PYTHON) tools/release_tag.py "$$release_tag"; \
8
+ git push origin HEAD "refs/tags/$$release_tag"
9
+
10
+ tag:
11
+ @set -eu; release_tag="$$( $(PYTHON) tools/next_release_version.py $(BUMP) )"; \
12
+ $(PYTHON) tools/release_tag.py "$$release_tag"
13
+
14
+ patch minor major:
15
+ @$(MAKE) release BUMP=$@
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TypedUnit
3
- Version: 0.0.8
3
+ Version: 0.2.4
4
4
  Summary: A package wrapping pint for handling typed units in Python.
5
5
  Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
6
  License: MIT License
@@ -33,6 +33,7 @@ Classifier: Programming Language :: Python
33
33
  Classifier: Programming Language :: Python :: 3
34
34
  Classifier: Programming Language :: Python :: 3.11
35
35
  Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.14
36
37
  Classifier: Programming Language :: Python :: Implementation :: CPython
37
38
  Classifier: Development Status :: 4 - Beta
38
39
  Classifier: Topic :: Scientific/Engineering :: Physics
@@ -41,17 +42,18 @@ Classifier: Intended Audience :: Science/Research
41
42
  Requires-Python: >=3.10
42
43
  Description-Content-Type: text/x-rst
43
44
  License-File: LICENSE
44
- Requires-Dist: pint
45
+ Requires-Dist: pint<0.26,>=0.24
45
46
  Requires-Dist: numpy
46
47
  Requires-Dist: matplotlib
47
48
  Requires-Dist: pint_pandas
48
49
  Provides-Extra: testing
49
- Requires-Dist: pytest<9.0,>=7.4; extra == "testing"
50
+ Requires-Dist: pytest<10.0,>=7.4; extra == "testing"
50
51
  Requires-Dist: pytest-cov<7,>=2; extra == "testing"
51
52
  Requires-Dist: pytest-json-report~=1.5; extra == "testing"
52
53
  Requires-Dist: flake8==7.3.0; extra == "testing"
53
54
  Requires-Dist: coverage~=7.6; extra == "testing"
54
55
  Provides-Extra: documentation
56
+ Requires-Dist: MartinPdeS-docs<0.2,>=0.1.4; extra == "documentation"
55
57
  Requires-Dist: numpydoc~=1.8; extra == "documentation"
56
58
  Requires-Dist: sphinx>=6; extra == "documentation"
57
59
  Requires-Dist: sphinx-gallery~=0.17; extra == "documentation"
@@ -240,8 +242,6 @@ TypedUnits is open source and contributions are welcome! Whether you're fixing b
240
242
 
241
243
  **Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=TypedUnits>`_
242
244
 
243
- ----
244
-
245
245
  .. |python| image:: https://img.shields.io/pypi/pyversions/typedunits.svg
246
246
  :target: https://www.python.org/
247
247
  :alt: Python version
@@ -179,8 +179,6 @@ TypedUnits is open source and contributions are welcome! Whether you're fixing b
179
179
 
180
180
  **Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=TypedUnits>`_
181
181
 
182
- ----
183
-
184
182
  .. |python| image:: https://img.shields.io/pypi/pyversions/typedunits.svg
185
183
  :target: https://www.python.org/
186
184
  :alt: Python version
@@ -0,0 +1,10 @@
1
+ try:
2
+ from ._version import __version__ as __version__
3
+
4
+ except ImportError:
5
+ __version__ = "0.0.0"
6
+
7
+ from TypedUnit.helper import validate_units as validate_units
8
+ from TypedUnit.units import * # noqa: F403 -- Re-export the unit module's public types.
9
+ from TypedUnit.units import Quantity as Quantity
10
+ from TypedUnit.units import ureg as ureg
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.2.4'
22
+ __version_tuple__ = version_tuple = (0, 2, 4)
23
+
24
+ __commit_id__ = commit_id = 'g8caa1b260'
@@ -2,30 +2,30 @@
2
2
  # -*- coding: utf-8 -*-
3
3
 
4
4
  from pathlib import Path
5
- import TypedUnit
6
5
 
6
+ import TypedUnit
7
7
 
8
8
  __all__ = [
9
- 'root_path',
10
- 'project_path',
11
- 'doc_path',
12
- 'doc_css_path',
9
+ "root_path",
10
+ "project_path",
11
+ "doc_path",
12
+ "doc_css_path",
13
13
  ]
14
14
 
15
15
  root_path = Path(TypedUnit.__path__[0])
16
16
 
17
17
  project_path = root_path.parents[0]
18
18
 
19
- example_directory = root_path.joinpath('examples')
19
+ example_directory = root_path.joinpath("examples")
20
20
 
21
- doc_path = project_path.joinpath('docs')
21
+ doc_path = project_path.joinpath("docs")
22
22
 
23
- examples_path = project_path.joinpath('docs/examples')
23
+ examples_path = project_path.joinpath("docs/examples")
24
24
 
25
- doc_css_path = doc_path.joinpath('source/_static/default.css')
25
+ doc_css_path = doc_path.joinpath("source/_static/default.css")
26
26
 
27
27
 
28
- if __name__ == '__main__':
28
+ if __name__ == "__main__":
29
29
  for path_name in __all__:
30
30
  path = locals()[path_name]
31
31
  print(path)
@@ -1,6 +1,8 @@
1
- from TypedUnit.units import BaseUnit
2
- from typing import get_type_hints, get_origin, get_args, Union
3
1
  import inspect
2
+ from typing import Union, get_args, get_origin, get_type_hints
3
+
4
+ from TypedUnit.units import BaseUnit
5
+
4
6
 
5
7
  def _get_unit_type(hint):
6
8
  """Extract BaseUnit type from hint, handling Optional and List."""
@@ -14,16 +16,25 @@ def _get_unit_type(hint):
14
16
  if origin is Union:
15
17
  # Handle Optional[BaseUnit] (Union[BaseUnit, None])
16
18
  unit_types = [arg for arg in args if arg is not type(None)]
17
- if len(unit_types) == 1 and inspect.isclass(unit_types[0]) and issubclass(unit_types[0], BaseUnit):
19
+ if (
20
+ len(unit_types) == 1
21
+ and inspect.isclass(unit_types[0])
22
+ and issubclass(unit_types[0], BaseUnit)
23
+ ):
18
24
  return unit_types[0], True, False # Optional BaseUnit
19
25
 
20
26
  elif origin in (list, tuple):
21
27
  # Handle List[BaseUnit] or Tuple[BaseUnit]
22
- if len(args) == 1 and inspect.isclass(args[0]) and issubclass(args[0], BaseUnit):
28
+ if (
29
+ len(args) == 1
30
+ and inspect.isclass(args[0])
31
+ and issubclass(args[0], BaseUnit)
32
+ ):
23
33
  return args[0], False, True # List of BaseUnit
24
34
 
25
35
  return None, False, False
26
36
 
37
+
27
38
  def validate_units(function):
28
39
  def wrapper(*args, **kwargs):
29
40
  hints = get_type_hints(function)
@@ -55,13 +66,14 @@ def validate_units(function):
55
66
  try:
56
67
  unit_type.check(item)
57
68
  except (AssertionError, ValueError) as e:
58
- raise ValueError(f"Parameter '{param_name}[{i}]': {e}")
69
+ raise ValueError(f"Parameter '{param_name}[{i}]': {e}") from e
59
70
  else:
60
71
  # Handle single values
61
72
  try:
62
73
  unit_type.check(value)
63
74
  except (AssertionError, ValueError) as e:
64
- raise ValueError(f"Parameter '{param_name}': {e}")
75
+ raise ValueError(f"Parameter '{param_name}': {e}") from e
65
76
 
66
77
  return function(*args, **kwargs)
67
- return wrapper
78
+
79
+ return wrapper
@@ -1,9 +1,9 @@
1
1
  # Initialize a unit registry
2
2
  import pint as _pint
3
+ import pint_pandas as pint # noqa: F401 -- Registers the pandas Pint extension.
3
4
  from pint import Quantity, UnitRegistry
4
- import pint_pandas as pint
5
5
 
6
- ureg = UnitRegistry()
6
+ ureg = UnitRegistry(autoconvert_offset_to_baseunit=True)
7
7
  ureg.setup_matplotlib()
8
8
 
9
9
  _pint.set_application_registry(ureg)
@@ -12,6 +12,8 @@ ureg.define("photoelectron = [Float64]") # Define a custom unit 'photoelectron'
12
12
  ureg.define("event = [Int64]") # Define a custom unit 'events'
13
13
  ureg.define("sqrt_hertz = Hz**0.5")
14
14
  ureg.define("bit_bins = ![Int64]")
15
+ ureg.define("dB_per_Hz = dB / hertz")
16
+
15
17
 
16
18
  __all__ = [
17
19
  "Energy",
@@ -63,7 +65,7 @@ class UnitMeta(type):
63
65
  num = cls.__name__
64
66
  den = other.__name__
65
67
  name = f"{num}Per{den}"
66
- expected = f"{getattr(cls, '_expected_dim')}/{getattr(other, '_expected_dim')}"
68
+ expected = f"{cls._expected_dim}/{other._expected_dim}"
67
69
  # Create a new subclass that uses the same metaclass
68
70
  return UnitMeta(name, (BaseUnit,), {"_expected_dim": expected})
69
71
 
@@ -74,16 +76,14 @@ class UnitMeta(type):
74
76
  a = cls.__name__
75
77
  b = other.__name__
76
78
  name = f"{a}Times{b}"
77
- expected = (
78
- f"({getattr(cls, '_expected_dim')})*({getattr(other, '_expected_dim')})"
79
- )
79
+ expected = f"({cls._expected_dim})*({other._expected_dim})"
80
80
  return UnitMeta(name, (BaseUnit,), {"_expected_dim": expected})
81
81
 
82
82
  def __pow__(cls, power):
83
83
  if not isinstance(power, int):
84
84
  return NotImplemented
85
85
  name = f"{cls.__name__}Pow{power}"
86
- expected = f"({getattr(cls, '_expected_dim')})**{power}"
86
+ expected = f"({cls._expected_dim})**{power}"
87
87
  return UnitMeta(name, (BaseUnit,), {"_expected_dim": expected})
88
88
 
89
89
 
@@ -96,7 +96,7 @@ class BaseUnit(metaclass=UnitMeta):
96
96
  return value
97
97
  assert isinstance(
98
98
  value, Quantity
99
- ), f"Expected a pint Quantity instance, got {type(value)}"
99
+ ), f"Expected a pint Quantity [{cls._expected_dim}] instance, got {type(value)}"
100
100
  assert value.check(
101
101
  cls._expected_dim
102
102
  ), f"Value units {value.dimensionality} do not match {cls.__name__} units"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: TypedUnit
3
- Version: 0.0.8
3
+ Version: 0.2.4
4
4
  Summary: A package wrapping pint for handling typed units in Python.
5
5
  Author-email: Martin Poinsinet de Sivry-Houle <martin.poinsinet.de.sivry@gmail.com>
6
6
  License: MIT License
@@ -33,6 +33,7 @@ Classifier: Programming Language :: Python
33
33
  Classifier: Programming Language :: Python :: 3
34
34
  Classifier: Programming Language :: Python :: 3.11
35
35
  Classifier: Programming Language :: Python :: 3.12
36
+ Classifier: Programming Language :: Python :: 3.14
36
37
  Classifier: Programming Language :: Python :: Implementation :: CPython
37
38
  Classifier: Development Status :: 4 - Beta
38
39
  Classifier: Topic :: Scientific/Engineering :: Physics
@@ -41,17 +42,18 @@ Classifier: Intended Audience :: Science/Research
41
42
  Requires-Python: >=3.10
42
43
  Description-Content-Type: text/x-rst
43
44
  License-File: LICENSE
44
- Requires-Dist: pint
45
+ Requires-Dist: pint<0.26,>=0.24
45
46
  Requires-Dist: numpy
46
47
  Requires-Dist: matplotlib
47
48
  Requires-Dist: pint_pandas
48
49
  Provides-Extra: testing
49
- Requires-Dist: pytest<9.0,>=7.4; extra == "testing"
50
+ Requires-Dist: pytest<10.0,>=7.4; extra == "testing"
50
51
  Requires-Dist: pytest-cov<7,>=2; extra == "testing"
51
52
  Requires-Dist: pytest-json-report~=1.5; extra == "testing"
52
53
  Requires-Dist: flake8==7.3.0; extra == "testing"
53
54
  Requires-Dist: coverage~=7.6; extra == "testing"
54
55
  Provides-Extra: documentation
56
+ Requires-Dist: MartinPdeS-docs<0.2,>=0.1.4; extra == "documentation"
55
57
  Requires-Dist: numpydoc~=1.8; extra == "documentation"
56
58
  Requires-Dist: sphinx>=6; extra == "documentation"
57
59
  Requires-Dist: sphinx-gallery~=0.17; extra == "documentation"
@@ -240,8 +242,6 @@ TypedUnits is open source and contributions are welcome! Whether you're fixing b
240
242
 
241
243
  **Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=TypedUnits>`_
242
244
 
243
- ----
244
-
245
245
  .. |python| image:: https://img.shields.io/pypi/pyversions/typedunits.svg
246
246
  :target: https://www.python.org/
247
247
  :alt: Python version
@@ -1,15 +1,20 @@
1
+ .coveragerc
1
2
  .flake8
2
3
  .gitignore
3
4
  .pre-commit-config.yaml
5
+ CONTRIBUTING.md
4
6
  LICENSE
7
+ Makefile
5
8
  README.rst
6
- meta.yaml
7
9
  pyproject.toml
10
+ pytest.ini
8
11
  .github/dependabot.yml
9
12
  .github/workflows/deploy_PyPi.yml
10
13
  .github/workflows/deploy_anaconda.yml
11
14
  .github/workflows/deploy_coverage.yml
12
15
  .github/workflows/deploy_documentation.yml
16
+ .github/workflows/quality.yml
17
+ .github/workflows/tests.yml
13
18
  TypedUnit/__init__.py
14
19
  TypedUnit/_version.py
15
20
  TypedUnit/directories.py
@@ -20,9 +25,13 @@ TypedUnit.egg-info/PKG-INFO
20
25
  TypedUnit.egg-info/SOURCES.txt
21
26
  TypedUnit.egg-info/dependency_links.txt
22
27
  TypedUnit.egg-info/requires.txt
28
+ TypedUnit.egg-info/scm_file_list.json
29
+ TypedUnit.egg-info/scm_version.json
23
30
  TypedUnit.egg-info/top_level.txt
31
+ conda.recipe/meta.yaml
24
32
  docs/Makefile
25
33
  docs/make.bat
34
+ docs/redirect.html
26
35
  docs/examples/README.rst
27
36
  docs/examples/example_0.py
28
37
  docs/examples/example_1.py
@@ -34,6 +43,11 @@ docs/source/references.rst
34
43
  docs/source/sg_execution_times.rst
35
44
  docs/source/theory.rst
36
45
  docs/source/_static/default.css
46
+ docs/source/_static/favicon.svg
47
+ docs/source/_static/layout.css
48
+ docs/source/_static/logo.svg
37
49
  docs/source/_static/thumbnail.png
38
50
  tests/__init__.py
39
- tests/test_0.py
51
+ tests/test_0.py
52
+ tools/next_release_version.py
53
+ tools/release_tag.py
@@ -1,9 +1,10 @@
1
- pint
1
+ pint<0.26,>=0.24
2
2
  numpy
3
3
  matplotlib
4
4
  pint_pandas
5
5
 
6
6
  [documentation]
7
+ MartinPdeS-docs<0.2,>=0.1.4
7
8
  numpydoc~=1.8
8
9
  sphinx>=6
9
10
  sphinx-gallery~=0.17
@@ -11,7 +12,7 @@ sphinx-rtd-theme<4,>=2
11
12
  pydata-sphinx-theme~=0.15
12
13
 
13
14
  [testing]
14
- pytest<9.0,>=7.4
15
+ pytest<10.0,>=7.4
15
16
  pytest-cov<7,>=2
16
17
  pytest-json-report~=1.5
17
18
  flake8==7.3.0