ucumvert 0.2.0__tar.gz → 0.2.2__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.
@@ -1,38 +1,36 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: ucumvert
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Python parser & interface for UCUM (Unified Code for Units of Measure).
5
5
  Project-URL: Documentation, https://github.com/dalito/ucumvert
6
6
  Project-URL: GitHub, https://github.com/dalito/ucumvert
7
7
  Project-URL: Changelog, https://github.com/dalito/ucumvert/releases
8
8
  Author-email: David Linke <david.linke@catalysis.de>
9
9
  Maintainer-email: David Linke <david.linke@catalysis.de>
10
- License: MIT
10
+ License-Expression: MIT
11
11
  License-File: LICENSE
12
12
  Keywords: UCUM,parser,units of measurement
13
13
  Classifier: Development Status :: 4 - Beta
14
14
  Classifier: Environment :: Console
15
15
  Classifier: Intended Audience :: Science/Research
16
- Classifier: License :: OSI Approved :: MIT License
17
16
  Classifier: Operating System :: OS Independent
18
17
  Classifier: Programming Language :: Python
19
- Classifier: Programming Language :: Python :: 3.8
20
18
  Classifier: Programming Language :: Python :: 3.9
21
19
  Classifier: Programming Language :: Python :: 3.10
22
20
  Classifier: Programming Language :: Python :: 3.11
23
21
  Classifier: Programming Language :: Python :: 3.12
24
- Requires-Python: >=3.8
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Requires-Python: >=3.9
25
24
  Requires-Dist: lark
26
25
  Requires-Dist: pint
27
26
  Provides-Extra: dev
28
- Requires-Dist: black; extra == 'dev'
29
27
  Requires-Dist: coverage; extra == 'dev'
30
28
  Requires-Dist: openpyxl; extra == 'dev'
31
29
  Requires-Dist: pydot; extra == 'dev'
32
30
  Requires-Dist: pytest; extra == 'dev'
33
31
  Requires-Dist: ruff; extra == 'dev'
34
32
  Provides-Extra: lint
35
- Requires-Dist: black; extra == 'lint'
33
+ Requires-Dist: ruff; extra == 'lint'
36
34
  Provides-Extra: tests
37
35
  Requires-Dist: coverage; extra == 'tests'
38
36
  Requires-Dist: pytest; extra == 'tests'
@@ -50,7 +48,7 @@ Description-Content-Type: text/markdown
50
48
 
