dccQuantities 2.1.0__tar.gz → 2.2.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.
- {dccquantities-2.1.0/src/dccQuantities.egg-info → dccquantities-2.2.0}/PKG-INFO +2 -7
- {dccquantities-2.1.0 → dccquantities-2.2.0}/pyproject.toml +3 -8
- {dccquantities-2.1.0 → dccquantities-2.2.0/src/dccQuantities.egg-info}/PKG-INFO +2 -7
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dccQuantities.egg-info/SOURCES.txt +1 -9
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dccQuantities.egg-info/requires.txt +1 -7
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/_abc/abstract_quantity_type_data.py +0 -1
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/_config.py +0 -4
- dccquantities-2.2.0/src/dcc_quantities/_helpers.py +69 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/_version.py +1 -1
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_chars_xml_list.py +0 -8
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_no_quantity.py +1 -9
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_quantity_table.py +173 -307
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_quantity_type.py +149 -122
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/serializers/dcc_element_key.py +2 -4
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/si_data/si_data_type.py +80 -38
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_dcc_chars_xml_list.py +0 -11
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_parser.py +2 -35
- dccquantities-2.2.0/tests/test_quantity_type.py +154 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_si_real_list.py +94 -73
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_tables.py +85 -82
- dccquantities-2.1.0/src/dccQuantities.egg-info/entry_points.txt +0 -2
- dccquantities-2.1.0/src/dcc_quantities/_cli.py +0 -32
- dccquantities-2.1.0/src/dcc_quantities/_helpers.py +0 -297
- dccquantities-2.1.0/src/dcc_quantities/query/__init__.py +0 -3
- dccquantities-2.1.0/src/dcc_quantities/query/_operators.py +0 -29
- dccquantities-2.1.0/src/dcc_quantities/query/slices.py +0 -33
- dccquantities-2.1.0/tests/test_dcc_no_quantity.py +0 -8
- dccquantities-2.1.0/tests/test_generate_example_table_data.py +0 -20
- dccquantities-2.1.0/tests/test_helpers.py +0 -100
- dccquantities-2.1.0/tests/test_si_real_list_parse_data.py +0 -29
- {dccquantities-2.1.0 → dccquantities-2.2.0}/LICENSE +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/MANIFEST.in +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/README.md +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/setup.cfg +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dccQuantities.egg-info/dependency_links.txt +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dccQuantities.egg-info/top_level.txt +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/__init__.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/_abc/__init__.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/_abc/abstract_list_type.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_lang_text.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_math.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_quantity_parser.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/dcc_rich_content_type.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/exceptions.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/parse_uncertainties.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/serializers/__init__.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/serializers/_explicit_serializer_mixin.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/serializers/_field_spec.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/serializers/dcc_element_parser.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/serializers/dcc_json_encoder.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/si_data/__init__.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/si_data/_base_si_type.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/src/dcc_quantities/si_data/si_hybrid.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_dcc_text.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_math.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_quantity_type_collector.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_serilizer.py +0 -0
- {dccquantities-2.1.0 → dccquantities-2.2.0}/tests/test_surface_flat_table_generation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dccQuantities
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Python classes for working with DDC calibration data
|
|
5
5
|
Author: Vanessa Stehr, Thomas Bruns
|
|
6
6
|
Author-email: Benedikt Seeger <benedikt.seeger@ptb.de>, Jaime Gonzalez Gomez <jaime.gonzalez-gomez@ptb.de>
|
|
@@ -21,14 +21,9 @@ License-File: LICENSE
|
|
|
21
21
|
Requires-Dist: dsiUnits~=3.1
|
|
22
22
|
Requires-Dist: dccXMLJSONConv~=3.0.0.dev8
|
|
23
23
|
Requires-Dist: metas_unclib
|
|
24
|
-
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: numpy>=2.0.0
|
|
25
25
|
Requires-Dist: PyBackport; python_version < "3.11"
|
|
26
26
|
Requires-Dist: pythonnet
|
|
27
|
-
Provides-Extra: docs
|
|
28
|
-
Requires-Dist: mkdocs; extra == "docs"
|
|
29
|
-
Requires-Dist: mkdocstrings-python; extra == "docs"
|
|
30
|
-
Requires-Dist: mike; extra == "docs"
|
|
31
|
-
Requires-Dist: ruff; extra == "docs"
|
|
32
27
|
Dynamic: license-file
|
|
33
28
|
|
|
34
29
|
# dccQuantities
|
|
@@ -6,6 +6,7 @@ build-backend = "setuptools.build_meta"
|
|
|
6
6
|
name = "dccQuantities"
|
|
7
7
|
description = "Python classes for working with DDC calibration data"
|
|
8
8
|
dynamic = ["readme", "version"]
|
|
9
|
+
# Python 3.14 is not supported due to a 'pythonnet' open issue: https://github.com/pythonnet/pythonnet/issues/2610
|
|
9
10
|
requires-python = ">=3.9,<3.14"
|
|
10
11
|
|
|
11
12
|
# SPDX license expression + point at your LICENSE file
|
|
@@ -32,7 +33,7 @@ dependencies = [
|
|
|
32
33
|
"dsiUnits~=3.1",
|
|
33
34
|
"dccXMLJSONConv~=3.0.0.dev8",
|
|
34
35
|
"metas_unclib",
|
|
35
|
-
"numpy",
|
|
36
|
+
"numpy>=2.0.0",
|
|
36
37
|
"PyBackport ; python_version < '3.11'",
|
|
37
38
|
"pythonnet",
|
|
38
39
|
]
|
|
@@ -42,18 +43,12 @@ Homepage = "https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities"
|
|
|
42
43
|
Repository = "https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities"
|
|
43
44
|
Documentation = "https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/"
|
|
44
45
|
|
|
45
|
-
[project.optional-dependencies]
|
|
46
|
-
docs = ["mkdocs", "mkdocstrings-python", "mike", "ruff"]
|
|
47
|
-
|
|
48
46
|
[tool.setuptools.dynamic]
|
|
49
47
|
version = { attr = "dcc_quantities._version.__version__" }
|
|
50
48
|
readme = { file = ["README.md"], content-type = "text/markdown" }
|
|
51
49
|
|
|
52
|
-
[project.scripts]
|
|
53
|
-
quantity-docs = "dcc_quantities._cli:deploy_local_docs"
|
|
54
|
-
|
|
55
50
|
[tool.coverage.run]
|
|
56
|
-
omit = ["
|
|
51
|
+
omit = ["_version.py"]
|
|
57
52
|
|
|
58
53
|
[tool.coverage.report]
|
|
59
54
|
exclude_also = [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dccQuantities
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.0
|
|
4
4
|
Summary: Python classes for working with DDC calibration data
|
|
5
5
|
Author: Vanessa Stehr, Thomas Bruns
|
|
6
6
|
Author-email: Benedikt Seeger <benedikt.seeger@ptb.de>, Jaime Gonzalez Gomez <jaime.gonzalez-gomez@ptb.de>
|
|
@@ -21,14 +21,9 @@ License-File: LICENSE
|
|
|
21
21
|
Requires-Dist: dsiUnits~=3.1
|
|
22
22
|
Requires-Dist: dccXMLJSONConv~=3.0.0.dev8
|
|
23
23
|
Requires-Dist: metas_unclib
|
|
24
|
-
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: numpy>=2.0.0
|
|
25
25
|
Requires-Dist: PyBackport; python_version < "3.11"
|
|
26
26
|
Requires-Dist: pythonnet
|
|
27
|
-
Provides-Extra: docs
|
|
28
|
-
Requires-Dist: mkdocs; extra == "docs"
|
|
29
|
-
Requires-Dist: mkdocstrings-python; extra == "docs"
|
|
30
|
-
Requires-Dist: mike; extra == "docs"
|
|
31
|
-
Requires-Dist: ruff; extra == "docs"
|
|
32
27
|
Dynamic: license-file
|
|
33
28
|
|
|
34
29
|
# dccQuantities
|
|
@@ -5,11 +5,9 @@ pyproject.toml
|
|
|
5
5
|
src/dccQuantities.egg-info/PKG-INFO
|
|
6
6
|
src/dccQuantities.egg-info/SOURCES.txt
|
|
7
7
|
src/dccQuantities.egg-info/dependency_links.txt
|
|
8
|
-
src/dccQuantities.egg-info/entry_points.txt
|
|
9
8
|
src/dccQuantities.egg-info/requires.txt
|
|
10
9
|
src/dccQuantities.egg-info/top_level.txt
|
|
11
10
|
src/dcc_quantities/__init__.py
|
|
12
|
-
src/dcc_quantities/_cli.py
|
|
13
11
|
src/dcc_quantities/_config.py
|
|
14
12
|
src/dcc_quantities/_helpers.py
|
|
15
13
|
src/dcc_quantities/_version.py
|
|
@@ -26,9 +24,6 @@ src/dcc_quantities/parse_uncertainties.py
|
|
|
26
24
|
src/dcc_quantities/_abc/__init__.py
|
|
27
25
|
src/dcc_quantities/_abc/abstract_list_type.py
|
|
28
26
|
src/dcc_quantities/_abc/abstract_quantity_type_data.py
|
|
29
|
-
src/dcc_quantities/query/__init__.py
|
|
30
|
-
src/dcc_quantities/query/_operators.py
|
|
31
|
-
src/dcc_quantities/query/slices.py
|
|
32
27
|
src/dcc_quantities/serializers/__init__.py
|
|
33
28
|
src/dcc_quantities/serializers/_explicit_serializer_mixin.py
|
|
34
29
|
src/dcc_quantities/serializers/_field_spec.py
|
|
@@ -40,15 +35,12 @@ src/dcc_quantities/si_data/_base_si_type.py
|
|
|
40
35
|
src/dcc_quantities/si_data/si_data_type.py
|
|
41
36
|
src/dcc_quantities/si_data/si_hybrid.py
|
|
42
37
|
tests/test_dcc_chars_xml_list.py
|
|
43
|
-
tests/test_dcc_no_quantity.py
|
|
44
38
|
tests/test_dcc_text.py
|
|
45
|
-
tests/test_generate_example_table_data.py
|
|
46
|
-
tests/test_helpers.py
|
|
47
39
|
tests/test_math.py
|
|
48
40
|
tests/test_parser.py
|
|
41
|
+
tests/test_quantity_type.py
|
|
49
42
|
tests/test_quantity_type_collector.py
|
|
50
43
|
tests/test_serilizer.py
|
|
51
44
|
tests/test_si_real_list.py
|
|
52
|
-
tests/test_si_real_list_parse_data.py
|
|
53
45
|
tests/test_surface_flat_table_generation.py
|
|
54
46
|
tests/test_tables.py
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import copy
|
|
4
|
+
import warnings
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from dcc_quantities.serializers.dcc_element_key import DccElementKey
|
|
8
|
+
from dcc_quantities.serializers.dcc_element_parser import dcc_type_collector
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def unexpected_key_serialization_handler(result: dict, key: str, value, class_name: str) -> None:
|
|
12
|
+
"""
|
|
13
|
+
Handles unexpected keys during JSON serialization.
|
|
14
|
+
|
|
15
|
+
If the key contains 'dcc:' or 'si:', it is assumed to be DCC-related and is added to the result,
|
|
16
|
+
otherwise a warning is issued and the key is ignored.
|
|
17
|
+
"""
|
|
18
|
+
if "dcc:" in str(key) or "si:" in str(key):
|
|
19
|
+
warnings.warn(
|
|
20
|
+
f"Found unexpected key {key} while converting {class_name} to JSON."
|
|
21
|
+
f" Assuming this is DCC data therefore adding it to the JSON.",
|
|
22
|
+
RuntimeWarning,
|
|
23
|
+
stacklevel=3,
|
|
24
|
+
)
|
|
25
|
+
result[key] = value
|
|
26
|
+
else:
|
|
27
|
+
warnings.warn(
|
|
28
|
+
f"Found unexpected key {key} while converting {class_name} to JSON."
|
|
29
|
+
f" Assuming this other data is unrelated to DCC and ignoring.",
|
|
30
|
+
RuntimeWarning,
|
|
31
|
+
stacklevel=3,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def parse_attributes(json_dict: dict):
|
|
36
|
+
attributes = {}
|
|
37
|
+
if "@id" in json_dict:
|
|
38
|
+
attributes["id"] = json_dict["@id"]
|
|
39
|
+
if "@refId" in json_dict:
|
|
40
|
+
attributes["ref_id"] = json_dict["@refId"]
|
|
41
|
+
if "@refType" in json_dict:
|
|
42
|
+
attributes["ref_type"] = json_dict["@refType"]
|
|
43
|
+
if "@lang" in json_dict:
|
|
44
|
+
attributes["lang"] = json_dict["@lang"]
|
|
45
|
+
if "@index" in json_dict:
|
|
46
|
+
attributes["index"] = json_dict["@index"]
|
|
47
|
+
return attributes
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def replace_quantities_in_dict(
|
|
51
|
+
json_dict: dict, parser, search_keys: Optional[list] = None, return_quantity_list: bool = False
|
|
52
|
+
):
|
|
53
|
+
if search_keys is None:
|
|
54
|
+
search_keys = [DccElementKey.QUANTITY]
|
|
55
|
+
found_quantities = dcc_type_collector(json_dict, search_keys=search_keys)
|
|
56
|
+
json_data = copy.deepcopy(json_dict)
|
|
57
|
+
if return_quantity_list:
|
|
58
|
+
quantity_list = []
|
|
59
|
+
for path, result in found_quantities:
|
|
60
|
+
parsed_object = parser(result)
|
|
61
|
+
if return_quantity_list:
|
|
62
|
+
quantity_list.append((path, parsed_object))
|
|
63
|
+
current_node = json_data
|
|
64
|
+
for key in path[:-1]:
|
|
65
|
+
current_node = current_node[key]
|
|
66
|
+
current_node[path[-1]] = parsed_object
|
|
67
|
+
if return_quantity_list:
|
|
68
|
+
return json_data, quantity_list
|
|
69
|
+
return json_data
|
|
@@ -7,7 +7,6 @@ from typing import Any
|
|
|
7
7
|
class DccCharsXMLList:
|
|
8
8
|
def __init__(self, data: list[str]):
|
|
9
9
|
self.data = data
|
|
10
|
-
self._sorted = None
|
|
11
10
|
|
|
12
11
|
def __len__(self) -> int:
|
|
13
12
|
return len(self.data)
|
|
@@ -31,13 +30,6 @@ class DccCharsXMLList:
|
|
|
31
30
|
def to_json_dict(self) -> dict[str, Any]:
|
|
32
31
|
return {"dcc:charsXMLList": self.data}
|
|
33
32
|
|
|
34
|
-
@property
|
|
35
|
-
def sorted(self) -> bool:
|
|
36
|
-
if self._sorted is None:
|
|
37
|
-
self._sorted = all((self.data[i] <= self.data[i + 1] for i in range(len(self.data) - 1)))
|
|
38
|
-
"Check if the list of strings is sorted in ascending order."
|
|
39
|
-
return self._sorted
|
|
40
|
-
|
|
41
33
|
|
|
42
34
|
def parse(json_dict: dict | list) -> DccCharsXMLList:
|
|
43
35
|
if isinstance(json_dict, list):
|
|
@@ -25,18 +25,16 @@ class DccNoQuantity(AbstractQuantityTypeData):
|
|
|
25
25
|
self.ref_id = ref_id
|
|
26
26
|
self.ref_type = ref_type
|
|
27
27
|
self.name = DccLangName(name)
|
|
28
|
-
self._sorted = False
|
|
29
28
|
|
|
30
29
|
def __len__(self) -> int:
|
|
31
30
|
return len(self.data["content"]) + len(self.data["file"]) + len(self.data["formula"])
|
|
32
31
|
|
|
33
32
|
def to_json_dict(self) -> dict:
|
|
34
|
-
private_keys = ["_sorted"]
|
|
35
33
|
key_mapping = {"id": "@id", "ref_id": "@refId", "ref_type": "@refType"}
|
|
36
34
|
data_key_mapping = {"content": "dcc:content", "file": "dcc:file", "formula": "dcc:formula"}
|
|
37
35
|
result = {}
|
|
38
36
|
for key, value in self._iter_items():
|
|
39
|
-
if value is None
|
|
37
|
+
if value is None:
|
|
40
38
|
continue
|
|
41
39
|
|
|
42
40
|
if key in key_mapping:
|
|
@@ -47,16 +45,10 @@ class DccNoQuantity(AbstractQuantityTypeData):
|
|
|
47
45
|
result[data_key_mapping[data_key]] = []
|
|
48
46
|
for item in data_value:
|
|
49
47
|
result[data_key_mapping[data_key]].append(item.to_json_dict())
|
|
50
|
-
# if set(self.data) - set(data_key_mapping):
|
|
51
|
-
# pass
|
|
52
48
|
else:
|
|
53
49
|
unexpected_key_serialization_handler(result, key, value, self.__class__.__name__)
|
|
54
50
|
return {"dcc:noQuantity": result}
|
|
55
51
|
|
|
56
|
-
@property
|
|
57
|
-
def sorted(self) -> bool:
|
|
58
|
-
return self._sorted
|
|
59
|
-
|
|
60
52
|
|
|
61
53
|
def parse(json_dict) -> DccNoQuantity:
|
|
62
54
|
# fixme: There are multiple issues here.
|