dccQuantities 2.2.0.post1__tar.gz → 3.0.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 (57) hide show
  1. {dccquantities-2.2.0.post1/src/dccQuantities.egg-info → dccquantities-3.0.0}/PKG-INFO +11 -11
  2. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/README.md +4 -4
  3. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/pyproject.toml +11 -9
  4. {dccquantities-2.2.0.post1 → dccquantities-3.0.0/src/dccQuantities.egg-info}/PKG-INFO +11 -11
  5. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dccQuantities.egg-info/SOURCES.txt +5 -14
  6. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dccQuantities.egg-info/requires.txt +2 -2
  7. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/__init__.py +2 -4
  8. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/_config.py +5 -6
  9. dccquantities-3.0.0/src/dcc_quantities/_helpers.py +35 -0
  10. dccquantities-3.0.0/src/dcc_quantities/_legacy/__init__.py +9 -0
  11. dccquantities-3.0.0/src/dcc_quantities/_legacy/si_hybrid.py +71 -0
  12. dccquantities-3.0.0/src/dcc_quantities/_metadata.py +10 -0
  13. dccquantities-3.0.0/src/dcc_quantities/dcc_chars_xml_list.py +14 -0
  14. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/dcc_lang_text.py +2 -0
  15. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/dcc_math.py +7 -5
  16. dccquantities-3.0.0/src/dcc_quantities/dcc_no_quantity.py +89 -0
  17. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/dcc_quantity_parser.py +11 -47
  18. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/dcc_quantity_table.py +60 -114
  19. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/dcc_quantity_type.py +49 -75
  20. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/dcc_rich_content_type.py +11 -10
  21. dccquantities-3.0.0/src/dcc_quantities/serializers/__init__.py +5 -0
  22. dccquantities-3.0.0/src/dcc_quantities/serializers/_explicit_serializer_mixin.py +145 -0
  23. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/serializers/_field_spec.py +2 -2
  24. dccquantities-3.0.0/src/dcc_quantities/serializers/content_data.py +109 -0
  25. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/si_data/_base_si_type.py +34 -61
  26. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/si_data/si_data_type.py +128 -87
  27. dccquantities-2.2.0.post1/src/dcc_quantities/parse_uncertainties.py → dccquantities-3.0.0/src/dcc_quantities/si_data/uncertainties.py +71 -92
  28. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/tests/test_math.py +1 -1
  29. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/tests/test_quantity_type.py +17 -2
  30. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/tests/test_si_real_list.py +55 -67
  31. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/tests/test_tables.py +41 -52
  32. dccquantities-2.2.0.post1/src/dcc_quantities/_abc/__init__.py +0 -4
  33. dccquantities-2.2.0.post1/src/dcc_quantities/_abc/abstract_list_type.py +0 -20
  34. dccquantities-2.2.0.post1/src/dcc_quantities/_abc/abstract_quantity_type_data.py +0 -26
  35. dccquantities-2.2.0.post1/src/dcc_quantities/_helpers.py +0 -69
  36. dccquantities-2.2.0.post1/src/dcc_quantities/_version.py +0 -3
  37. dccquantities-2.2.0.post1/src/dcc_quantities/dcc_chars_xml_list.py +0 -39
  38. dccquantities-2.2.0.post1/src/dcc_quantities/dcc_no_quantity.py +0 -73
  39. dccquantities-2.2.0.post1/src/dcc_quantities/serializers/__init__.py +0 -7
  40. dccquantities-2.2.0.post1/src/dcc_quantities/serializers/_explicit_serializer_mixin.py +0 -53
  41. dccquantities-2.2.0.post1/src/dcc_quantities/serializers/dcc_element_key.py +0 -65
  42. dccquantities-2.2.0.post1/src/dcc_quantities/serializers/dcc_element_parser.py +0 -213
  43. dccquantities-2.2.0.post1/src/dcc_quantities/serializers/dcc_json_encoder.py +0 -22
  44. dccquantities-2.2.0.post1/src/dcc_quantities/si_data/si_hybrid.py +0 -34
  45. dccquantities-2.2.0.post1/tests/test_dcc_chars_xml_list.py +0 -17
  46. dccquantities-2.2.0.post1/tests/test_parser.py +0 -60
  47. dccquantities-2.2.0.post1/tests/test_quantity_type_collector.py +0 -23
  48. dccquantities-2.2.0.post1/tests/test_serilizer.py +0 -26
  49. dccquantities-2.2.0.post1/tests/test_surface_flat_table_generation.py +0 -46
  50. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/LICENSE +0 -0
  51. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/MANIFEST.in +0 -0
  52. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/setup.cfg +0 -0
  53. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dccQuantities.egg-info/dependency_links.txt +0 -0
  54. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dccQuantities.egg-info/top_level.txt +0 -0
  55. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/exceptions.py +0 -0
  56. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/src/dcc_quantities/si_data/__init__.py +0 -0
  57. {dccquantities-2.2.0.post1 → dccquantities-3.0.0}/tests/test_dcc_text.py +0 -0