51
49
  [UCUM](https://ucum.org/) (Unified Code for Units of Measure) is a code system intended to cover all units of measures.
52
50
  It provides a formalism to express units in an unambiguous way suitable for electronic communication.
53
- Note that UCUM does non provide a canonical representation, e.g. `m/s` and `m.s-1` are expressing the same unit in two ways.
51
+ Note that UCUM does not provide a canonical representation, e.g. `m/s` and `m.s-1` are expressing the same unit in two ways.
54
52
 
55
53
  **ucumvert** is a pip-installable Python package. Features:
56
54
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  [UCUM](https://ucum.org/) (Unified Code for Units of Measure) is a code system intended to cover all units of measures.
12
12
  It provides a formalism to express units in an unambiguous way suitable for electronic communication.
13
- Note that UCUM does non provide a canonical representation, e.g. `m/s` and `m.s-1` are expressing the same unit in two ways.
13
+ Note that UCUM does not provide a canonical representation, e.g. `m/s` and `m.s-1` are expressing the same unit in two ways.
14
14
 
15
15
  **ucumvert** is a pip-installable Python package. Features:
16
16
 
@@ -13,9 +13,10 @@ authors = [
13
13
  maintainers = [
14
14
  {name = "David Linke", email = "david.linke@catalysis.de"},
15
15
  ]
16
- license = {text = "MIT"}
16
+ license = "MIT"
17
+ license-files = ["LICENSE"]
17
18
  readme = "README.md"
18
- requires-python = ">=3.8"
19
+ requires-python = ">=3.9"
19
20
 
20
21
  keywords = ["UCUM", "units of measurement", "parser"]
21
22
 
@@ -24,13 +25,12 @@ classifiers = [
24
25
  "Programming Language :: Python",
25
26
  "Environment :: Console",
26
27
  "Intended Audience :: Science/Research",
27
- "License :: OSI Approved :: MIT License",
28
28
  "Operating System :: OS Independent",
29
- "Programming Language :: Python :: 3.8",
30
29
  "Programming Language :: Python :: 3.9",
31
30
  "Programming Language :: Python :: 3.10",
32
31
  "Programming Language :: Python :: 3.11",
33
32
  "Programming Language :: Python :: 3.12",
33
+ "Programming Language :: Python :: 3.13",
34
34
  ]
35
35
 
36
36
  dependencies = [
@@ -51,11 +51,10 @@ tests = [
51
51
  "coverage",
52
52
  ]
53
53
  lint = [
54
- "black",
54
+ "ruff",
55
55
  ]
56
56
  dev = [
57
57
  "ucumvert[tests,lint]",
58
- "ruff",
59
58
  "openpyxl",
60
59
  "pydot",
61
60
  ]
@@ -107,7 +106,6 @@ norecursedirs = "dist build .tox .git .cache __pycache__ .venv"
107
106
  # --doctest-modules
108
107
  addopts = "--strict-markers --strict-config --tb=short"
109
108
 
110
- [tool.coverage]
111
109
  [tool.coverage.run]
112
110
  # https://coverage.readthedocs.io/en/latest/config.html
113
111
  parallel = true
@@ -146,26 +144,32 @@ directory = ".htmlcov"
146
144
  title = "ucumvert coverage report"
147
145
 
148
146
  [tool.ruff]
149
- # https://beta.ruff.rs/docs/configuration/
147
+ # https://docs.astral.sh/ruff/configuration/
150
148
 
151
149
  exclude = [
152
150
  "__pycache__",
153
151
  "*.egg",
154
152
  ".*",
155
153
  ]
154
+
155
+ # Assume Python 3.9 syntax and semantics for linting.
156
+ target-version = "py39"
157
+
158
+ # Same as Black.
159
+ line-length = 88
160
+
161
+ [tool.ruff.lint]
156
162
  ignore = [
157
163
  "B905", # zip() without an explicit strict= parameter set. (requires python >= 3.10)
158
164
  "E501", # line too long
159
165
  "ISC001", # Conficts with ruff formatter
160
166
  ]
161
- # Same as Black.
162
- line-length = 88
163
167
 
164
168
  # Avoid trying to fix these violations
165
169
  unfixable = [
166
170
  "B", # flake8-bugbear
167
171
  ]
168
- # Rule selection https://beta.ruff.rs/docs/rules/
172
+ # Rule selection https://docs.astral.sh/ruff/rules/
169
173
  select = [
170
174
  # sort order as in ruff docs
171
175
  "F", # Pyflakes
@@ -228,32 +232,22 @@ select = [
228
232
  "LOG", # flake8-logging
229
233
  "RUF", # Ruff-specific rules
230
234
  ]
231
- # Assume Python 3.8
232
- target-version = "py38"
233
235
 
234
- [tool.ruff.per-file-ignores]
236
+ [tool.ruff.lint.per-file-ignores]
235
237
  "tests/*.py" = [
236
238
  "S101", # assert in tests is OK
237
239
  ]
238
240
 
239
- [tool.ruff.mccabe]
241
+ [tool.ruff.lint.mccabe]
240
242
  # Flake8-mccabe uses a default level of 7, ruff of 10.
241
243
  max-complexity = 10
242
244
 
243
- [tool.ruff.pep8-naming]
244
- # Allow Pydantic's `@validator` decorator to trigger class method treatment.
245
- classmethod-decorators = [
246
- "classmethod",
247
- ]
248
-
249
245
  [tool.ruff.format]
250
246
  # Enable reformatting of code snippets in docstrings.
251
247
  docstring-code-format = true
252
248
 
253
249
  [tool.codespell]
254
-
255
250
  skip = "pyproject.toml,src/ucumvert/vendor/ucum-essence.xml,src/ucumvert/vendor/ucum_examples.tsv,src/ucumvert/ucum_grammar.lark,src/ucumvert/pint_ucum_defs_mapping_report.txt"
256
-
257
251
  # Note: words have to be lowercased for the ignore-words-list
258
252
  ignore-words-list = "linke,tne,sie,smoot"
259
253
  quiet-level = 3
@@ -1,8 +1,13 @@
1
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
3
6
  TYPE_CHECKING = False
4
7
  if TYPE_CHECKING:
5
- from typing import Tuple, Union
8
+ from typing import Tuple
9
+ from typing import Union
10
+
6
11
  VERSION_TUPLE = Tuple[Union[int, str], ...]
7
12
  else:
8
13
  VERSION_TUPLE = object
@@ -12,5 +17,5 @@ __version__: str
12
17
  __version_tuple__: VERSION_TUPLE
13
18
  version_tuple: VERSION_TUPLE
14
19
 
15
- __version__ = version = '0.2.0'
16
- __version_tuple__ = version_tuple = (0, 2, 0)
20
+ __version__ = version = '0.2.2'
21
+ __version_tuple__ = version_tuple = (0, 2, 2)
@@ -8,6 +8,12 @@
8
8
  # Example: [gal_us] -> Alias: "gal_us"
9
9
  # cal[20] -> New unit: "twenty_degC_calorie" with alias "cal_20"
10
10
 
11
+ #### CONSTANTS ####
12
+
13
+ # Calculated using wolfram alpha to precision 50
14
+ # slope = tan(1 rad), calculated as constant as tan()-function cannot be used in definitions
15
+ slope = 1.5574077246549022305069748074583601730872507723815
16
+
11
17
  #### Prefixes ####
12
18
  # <prefix>- = <amount> [= <symbol>] [= <alias>] [ = <alias> ] [...]
13
19
  # Example:
@@ -85,8 +91,7 @@ osmole = mol = osm
85
91
 
86
92
  diopter = 1 / meter = _ = diop
87
93
 
88
- slope = tan(1 rad)
89
- prism_diopter = 100 * tan(1 rad) = _ = p_diop
94
+ prism_diopter = 100 * slope = _ = p_diop
90
95
 
91
96
  nephelometric_turbidity_unit = 1 = _ = NTU
92
97
  formazin_nephelometric_unit = 1 = _ = FNU
@@ -152,7 +152,12 @@ class UcumToPintTransformer(Transformer):
152
152
  def simple_unit(self, args):
153
153
  # print("DBGsu>", repr(args), len(args))
154
154
  if len(args) == 2: # prefix is present # noqa: PLR2004
155
- return self.ureg(args[0] + args[1])
155
+ # Work around a pint bug: parsing of abbreviated custom unit with prefix
156
+ # that could be a unit (k,m,M) does not detect the prefix but 2 units.
157
+ # e.g. m[IU] --> <Quantity(1, 'meter * [IU]')> instead of <Quantity(1, 'milli[IU]')>
158
+ # Therefore, this fails (pint 0.23):
159
+ # return self.ureg(args[0] + args[1])
160
+ return self.ureg(args[0] + str(self.ureg(args[1]).units))
156
161
 
157
162
  # Substitute UCUM atoms that cannot be defined in pint as units or aliases.
158
163
  return self.ureg(MAPPINGS_UCUM_TO_PINT.get(args[0], args[0]))
File without changes
File without changes
@@ -29,12 +29,12 @@ except ImportError: # pragma: no cover
29
29
  HAS_PYDOT = False
30
30
 
31
31
  __all__ = [
32
+ "PintUcumRegistry",
33
+ "UcumToPintStrTransformer",
34
+ "UcumToPintTransformer",
32
35
  "get_ucum_parser",
33
36
  "ucum_preprocessor",
34
37
  "update_lark_ucum_grammar_file",
35
- "UcumToPintTransformer",
36
- "UcumToPintStrTransformer",
37
- "PintUcumRegistry",
38
38
  ]
39
39
 
40
40
  # Note that nothing is passed to getLogger to set the "root" logger
File without changes