TypedUnit 0.2.7__tar.gz → 0.2.8__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.
- {typedunit-0.2.7 → typedunit-0.2.8}/PKG-INFO +60 -27
- {typedunit-0.2.7 → typedunit-0.2.8}/README.rst +59 -26
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit/_version.py +3 -3
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/PKG-INFO +60 -27
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/scm_version.json +2 -2
- {typedunit-0.2.7 → typedunit-0.2.8}/.coveragerc +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.flake8 +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/dependabot.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/workflows/deploy_PyPi.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/workflows/deploy_anaconda.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/workflows/deploy_coverage.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/workflows/deploy_documentation.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/workflows/quality.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.github/workflows/tests.yml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.gitignore +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/.pre-commit-config.yaml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/CONTRIBUTING.md +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/LICENSE +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/Makefile +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit/__init__.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit/directories.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit/helper.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit/units.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit/utils.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/SOURCES.txt +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/dependency_links.txt +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/requires.txt +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/scm_file_list.json +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/TypedUnit.egg-info/top_level.txt +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/conda.recipe/meta.yaml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/Makefile +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/examples/README.rst +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/examples/example_0.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/examples/example_1.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/images/logo.png +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/make.bat +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/redirect.html +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/_static/default.css +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/_static/favicon.svg +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/_static/layout.css +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/_static/logo.svg +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/_static/thumbnail.png +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/code.rst +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/conf.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/index.rst +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/references.rst +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/sg_execution_times.rst +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/docs/source/theory.rst +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/pyproject.toml +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/pytest.ini +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/setup.cfg +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/tests/__init__.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/tests/test_0.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/tools/next_release_version.py +0 -0
- {typedunit-0.2.7 → typedunit-0.2.8}/tools/release_tag.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: TypedUnit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
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
|
|
@@ -61,14 +61,35 @@ Requires-Dist: sphinx-rtd-theme<4,>=2; extra == "documentation"
|
|
|
61
61
|
Requires-Dist: pydata-sphinx-theme~=0.15; extra == "documentation"
|
|
62
62
|
Dynamic: license-file
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
TypedUnit
|
|
65
65
|
===========
|
|
66
66
|
|
|
67
|
-
|
|
|
67
|
+
|logo|
|
|
68
|
+
|
|
69
|
+
.. list-table::
|
|
70
|
+
:widths: 35 65
|
|
71
|
+
:header-rows: 1
|
|
72
|
+
|
|
73
|
+
* - Badge
|
|
74
|
+
- Status
|
|
75
|
+
* - Python versions
|
|
76
|
+
- |python|
|
|
77
|
+
* - Documentation
|
|
78
|
+
- |docs|
|
|
79
|
+
* - Continuous integration
|
|
80
|
+
- |ci/cd|
|
|
81
|
+
* - Test coverage
|
|
82
|
+
- |coverage|
|
|
83
|
+
* - PyPI package
|
|
84
|
+
- |PyPI|
|
|
85
|
+
* - PyPI downloads
|
|
86
|
+
- |PyPI_download|
|
|
87
|
+
* - Anaconda package
|
|
88
|
+
- |anaconda|
|
|
68
89
|
|
|
69
90
|
**Type-safe physical units for Python**
|
|
70
91
|
|
|
71
|
-
|
|
92
|
+
TypedUnit is a Python library that extends Pint with type safety and validation capabilities. It allows you to create unit-aware types that work seamlessly with Python's type system and provide runtime validation for physical quantities.
|
|
72
93
|
|
|
73
94
|
**Key Features:**
|
|
74
95
|
|
|
@@ -83,7 +104,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
83
104
|
|
|
84
105
|
.. code-block:: python
|
|
85
106
|
|
|
86
|
-
from
|
|
107
|
+
from TypedUnit import Energy, Time, Power, validate, ureg
|
|
87
108
|
|
|
88
109
|
# Normal Pint instantiation
|
|
89
110
|
energy = 100 * ureg.joule
|
|
@@ -112,7 +133,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
112
133
|
|
|
113
134
|
.. code-block:: bash
|
|
114
135
|
|
|
115
|
-
pip install
|
|
136
|
+
pip install TypedUnit
|
|
116
137
|
|
|
117
138
|
----
|
|
118
139
|
|
|
@@ -122,7 +143,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
122
143
|
|
|
123
144
|
.. code-block:: python
|
|
124
145
|
|
|
125
|
-
from
|
|
146
|
+
from TypedUnit import Energy, Length, Mass, ureg
|
|
126
147
|
|
|
127
148
|
# Create quantities the normal way
|
|
128
149
|
kinetic_energy = 0.5 * 10 * ureg.kilogram * (5 * ureg.meter / ureg.second)**2
|
|
@@ -140,7 +161,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
140
161
|
|
|
141
162
|
.. code-block:: python
|
|
142
163
|
|
|
143
|
-
from
|
|
164
|
+
from TypedUnit import validate_units, Energy, Time, Power
|
|
144
165
|
|
|
145
166
|
@validate_units
|
|
146
167
|
def calculate_work(power: Power, time: Time) -> Energy:
|
|
@@ -156,7 +177,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
156
177
|
|
|
157
178
|
.. code-block:: python
|
|
158
179
|
|
|
159
|
-
from
|
|
180
|
+
from TypedUnit import Energy, Length, Mass
|
|
160
181
|
from pydantic.dataclasses import dataclass
|
|
161
182
|
|
|
162
183
|
@dataclass
|
|
@@ -176,7 +197,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
176
197
|
|
|
177
198
|
**Available Unit Types**
|
|
178
199
|
|
|
179
|
-
|
|
200
|
+
TypedUnit includes common physical unit types:
|
|
180
201
|
|
|
181
202
|
- **Mechanical**: `Energy`, `Power`, `Force`, `Pressure`
|
|
182
203
|
- **Spatial**: `Length`, `Area`, `Volume`, `Angle`
|
|
@@ -194,7 +215,7 @@ TypedUnits includes common physical unit types:
|
|
|
194
215
|
|
|
195
216
|
.. code-block:: python
|
|
196
217
|
|
|
197
|
-
from
|
|
218
|
+
from TypedUnit import create_unit_type
|
|
198
219
|
|
|
199
220
|
# Create your own unit types
|
|
200
221
|
MagneticField = create_unit_type('MagneticField', '[magnetic_flux_density]')
|
|
@@ -206,7 +227,7 @@ TypedUnits includes common physical unit types:
|
|
|
206
227
|
|
|
207
228
|
.. code-block:: python
|
|
208
229
|
|
|
209
|
-
from
|
|
230
|
+
from TypedUnit import validate_enhanced
|
|
210
231
|
|
|
211
232
|
@validate_enhanced(strict_mode=False, convert_types=True)
|
|
212
233
|
def flexible_function(energy: Energy, count: int) -> str:
|
|
@@ -227,8 +248,8 @@ TypedUnits includes common physical unit types:
|
|
|
227
248
|
|
|
228
249
|
.. code-block:: bash
|
|
229
250
|
|
|
230
|
-
git clone https://github.com/MartinPdeS/
|
|
231
|
-
cd
|
|
251
|
+
git clone https://github.com/MartinPdeS/TypedUnit.git
|
|
252
|
+
cd TypedUnit
|
|
232
253
|
pip install -e ".[testing]"
|
|
233
254
|
pytest
|
|
234
255
|
|
|
@@ -236,28 +257,40 @@ TypedUnits includes common physical unit types:
|
|
|
236
257
|
|
|
237
258
|
**Contributing**
|
|
238
259
|
|
|
239
|
-
|
|
260
|
+
TypedUnit is open source and contributions are welcome! Whether you're fixing bugs, adding new unit types, or improving documentation, your help is appreciated.
|
|
240
261
|
|
|
241
262
|
**Author:** `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdeS>`_
|
|
242
263
|
|
|
243
|
-
**Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=
|
|
264
|
+
**Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=TypedUnit>`_
|
|
244
265
|
|
|
245
|
-
.. |
|
|
266
|
+
.. |logo| image:: https://github.com/MartinPdeS/TypedUnit/raw/master/docs/images/logo.png
|
|
267
|
+
:target: https://github.com/MartinPdeS/TypedUnit
|
|
268
|
+
:alt: TypedUnit logo
|
|
269
|
+
|
|
270
|
+
.. |python| image:: https://img.shields.io/pypi/pyversions/typedunit.svg
|
|
246
271
|
:target: https://www.python.org/
|
|
247
272
|
:alt: Python version
|
|
248
273
|
|
|
249
|
-
.. |
|
|
250
|
-
:target: https://pypi.org/project/
|
|
251
|
-
:alt:
|
|
274
|
+
.. |PyPI| image:: https://badge.fury.io/py/typedunit.svg
|
|
275
|
+
:target: https://pypi.org/project/typedunit/
|
|
276
|
+
:alt: PyPI
|
|
252
277
|
|
|
253
|
-
.. |PyPi_download| image:: https://img.shields.io/pypi/dm/
|
|
254
|
-
:target: https://pypistats.org/packages/
|
|
255
|
-
:alt:
|
|
278
|
+
.. |PyPi_download| image:: https://img.shields.io/pypi/dm/typedunit.svg
|
|
279
|
+
:target: https://pypistats.org/packages/typedunit
|
|
280
|
+
:alt: PyPI download statistics
|
|
256
281
|
|
|
257
|
-
.. |docs| image:: https://github.com/
|
|
258
|
-
:target: https://martinpdes.github.io/
|
|
282
|
+
.. |docs| image:: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_documentation.yml/badge.svg
|
|
283
|
+
:target: https://martinpdes.github.io/TypedUnit/
|
|
259
284
|
:alt: Documentation Status
|
|
260
285
|
|
|
261
|
-
.. |
|
|
262
|
-
:target: https://
|
|
286
|
+
.. |ci/cd| image:: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_coverage.yml/badge.svg
|
|
287
|
+
:target: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_coverage.yml
|
|
288
|
+
:alt: Continuous integration status
|
|
289
|
+
|
|
290
|
+
.. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/TypedUnit/python-coverage-comment-action-data/badge.svg
|
|
291
|
+
:target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/TypedUnit/blob/python-coverage-comment-action-data/htmlcov/index.html
|
|
263
292
|
:alt: Unittest coverage
|
|
293
|
+
|
|
294
|
+
.. |anaconda| image:: https://anaconda.org/martinpdes/typedunit/badges/version.svg
|
|
295
|
+
:target: https://anaconda.org/martinpdes/typedunit
|
|
296
|
+
:alt: Anaconda package
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
TypedUnit
|
|
2
2
|
===========
|
|
3
3
|
|
|
4
|
-
|
|
|
4
|
+
|logo|
|
|
5
|
+
|
|
6
|
+
.. list-table::
|
|
7
|
+
:widths: 35 65
|
|
8
|
+
:header-rows: 1
|
|
9
|
+
|
|
10
|
+
* - Badge
|
|
11
|
+
- Status
|
|
12
|
+
* - Python versions
|
|
13
|
+
- |python|
|
|
14
|
+
* - Documentation
|
|
15
|
+
- |docs|
|
|
16
|
+
* - Continuous integration
|
|
17
|
+
- |ci/cd|
|
|
18
|
+
* - Test coverage
|
|
19
|
+
- |coverage|
|
|
20
|
+
* - PyPI package
|
|
21
|
+
- |PyPI|
|
|
22
|
+
* - PyPI downloads
|
|
23
|
+
- |PyPI_download|
|
|
24
|
+
* - Anaconda package
|
|
25
|
+
- |anaconda|
|
|
5
26
|
|
|
6
27
|
**Type-safe physical units for Python**
|
|
7
28
|
|
|
8
|
-
|
|
29
|
+
TypedUnit is a Python library that extends Pint with type safety and validation capabilities. It allows you to create unit-aware types that work seamlessly with Python's type system and provide runtime validation for physical quantities.
|
|
9
30
|
|
|
10
31
|
**Key Features:**
|
|
11
32
|
|
|
@@ -20,7 +41,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
20
41
|
|
|
21
42
|
.. code-block:: python
|
|
22
43
|
|
|
23
|
-
from
|
|
44
|
+
from TypedUnit import Energy, Time, Power, validate, ureg
|
|
24
45
|
|
|
25
46
|
# Normal Pint instantiation
|
|
26
47
|
energy = 100 * ureg.joule
|
|
@@ -49,7 +70,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
49
70
|
|
|
50
71
|
.. code-block:: bash
|
|
51
72
|
|
|
52
|
-
pip install
|
|
73
|
+
pip install TypedUnit
|
|
53
74
|
|
|
54
75
|
----
|
|
55
76
|
|
|
@@ -59,7 +80,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
59
80
|
|
|
60
81
|
.. code-block:: python
|
|
61
82
|
|
|
62
|
-
from
|
|
83
|
+
from TypedUnit import Energy, Length, Mass, ureg
|
|
63
84
|
|
|
64
85
|
# Create quantities the normal way
|
|
65
86
|
kinetic_energy = 0.5 * 10 * ureg.kilogram * (5 * ureg.meter / ureg.second)**2
|
|
@@ -77,7 +98,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
77
98
|
|
|
78
99
|
.. code-block:: python
|
|
79
100
|
|
|
80
|
-
from
|
|
101
|
+
from TypedUnit import validate_units, Energy, Time, Power
|
|
81
102
|
|
|
82
103
|
@validate_units
|
|
83
104
|
def calculate_work(power: Power, time: Time) -> Energy:
|
|
@@ -93,7 +114,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
93
114
|
|
|
94
115
|
.. code-block:: python
|
|
95
116
|
|
|
96
|
-
from
|
|
117
|
+
from TypedUnit import Energy, Length, Mass
|
|
97
118
|
from pydantic.dataclasses import dataclass
|
|
98
119
|
|
|
99
120
|
@dataclass
|
|
@@ -113,7 +134,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
113
134
|
|
|
114
135
|
**Available Unit Types**
|
|
115
136
|
|
|
116
|
-
|
|
137
|
+
TypedUnit includes common physical unit types:
|
|
117
138
|
|
|
118
139
|
- **Mechanical**: `Energy`, `Power`, `Force`, `Pressure`
|
|
119
140
|
- **Spatial**: `Length`, `Area`, `Volume`, `Angle`
|
|
@@ -131,7 +152,7 @@ TypedUnits includes common physical unit types:
|
|
|
131
152
|
|
|
132
153
|
.. code-block:: python
|
|
133
154
|
|
|
134
|
-
from
|
|
155
|
+
from TypedUnit import create_unit_type
|
|
135
156
|
|
|
136
157
|
# Create your own unit types
|
|
137
158
|
MagneticField = create_unit_type('MagneticField', '[magnetic_flux_density]')
|
|
@@ -143,7 +164,7 @@ TypedUnits includes common physical unit types:
|
|
|
143
164
|
|
|
144
165
|
.. code-block:: python
|
|
145
166
|
|
|
146
|
-
from
|
|
167
|
+
from TypedUnit import validate_enhanced
|
|
147
168
|
|
|
148
169
|
@validate_enhanced(strict_mode=False, convert_types=True)
|
|
149
170
|
def flexible_function(energy: Energy, count: int) -> str:
|
|
@@ -164,8 +185,8 @@ TypedUnits includes common physical unit types:
|
|
|
164
185
|
|
|
165
186
|
.. code-block:: bash
|
|
166
187
|
|
|
167
|
-
git clone https://github.com/MartinPdeS/
|
|
168
|
-
cd
|
|
188
|
+
git clone https://github.com/MartinPdeS/TypedUnit.git
|
|
189
|
+
cd TypedUnit
|
|
169
190
|
pip install -e ".[testing]"
|
|
170
191
|
pytest
|
|
171
192
|
|
|
@@ -173,28 +194,40 @@ TypedUnits includes common physical unit types:
|
|
|
173
194
|
|
|
174
195
|
**Contributing**
|
|
175
196
|
|
|
176
|
-
|
|
197
|
+
TypedUnit is open source and contributions are welcome! Whether you're fixing bugs, adding new unit types, or improving documentation, your help is appreciated.
|
|
177
198
|
|
|
178
199
|
**Author:** `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdeS>`_
|
|
179
200
|
|
|
180
|
-
**Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=
|
|
201
|
+
**Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=TypedUnit>`_
|
|
181
202
|
|
|
182
|
-
.. |
|
|
203
|
+
.. |logo| image:: https://github.com/MartinPdeS/TypedUnit/raw/master/docs/images/logo.png
|
|
204
|
+
:target: https://github.com/MartinPdeS/TypedUnit
|
|
205
|
+
:alt: TypedUnit logo
|
|
206
|
+
|
|
207
|
+
.. |python| image:: https://img.shields.io/pypi/pyversions/typedunit.svg
|
|
183
208
|
:target: https://www.python.org/
|
|
184
209
|
:alt: Python version
|
|
185
210
|
|
|
186
|
-
.. |
|
|
187
|
-
:target: https://pypi.org/project/
|
|
188
|
-
:alt:
|
|
211
|
+
.. |PyPI| image:: https://badge.fury.io/py/typedunit.svg
|
|
212
|
+
:target: https://pypi.org/project/typedunit/
|
|
213
|
+
:alt: PyPI
|
|
189
214
|
|
|
190
|
-
.. |PyPi_download| image:: https://img.shields.io/pypi/dm/
|
|
191
|
-
:target: https://pypistats.org/packages/
|
|
192
|
-
:alt:
|
|
215
|
+
.. |PyPi_download| image:: https://img.shields.io/pypi/dm/typedunit.svg
|
|
216
|
+
:target: https://pypistats.org/packages/typedunit
|
|
217
|
+
:alt: PyPI download statistics
|
|
193
218
|
|
|
194
|
-
.. |docs| image:: https://github.com/
|
|
195
|
-
:target: https://martinpdes.github.io/
|
|
219
|
+
.. |docs| image:: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_documentation.yml/badge.svg
|
|
220
|
+
:target: https://martinpdes.github.io/TypedUnit/
|
|
196
221
|
:alt: Documentation Status
|
|
197
222
|
|
|
198
|
-
.. |
|
|
199
|
-
:target: https://
|
|
223
|
+
.. |ci/cd| image:: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_coverage.yml/badge.svg
|
|
224
|
+
:target: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_coverage.yml
|
|
225
|
+
:alt: Continuous integration status
|
|
226
|
+
|
|
227
|
+
.. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/TypedUnit/python-coverage-comment-action-data/badge.svg
|
|
228
|
+
:target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/TypedUnit/blob/python-coverage-comment-action-data/htmlcov/index.html
|
|
200
229
|
:alt: Unittest coverage
|
|
230
|
+
|
|
231
|
+
.. |anaconda| image:: https://anaconda.org/martinpdes/typedunit/badges/version.svg
|
|
232
|
+
:target: https://anaconda.org/martinpdes/typedunit
|
|
233
|
+
:alt: Anaconda package
|
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '0.2.
|
|
22
|
-
__version_tuple__ = version_tuple = (0, 2,
|
|
21
|
+
__version__ = version = '0.2.8'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 2, 8)
|
|
23
23
|
|
|
24
|
-
__commit_id__ = commit_id = '
|
|
24
|
+
__commit_id__ = commit_id = 'g3316b556e'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: TypedUnit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.8
|
|
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
|
|
@@ -61,14 +61,35 @@ Requires-Dist: sphinx-rtd-theme<4,>=2; extra == "documentation"
|
|
|
61
61
|
Requires-Dist: pydata-sphinx-theme~=0.15; extra == "documentation"
|
|
62
62
|
Dynamic: license-file
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
TypedUnit
|
|
65
65
|
===========
|
|
66
66
|
|
|
67
|
-
|
|
|
67
|
+
|logo|
|
|
68
|
+
|
|
69
|
+
.. list-table::
|
|
70
|
+
:widths: 35 65
|
|
71
|
+
:header-rows: 1
|
|
72
|
+
|
|
73
|
+
* - Badge
|
|
74
|
+
- Status
|
|
75
|
+
* - Python versions
|
|
76
|
+
- |python|
|
|
77
|
+
* - Documentation
|
|
78
|
+
- |docs|
|
|
79
|
+
* - Continuous integration
|
|
80
|
+
- |ci/cd|
|
|
81
|
+
* - Test coverage
|
|
82
|
+
- |coverage|
|
|
83
|
+
* - PyPI package
|
|
84
|
+
- |PyPI|
|
|
85
|
+
* - PyPI downloads
|
|
86
|
+
- |PyPI_download|
|
|
87
|
+
* - Anaconda package
|
|
88
|
+
- |anaconda|
|
|
68
89
|
|
|
69
90
|
**Type-safe physical units for Python**
|
|
70
91
|
|
|
71
|
-
|
|
92
|
+
TypedUnit is a Python library that extends Pint with type safety and validation capabilities. It allows you to create unit-aware types that work seamlessly with Python's type system and provide runtime validation for physical quantities.
|
|
72
93
|
|
|
73
94
|
**Key Features:**
|
|
74
95
|
|
|
@@ -83,7 +104,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
83
104
|
|
|
84
105
|
.. code-block:: python
|
|
85
106
|
|
|
86
|
-
from
|
|
107
|
+
from TypedUnit import Energy, Time, Power, validate, ureg
|
|
87
108
|
|
|
88
109
|
# Normal Pint instantiation
|
|
89
110
|
energy = 100 * ureg.joule
|
|
@@ -112,7 +133,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
112
133
|
|
|
113
134
|
.. code-block:: bash
|
|
114
135
|
|
|
115
|
-
pip install
|
|
136
|
+
pip install TypedUnit
|
|
116
137
|
|
|
117
138
|
----
|
|
118
139
|
|
|
@@ -122,7 +143,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
122
143
|
|
|
123
144
|
.. code-block:: python
|
|
124
145
|
|
|
125
|
-
from
|
|
146
|
+
from TypedUnit import Energy, Length, Mass, ureg
|
|
126
147
|
|
|
127
148
|
# Create quantities the normal way
|
|
128
149
|
kinetic_energy = 0.5 * 10 * ureg.kilogram * (5 * ureg.meter / ureg.second)**2
|
|
@@ -140,7 +161,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
140
161
|
|
|
141
162
|
.. code-block:: python
|
|
142
163
|
|
|
143
|
-
from
|
|
164
|
+
from TypedUnit import validate_units, Energy, Time, Power
|
|
144
165
|
|
|
145
166
|
@validate_units
|
|
146
167
|
def calculate_work(power: Power, time: Time) -> Energy:
|
|
@@ -156,7 +177,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
156
177
|
|
|
157
178
|
.. code-block:: python
|
|
158
179
|
|
|
159
|
-
from
|
|
180
|
+
from TypedUnit import Energy, Length, Mass
|
|
160
181
|
from pydantic.dataclasses import dataclass
|
|
161
182
|
|
|
162
183
|
@dataclass
|
|
@@ -176,7 +197,7 @@ TypedUnits is a Python library that extends Pint with type safety and validation
|
|
|
176
197
|
|
|
177
198
|
**Available Unit Types**
|
|
178
199
|
|
|
179
|
-
|
|
200
|
+
TypedUnit includes common physical unit types:
|
|
180
201
|
|
|
181
202
|
- **Mechanical**: `Energy`, `Power`, `Force`, `Pressure`
|
|
182
203
|
- **Spatial**: `Length`, `Area`, `Volume`, `Angle`
|
|
@@ -194,7 +215,7 @@ TypedUnits includes common physical unit types:
|
|
|
194
215
|
|
|
195
216
|
.. code-block:: python
|
|
196
217
|
|
|
197
|
-
from
|
|
218
|
+
from TypedUnit import create_unit_type
|
|
198
219
|
|
|
199
220
|
# Create your own unit types
|
|
200
221
|
MagneticField = create_unit_type('MagneticField', '[magnetic_flux_density]')
|
|
@@ -206,7 +227,7 @@ TypedUnits includes common physical unit types:
|
|
|
206
227
|
|
|
207
228
|
.. code-block:: python
|
|
208
229
|
|
|
209
|
-
from
|
|
230
|
+
from TypedUnit import validate_enhanced
|
|
210
231
|
|
|
211
232
|
@validate_enhanced(strict_mode=False, convert_types=True)
|
|
212
233
|
def flexible_function(energy: Energy, count: int) -> str:
|
|
@@ -227,8 +248,8 @@ TypedUnits includes common physical unit types:
|
|
|
227
248
|
|
|
228
249
|
.. code-block:: bash
|
|
229
250
|
|
|
230
|
-
git clone https://github.com/MartinPdeS/
|
|
231
|
-
cd
|
|
251
|
+
git clone https://github.com/MartinPdeS/TypedUnit.git
|
|
252
|
+
cd TypedUnit
|
|
232
253
|
pip install -e ".[testing]"
|
|
233
254
|
pytest
|
|
234
255
|
|
|
@@ -236,28 +257,40 @@ TypedUnits includes common physical unit types:
|
|
|
236
257
|
|
|
237
258
|
**Contributing**
|
|
238
259
|
|
|
239
|
-
|
|
260
|
+
TypedUnit is open source and contributions are welcome! Whether you're fixing bugs, adding new unit types, or improving documentation, your help is appreciated.
|
|
240
261
|
|
|
241
262
|
**Author:** `Martin Poinsinet de Sivry-Houle <https://github.com/MartinPdeS>`_
|
|
242
263
|
|
|
243
|
-
**Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=
|
|
264
|
+
**Email:** `martin.poinsinet-de-sivry@polymtl.ca <mailto:martin.poinsinet-de-sivry@polymtl.ca?subject=TypedUnit>`_
|
|
244
265
|
|
|
245
|
-
.. |
|
|
266
|
+
.. |logo| image:: https://github.com/MartinPdeS/TypedUnit/raw/master/docs/images/logo.png
|
|
267
|
+
:target: https://github.com/MartinPdeS/TypedUnit
|
|
268
|
+
:alt: TypedUnit logo
|
|
269
|
+
|
|
270
|
+
.. |python| image:: https://img.shields.io/pypi/pyversions/typedunit.svg
|
|
246
271
|
:target: https://www.python.org/
|
|
247
272
|
:alt: Python version
|
|
248
273
|
|
|
249
|
-
.. |
|
|
250
|
-
:target: https://pypi.org/project/
|
|
251
|
-
:alt:
|
|
274
|
+
.. |PyPI| image:: https://badge.fury.io/py/typedunit.svg
|
|
275
|
+
:target: https://pypi.org/project/typedunit/
|
|
276
|
+
:alt: PyPI
|
|
252
277
|
|
|
253
|
-
.. |PyPi_download| image:: https://img.shields.io/pypi/dm/
|
|
254
|
-
:target: https://pypistats.org/packages/
|
|
255
|
-
:alt:
|
|
278
|
+
.. |PyPi_download| image:: https://img.shields.io/pypi/dm/typedunit.svg
|
|
279
|
+
:target: https://pypistats.org/packages/typedunit
|
|
280
|
+
:alt: PyPI download statistics
|
|
256
281
|
|
|
257
|
-
.. |docs| image:: https://github.com/
|
|
258
|
-
:target: https://martinpdes.github.io/
|
|
282
|
+
.. |docs| image:: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_documentation.yml/badge.svg
|
|
283
|
+
:target: https://martinpdes.github.io/TypedUnit/
|
|
259
284
|
:alt: Documentation Status
|
|
260
285
|
|
|
261
|
-
.. |
|
|
262
|
-
:target: https://
|
|
286
|
+
.. |ci/cd| image:: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_coverage.yml/badge.svg
|
|
287
|
+
:target: https://github.com/MartinPdeS/TypedUnit/actions/workflows/deploy_coverage.yml
|
|
288
|
+
:alt: Continuous integration status
|
|
289
|
+
|
|
290
|
+
.. |coverage| image:: https://raw.githubusercontent.com/MartinPdeS/TypedUnit/python-coverage-comment-action-data/badge.svg
|
|
291
|
+
:target: https://htmlpreview.github.io/?https://github.com/MartinPdeS/TypedUnit/blob/python-coverage-comment-action-data/htmlcov/index.html
|
|
263
292
|
:alt: Unittest coverage
|
|
293
|
+
|
|
294
|
+
.. |anaconda| image:: https://anaconda.org/martinpdes/typedunit/badges/version.svg
|
|
295
|
+
:target: https://anaconda.org/martinpdes/typedunit
|
|
296
|
+
:alt: Anaconda package
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|