@@ -1,39 +1,39 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dccQuantities
3
- Version: 2.2.0.post1
3
+ Version: 3.0.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>
7
7
  License-Expression: LGPL-2.1-or-later
8
- Project-URL: Homepage, https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities
9
- Project-URL: Repository, https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities
8
+ Project-URL: Homepage, https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities
9
+ Project-URL: Repository, https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities
10
10
  Project-URL: Documentation, https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
17
  Classifier: Operating System :: OS Independent
18
- Requires-Python: <3.14,>=3.9
18
+ Requires-Python: >=3.10
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: dsiUnits~=3.1
22
- Requires-Dist: dccXMLJSONConv~=3.0.0.dev8
22
+ Requires-Dist: dcc-json-toolkit>=1.1.2
23
23
  Requires-Dist: metas_unclib
24
24
  Requires-Dist: numpy>=2.0.0
25
25
  Requires-Dist: PyBackport; python_version < "3.11"
26
- Requires-Dist: pythonnet
26
+ Requires-Dist: pythonnet>=3.1.0
27
27
  Dynamic: license-file
28
28
 
29
29
  # dccQuantities
30
30
 
31
31
  `dccQuantities` is a Python library designed for users of PTB’s [Digital Calibration Certificates (DCC)](https://wiki.dcc.ptb.de/) in XML format. It provides an object‑oriented interface to parse, serialize, and manipulate calibration data with full support for uncertainties and units. Arithmetic works naturally on scalars, scalar‑vector mixes, and same‑length vectors element‑wise, preserving uncertainty propagation and metadata throughout.
32
32
 
33
- [![Latest Release](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/-/badges/release.svg)](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/-/releases)
34
- ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/badges/main/pipeline.svg)
35
- ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/badges/main/coverage.svg)
36
- [![Docs](https://img.shields.io/badge/Read_the_docs-blue)](https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/)
33
+ [![PyPI Release](https://img.shields.io/pypi/v/dccQuantities?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/dccQuantities/)
34
+ ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities/badges/main/pipeline.svg)
35
+ ![Coverage (main)](https://gitlab1.ptb.de/%{project_path}/badges/main/coverage.svg?key_text=Coverage+(main)&key_width=100)
36
+ [![Docs](https://img.shields.io/badge/ReadTheDocs_(click_me)-blue?logo=readthedocs)](https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/)
37
37
 
38
38
  ---
39
39
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  `dccQuantities` is a Python library designed for users of PTB’s [Digital Calibration Certificates (DCC)](https://wiki.dcc.ptb.de/) in XML format. It provides an object‑oriented interface to parse, serialize, and manipulate calibration data with full support for uncertainties and units. Arithmetic works naturally on scalars, scalar‑vector mixes, and same‑length vectors element‑wise, preserving uncertainty propagation and metadata throughout.
4
4
 
5
- [![Latest Release](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/-/badges/release.svg)](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/-/releases)
6
- ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/badges/main/pipeline.svg)
7
- ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/badges/main/coverage.svg)
8
- [![Docs](https://img.shields.io/badge/Read_the_docs-blue)](https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/)
5
+ [![PyPI Release](https://img.shields.io/pypi/v/dccQuantities?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/dccQuantities/)
6
+ ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities/badges/main/pipeline.svg)
7
+ ![Coverage (main)](https://gitlab1.ptb.de/%{project_path}/badges/main/coverage.svg?key_text=Coverage+(main)&key_width=100)
8
+ [![Docs](https://img.shields.io/badge/ReadTheDocs_(click_me)-blue?logo=readthedocs)](https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/)
9
9
 
10
10
  ---
11
11
 
@@ -6,8 +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
10
- requires-python = ">=3.9,<3.14"
9
+ requires-python = ">=3.10"
11
10
 
12
11
  # SPDX license expression + point at your LICENSE file
13
12
  license = "LGPL-2.1-or-later"
@@ -15,11 +14,11 @@ license-files = ["LICENSE"]
15
14
 
16
15
  classifiers = [
17
16
  "Programming Language :: Python :: 3",
18
- "Programming Language :: Python :: 3.9",
19
17
  "Programming Language :: Python :: 3.10",
20
18
  "Programming Language :: Python :: 3.11",
21
19
  "Programming Language :: Python :: 3.12",
22
20
  "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
23
22
  "Operating System :: OS Independent",
24
23
  ]
25
24
 
@@ -31,24 +30,27 @@ authors = [
31
30
  ]
32
31
  dependencies = [
33
32
  "dsiUnits~=3.1",
34
- "dccXMLJSONConv~=3.0.0.dev8",
33
+ "dcc-json-toolkit>=1.1.2",
35
34
  "metas_unclib",
36
35
  "numpy>=2.0.0",
37
36
  "PyBackport ; python_version < '3.11'",
38
- "pythonnet",
37
+ "pythonnet>=3.1.0",
39
38
  ]
40
39
 
41
40
  [project.urls]
42
- Homepage = "https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities"
43
- Repository = "https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities"
41
+ Homepage = "https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities"
42
+ Repository = "https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities"
44
43
  Documentation = "https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/"
45
44
 
46
45
  [tool.setuptools.dynamic]
47
- version = { attr = "dcc_quantities._version.__version__" }
46
+ version = { attr = "dcc_quantities._metadata.__version__" }
48
47
  readme = { file = ["README.md"], content-type = "text/markdown" }
49
48
 
50
49
  [tool.coverage.run]
51
- omit = ["_version.py"]
50
+ omit = [
51
+ "_metadata.py",
52
+ "**/_legacy/*",
53
+ ]
52
54
 
53
55
  [tool.coverage.report]
54
56
  exclude_also = [
@@ -1,39 +1,39 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dccQuantities
3
- Version: 2.2.0.post1
3
+ Version: 3.0.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>
7
7
  License-Expression: LGPL-2.1-or-later
8
- Project-URL: Homepage, https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities
9
- Project-URL: Repository, https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities
8
+ Project-URL: Homepage, https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities
9
+ Project-URL: Repository, https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities
10
10
  Project-URL: Documentation, https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/
11
11
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
12
  Classifier: Programming Language :: Python :: 3.10
14
13
  Classifier: Programming Language :: Python :: 3.11
15
14
  Classifier: Programming Language :: Python :: 3.12
16
15
  Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
17
  Classifier: Operating System :: OS Independent
18
- Requires-Python: <3.14,>=3.9
18
+ Requires-Python: >=3.10
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
  Requires-Dist: dsiUnits~=3.1
22
- Requires-Dist: dccXMLJSONConv~=3.0.0.dev8
22
+ Requires-Dist: dcc-json-toolkit>=1.1.2
23
23
  Requires-Dist: metas_unclib
24
24
  Requires-Dist: numpy>=2.0.0
25
25
  Requires-Dist: PyBackport; python_version < "3.11"
26
- Requires-Dist: pythonnet
26
+ Requires-Dist: pythonnet>=3.1.0
27
27
  Dynamic: license-file
28
28
 
29
29
  # dccQuantities
30
30
 
31
31
  `dccQuantities` is a Python library designed for users of PTB’s [Digital Calibration Certificates (DCC)](https://wiki.dcc.ptb.de/) in XML format. It provides an object‑oriented interface to parse, serialize, and manipulate calibration data with full support for uncertainties and units. Arithmetic works naturally on scalars, scalar‑vector mixes, and same‑length vectors element‑wise, preserving uncertainty propagation and metadata throughout.
32
32
 
33
- [![Latest Release](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/-/badges/release.svg)](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/-/releases)
34
- ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/badges/main/pipeline.svg)
35
- ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/badges/main/coverage.svg)
36
- [![Docs](https://img.shields.io/badge/Read_the_docs-blue)](https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/)
33
+ [![PyPI Release](https://img.shields.io/pypi/v/dccQuantities?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/dccQuantities/)
34
+ ![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dccQuantities/badges/main/pipeline.svg)
35
+ ![Coverage (main)](https://gitlab1.ptb.de/%{project_path}/badges/main/coverage.svg?key_text=Coverage+(main)&key_width=100)
36
+ [![Docs](https://img.shields.io/badge/ReadTheDocs_(click_me)-blue?logo=readthedocs)](https://gitlab-pages.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dccQuantities/)
37
37
 
38
38
  ---
39
39
 
@@ -10,7 +10,7 @@ src/dccQuantities.egg-info/top_level.txt
10
10
  src/dcc_quantities/__init__.py
11
11
  src/dcc_quantities/_config.py
12
12
  src/dcc_quantities/_helpers.py
13
- src/dcc_quantities/_version.py
13
+ src/dcc_quantities/_metadata.py
14
14
  src/dcc_quantities/dcc_chars_xml_list.py
15
15
  src/dcc_quantities/dcc_lang_text.py
16
16
  src/dcc_quantities/dcc_math.py
@@ -20,27 +20,18 @@ src/dcc_quantities/dcc_quantity_table.py
20
20
  src/dcc_quantities/dcc_quantity_type.py
21
21
  src/dcc_quantities/dcc_rich_content_type.py
22
22
  src/dcc_quantities/exceptions.py
23
- src/dcc_quantities/parse_uncertainties.py
24
- src/dcc_quantities/_abc/__init__.py
25
- src/dcc_quantities/_abc/abstract_list_type.py
26
- src/dcc_quantities/_abc/abstract_quantity_type_data.py
23
+ src/dcc_quantities/_legacy/__init__.py
24
+ src/dcc_quantities/_legacy/si_hybrid.py
27
25
  src/dcc_quantities/serializers/__init__.py
28
26
  src/dcc_quantities/serializers/_explicit_serializer_mixin.py
29
27
  src/dcc_quantities/serializers/_field_spec.py
30
- src/dcc_quantities/serializers/dcc_element_key.py
31
- src/dcc_quantities/serializers/dcc_element_parser.py
32
- src/dcc_quantities/serializers/dcc_json_encoder.py
28
+ src/dcc_quantities/serializers/content_data.py
33
29
  src/dcc_quantities/si_data/__init__.py
34
30
  src/dcc_quantities/si_data/_base_si_type.py
35
31
  src/dcc_quantities/si_data/si_data_type.py
36
- src/dcc_quantities/si_data/si_hybrid.py
37
- tests/test_dcc_chars_xml_list.py
32
+ src/dcc_quantities/si_data/uncertainties.py
38
33
  tests/test_dcc_text.py
39
34
  tests/test_math.py
40
- tests/test_parser.py
41
35
  tests/test_quantity_type.py
42
- tests/test_quantity_type_collector.py
43
- tests/test_serilizer.py
44
36
  tests/test_si_real_list.py
45
- tests/test_surface_flat_table_generation.py
46
37
  tests/test_tables.py
@@ -1,8 +1,8 @@
1
1
  dsiUnits~=3.1
2
- dccXMLJSONConv~=3.0.0.dev8
2
+ dcc-json-toolkit>=1.1.2
3
3
  metas_unclib
4
4
  numpy>=2.0.0
5
- pythonnet
5
+ pythonnet>=3.1.0
6
6
 
7
7
  [:python_version < "3.11"]
8
8
  PyBackport
@@ -3,17 +3,15 @@
3
3
  from dcc_quantities.dcc_lang_text import DccLangName
4
4
  from dcc_quantities.dcc_quantity_table import DccFlatTable, DccLongTable, DccQuantityTable
5
5
  from dcc_quantities.dcc_quantity_type import DccQuantityType
6
- from dcc_quantities.serializers.dcc_element_key import DccElementKey
7
- from dcc_quantities.serializers.dcc_element_parser import extract_dcc_elements
6
+ from dcc_quantities.serializers.content_data import extract_dcc_tables
8
7
  from dcc_quantities.si_data import SiRealList
9
8
 
10
9
  __all__ = [
11
- "DccElementKey",
12
10
  "DccFlatTable",
13
11
  "DccLangName",
14
12
  "DccLongTable",
15
13
  "DccQuantityTable",
16
14
  "DccQuantityType",
17
15
  "SiRealList",
18
- "extract_dcc_elements",
16
+ "extract_dcc_tables",
19
17
  ]
@@ -4,6 +4,10 @@ import ctypes
4
4
  import locale
5
5
  import sys
6
6
 
7
+ from dcc_json_toolkit import DccSchema
8
+
9
+ from dcc_quantities._metadata import __default_out_schema_version__ as default_schema_version
10
+
7
11
  if sys.version_info < (3, 11):
8
12
  from py_back import enum
9
13
  else:
@@ -15,11 +19,6 @@ class CoverageProbabilityMissmatchBehavior(enum.IntEnum):
15
19
  WARNING_TAKE_K_VALUE = 2
16
20
 
17
21
 
18
- class DccReprStyle(enum.StrEnum):
19
- NORMAL = enum.auto()
20
- LIB_DEBUG = enum.auto()
21
-
22
-
23
22
  class DccConfiguration:
24
23
  _instance = None
25
24
 
@@ -31,7 +30,6 @@ class DccConfiguration:
31
30
  cls.reprStyle = "normal"
32
31
  cls.allowedCoverageProbabilityMissmatch = {"normal": 0.01, "uniform": 0.03, "default": 0.03}
33
32
  cls.coverageProbabilityMissmatchBehavior = CoverageProbabilityMissmatchBehavior.WARNING_TAKE_K_VALUE
34
- cls.storeOriginalUncerForNonIntK = True
35
33
  cls.record_warnings = True
36
34
  return cls._instance
37
35
 
@@ -47,3 +45,4 @@ class DccConfiguration:
47
45
 
48
46
 
49
47
  dcc_config = DccConfiguration()
48
+ out_schema = DccSchema(default_schema_version)
@@ -0,0 +1,35 @@
1
+ from __future__ import annotations
2
+
3
+ import copy
4
+ from typing import Optional
5
+
6
+ from dcc_quantities.serializers.content_data import dcc_type_collector
7
+
8
+
9
+ def parse_attributes(json_dict: dict):
10
+ attributes = {}
11
+ if "@id" in json_dict:
12
+ attributes["id"] = json_dict["@id"]
13
+ if "@refId" in json_dict:
14
+ attributes["ref_id"] = json_dict["@refId"]
15
+ if "@refType" in json_dict:
16
+ attributes["ref_type"] = json_dict["@refType"]
17
+ if "@lang" in json_dict:
18
+ attributes["lang"] = json_dict["@lang"]
19
+ if "@index" in json_dict:
20
+ attributes["index"] = json_dict["@index"]
21
+ return attributes
22
+
23
+
24
+ def replace_quantities_in_dict(json_dict: dict, parser, search_keys: Optional[list] = None):
25
+ if search_keys is None:
26
+ search_keys = ["dcc:quantity"]
27
+ found_quantities = dcc_type_collector(json_dict, search_keys=search_keys)
28
+ json_data = copy.deepcopy(json_dict)
29
+ for path, result in found_quantities:
30
+ parsed_object = parser(result)
31
+ current_node = json_data
32
+ for key in path[:-1]:
33
+ current_node = current_node[key]
34
+ current_node[path[-1]] = parsed_object
35
+ return json_data
@@ -0,0 +1,9 @@
1
+ """LEGACY SUBPACKAGE!
2
+
3
+ Here are contained modules that are currently NOT IN USE (in the test coverage)
4
+ and that might need a rework in the near future. The code is kept with the sole
5
+ purpose of having a reference.
6
+
7
+ The code contained here should never be used without a well known reason.
8
+ All files are skipping the `ruff` rules.
9
+ """
@@ -0,0 +1,71 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Optional, Iterator, Any
4
+
5
+ from dcc_quantities.si_data import SiRealList
6
+
7
+
8
+ class AbstractListType:
9
+ def __init__(self, children: list[AbstractListType]):
10
+ super().__init__()
11
+ self.children = children
12
+ self.data = None
13
+
14
+ def to_json_dict(self) -> dict:
15
+ result = {}
16
+ for child in self.children:
17
+ child_json = child.to_json_dict()
18
+ for key, value in child_json.items():
19
+ result.setdefault(key, []).append(value)
20
+ return result
21
+
22
+ def __len__(self) -> int:
23
+ return len(self.children)
24
+
25
+ def _iter_items(self) -> Iterator[tuple[str, Any]]:
26
+ """Iterator over all the class' items.
27
+
28
+ Iterates over all the non-empty (different to 'None') attributes or items contained within the class.
29
+ The items are returned as the attribute name and its value.
30
+ """
31
+ for k, v in vars(self).items():
32
+ if v is not None:
33
+ yield k, v
34
+
35
+ def __str__(self) -> str:
36
+ """String representation of the class' stored values."""
37
+ param_str = ", ".join(f"{key}: {value!s}" for key, value in self._iter_items())
38
+ if len(param_str) > 0:
39
+ param_str = " (" + param_str + ")"
40
+ return f"{self.data!s}{param_str}"
41
+
42
+ def __repr__(self) -> str:
43
+ return ", ".join(f"{key}={value!s}" for key, value in self._iter_items())
44
+
45
+
46
+ class SiHybrid(AbstractListType):
47
+ def to_json_dict(self):
48
+ return {"si:hybrid": super().to_json_dict()}
49
+
50
+ def __str__(self) -> str:
51
+ return "\n[\n " + "\n ".join((str(child) for child in self.children)) + "\n]\n"
52
+
53
+ @classmethod
54
+ def from_dcc_data(cls, json_dict: dict, relative_uncertainty: Optional[dict] = None):
55
+ key_parser_mapping = {
56
+ "si:real": SiRealList.from_si_real,
57
+ "si:complex": ...,
58
+ "si:list": ...,
59
+ "si:realList": ...,
60
+ "si:realListXMLList": SiRealList.from_si_xml_list,
61
+ "si:complexList": ...,
62
+ "si:constant": SiRealList.from_si_constant,
63
+ }
64
+ children = []
65
+ for key, parse_func in key_parser_mapping.items():
66
+ if key in json_dict and isinstance(json_dict[key], list):
67
+ new_children = [
68
+ parse_func(item, relative_uncertainties=relative_uncertainty) for item in json_dict[key]
69
+ ]
70
+ children.extend(new_children)
71
+ return cls(children=children)
@@ -0,0 +1,10 @@
1
+ """Varios metadata fields of the package.
2
+
3
+ VERSION :
4
+ The semantic versioning of the package.
5
+ DEFAULT_OUT_SCHEMA_VERSION :
6
+ Version of the released 'dcc.xsd' file that is used as default for exporting any data to an XML string.
7
+ """
8
+
9
+ __version__ = "3.0.0"
10
+ __default_out_schema_version__ = "3.4.0-rc.2"
@@ -0,0 +1,14 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+
6
+ class DccCharsXMLList:
7
+ def __init__(self, data: list[str]):
8
+ self.data = data
9
+
10
+ def __len__(self) -> int:
11
+ return len(self.data)
12
+
13
+ def to_json_dict(self) -> dict[str, Any]:
14
+ return {"dcc:charsXMLList": self.data}
@@ -87,6 +87,8 @@ class DccLangText(UserDict, ABC):
87
87
  parsed_dict = {item["@lang"]: item["$"] for item in content["dcc:content"]}
88
88
  else:
89
89
  parsed_dict = content
90
+
91
+ parsed_dict = {k: v.strip(" ") for k, v in parsed_dict.items()}
90
92
  super().__init__(parsed_dict)
91
93
 
92
94
  def __new__(cls, *args, **kwargs) -> DccLangText:
@@ -98,7 +98,7 @@ def _direct_trigonometric_function(q: DccQuantityType | SiRealList, ufunc: Calla
98
98
  angle_unit_name = data.unit.dsi_string.strip("\\")
99
99
  data *= _ANGLE_UNITS[angle_unit_name][2]
100
100
 
101
- new_si_data = SiRealList(data=ufunc(data.data), unit="\\one")
101
+ new_si_data = SiRealList(values=ufunc(data.data), unit="\\one")
102
102
  return new_si_data if isinstance(q, SiRealList) else DccQuantityType(new_si_data)
103
103
 
104
104
 
@@ -123,7 +123,7 @@ def _inverse_trigonometric_function(q: DccQuantityType | SiRealList, ufunc: Call
123
123
  within_domain = np.all(_INV_TRIG_DOMAIN_CHECK[ufunc.__name__](data.data))
124
124
  if not within_domain:
125
125
  raise NumericDomainError(f"The provided values are outside the valid domain for {ufunc.__name__}.")
126
- new_si_data = SiRealList(data=ufunc((data * data.unit.scale_factor).data), unit="\\radian")
126
+ new_si_data = SiRealList(values=ufunc((data * data.unit.scale_factor).data), unit="\\radian")
127
127
  return new_si_data if isinstance(q, SiRealList) else DccQuantityType(new_si_data)
128
128
 
129
129
 
@@ -160,7 +160,7 @@ def _generic_umath_function(
160
160
  new_data = ufunc((data * data.unit.scale_factor).data)
161
161
  if any(isinstance(get_value(v), complex) for v in new_data):
162
162
  raise NotImplementedError("Complex numbers are not supported yet. Make yure ")
163
- new_si_data = SiRealList(data=ufunc((data * data.unit.scale_factor).data), unit=result_unit)
163
+ new_si_data = SiRealList(values=ufunc((data * data.unit.scale_factor).data), unit=result_unit)
164
164
  return new_si_data if isinstance(q, SiRealList) else DccQuantityType(new_si_data)
165
165
 
166
166
 
@@ -190,8 +190,10 @@ def log10(a: DccQuantityType | SiRealList) -> DccQuantityType | SiRealList:
190
190
 
191
191
 
192
192
  def exp(a: DccQuantityType | SiRealList) -> DccQuantityType | SiRealList:
193
- """Return _e_ raised to the power _**a**_, where _e_ = 2.718281… is the base of natural logarithms and _**a**_
194
- is adimensional DCC Quantity data.
193
+ """Operation _e_ raised to the power _**a**_.
194
+
195
+ At the mentioned math equation, _e_ = 2.718281… is the base of natural logarithms
196
+ and _**a**_ is adimensional DCC Quantity data.
195
197
 
196
198
  Raises
197
199
  ------
@@ -0,0 +1,89 @@
1
+ from __future__ import annotations
2
+
3
+ import warnings
4
+ from typing import Any, Iterator, Optional
5
+
6
+ from dcc_quantities._helpers import parse_attributes
7
+ from dcc_quantities.dcc_lang_text import DccLangName
8
+ from dcc_quantities.dcc_rich_content_type import DccContent
9
+ from dcc_quantities.serializers.content_data import dcc_type_collector
10
+
11
+
12
+ class DccNoQuantity:
13
+ def __init__(
14
+ self,
15
+ data: str | list[dict[str, Any]],
16
+ identifier: Optional[str] = None,
17
+ ref_id: Optional[list[str]] = None,
18
+ ref_type: Optional[list[str]] = None,
19
+ name: Optional[dict] = None,
20
+ ) -> None:
21
+ super().__init__()
22
+ self.data = data
23
+ self.id = identifier
24
+ self.ref_id = ref_id
25
+ self.ref_type = ref_type
26
+ self.name = DccLangName(name)
27
+
28
+ def __len__(self) -> int:
29
+ return len(self.data["content"]) + len(self.data["file"]) + len(self.data["formula"])
30
+
31
+ def to_json_dict(self) -> dict:
32
+ key_mapping = {"id": "@id", "ref_id": "@refId", "ref_type": "@refType"}
33
+ data_key_mapping = {"content": "dcc:content", "file": "dcc:file", "formula": "dcc:formula"}
34
+ result = {}
35
+ for key, value in self._iter_items():
36
+ if value is None:
37
+ continue
38
+
39
+ if key in key_mapping:
40
+ result[key_mapping[key]] = value
41
+ elif key == "data":
42
+ for data_key, data_value in self.data.items():
43
+ if isinstance(data_value, list) and len(data_value) > 0:
44
+ result[data_key_mapping[data_key]] = []
45
+ for item in data_value:
46
+ result[data_key_mapping[data_key]].append(item.to_json_dict())
47
+ else:
48
+ raise NotImplementedError
49
+ return {"dcc:noQuantity": result}
50
+
51
+ def _iter_items(self) -> Iterator[tuple[str, Any]]:
52
+ """Iterator over all the class' items.
53
+
54
+ Iterates over all the non-empty (different to 'None') attributes or items contained within the class.
55
+ The items are returned as the attribute name and its value.
56
+ """
57
+ for k, v in vars(self).items():
58
+ if v is not None:
59
+ yield k, v
60
+
61
+ def __str__(self) -> str:
62
+ """String representation of the class' stored values."""
63
+ param_str = ", ".join(f"{key}: {value!s}" for key, value in self._iter_items())
64
+ if len(param_str) > 0:
65
+ param_str = " (" + param_str + ")"
66
+ return f"{self.data!s}{param_str}"
67
+
68
+ def __repr__(self) -> str:
69
+ return ", ".join(f"{key}={value!s}" for key, value in self._iter_items())
70
+
71
+ @classmethod
72
+ def from_json_dict(cls, json_dict: dict[str, Any]) -> DccNoQuantity:
73
+ dcc_no_quantity_args = parse_attributes(json_dict=json_dict)
74
+ if "dcc:name" in json_dict:
75
+ dcc_no_quantity_args["name"] = json_dict["dcc:name"]
76
+ dcc_no_quantity_data = {}
77
+ dcc_content_results = []
78
+ for result in dcc_type_collector(dcc_data=json_dict, search_keys=["dcc:content"]):
79
+ dcc_content_results.append(DccContent.from_json_dict(result[1]))
80
+ dcc_no_quantity_data["content"] = dcc_content_results
81
+ dcc_file_results = []
82
+ dcc_no_quantity_data["file"] = dcc_file_results
83
+ dcc_formula_results = []
84
+ dcc_no_quantity_data["formula"] = dcc_formula_results
85
+ dcc_no_quantity_args["data"] = dcc_no_quantity_data
86
+ for key in json_dict:
87
+ if key not in {"dcc:name", "dcc:content", "dcc:file", "dcc:formula", "@_Comment"}:
88
+ warnings.warn(f"Unsupported key for dcc:noQuantity: {key}", RuntimeWarning, stacklevel=2)
89
+ return cls(**dcc_no_quantity_args)