labfreed 0.0.9__py2.py3-none-any.whl → 0.0.10__py2.py3-none-any.whl
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.
- labfreed/DisplayNameExtension/DisplayNameExtension.py +5 -2
- labfreed/PAC_CAT/data_model copy.py +232 -0
- labfreed/PAC_CAT/data_model.py +319 -59
- labfreed/PAC_ID/data_model.py +42 -112
- labfreed/PAC_ID/extensions.py +55 -0
- labfreed/TREX/data_model.py +316 -396
- labfreed/TREX/parse.py +1 -69
- labfreed/TREX/unece_units.py +17 -1
- labfreed/__init__.py +1 -1
- labfreed/{PAC_ID/parse.py → parse_pac.py} +104 -59
- labfreed/utilities/base36.py +29 -13
- labfreed/utilities/extension_intertpreters.py +4 -0
- labfreed/utilities/utility_types.py +103 -0
- labfreed/{PAC_ID/well_known_segment_keys.py → utilities/well_known_keys.py} +1 -1
- labfreed/validation.py +3 -1
- {labfreed-0.0.9.dist-info → labfreed-0.0.10.dist-info}/METADATA +1 -1
- labfreed-0.0.10.dist-info/RECORD +22 -0
- labfreed/PAC_ID/serialize.py +0 -60
- labfreed/TREX/serialize.py +0 -3
- labfreed/conversion_tools/uncertainty.py +0 -32
- labfreed/conversion_tools/unit_utilities.py +0 -109
- labfreed-0.0.9.dist-info/RECORD +0 -22
- {labfreed-0.0.9.dist-info → labfreed-0.0.10.dist-info}/WHEEL +0 -0
- {labfreed-0.0.9.dist-info → labfreed-0.0.10.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
from functools import cache
|
|
2
|
-
import json
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
from rich import print
|
|
6
|
-
|
|
7
|
-
from typing import Tuple
|
|
8
|
-
from typing_extensions import Annotated
|
|
9
|
-
from pydantic import BaseModel, AfterValidator
|
|
10
|
-
import quantities as pq
|
|
11
|
-
from quantities import units
|
|
12
|
-
from .uncertainty import to_significant_digits_str
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def validate_unit(unit_name:str) -> str :
|
|
16
|
-
"""
|
|
17
|
-
Pydantic validator function for the unit.
|
|
18
|
-
Checks if the unit is a valid unit.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Args:
|
|
22
|
-
unit (str): unit symbol, e.g. 'kg'
|
|
23
|
-
|
|
24
|
-
Returns:
|
|
25
|
-
str: the input unit.
|
|
26
|
-
|
|
27
|
-
Errors:
|
|
28
|
-
raises an AssertionError if validation fails
|
|
29
|
-
"""
|
|
30
|
-
if hasattr(pq, unit_name):
|
|
31
|
-
return unit_name
|
|
32
|
-
else:
|
|
33
|
-
assert False
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
class PydanticUncertainQuantity(BaseModel):
|
|
37
|
-
data:int|float
|
|
38
|
-
unit_name: Annotated[str, AfterValidator(validate_unit)]
|
|
39
|
-
unit_symbol: str
|
|
40
|
-
uncertainty:float|None=None
|
|
41
|
-
|
|
42
|
-
@property
|
|
43
|
-
def for_display(self):
|
|
44
|
-
return self.__str__()
|
|
45
|
-
|
|
46
|
-
def as_strings(self):
|
|
47
|
-
unit_symbol = self.unit_symbol
|
|
48
|
-
if unit_symbol == "dimensionless":
|
|
49
|
-
unit_symbol = ""
|
|
50
|
-
s = ''
|
|
51
|
-
|
|
52
|
-
val_str = to_significant_digits_str(self.data, self.uncertainty)
|
|
53
|
-
return f"{val_str}", f"{unit_symbol}", f"{val_str} {unit_symbol}"
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
def __str__(self):
|
|
58
|
-
unit_symbol = self.unit_symbol
|
|
59
|
-
if unit_symbol == "dimensionless":
|
|
60
|
-
unit_symbol = ""
|
|
61
|
-
|
|
62
|
-
s = f"{to_significant_digits_str(self.data, self.uncertainty)} {unit_symbol}"
|
|
63
|
-
return s
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
unit_map = [
|
|
67
|
-
('MGM', units.milligram),
|
|
68
|
-
('GRM', units.gram),
|
|
69
|
-
('KGM', units.kilogram),
|
|
70
|
-
|
|
71
|
-
('CEL', units.celsius),
|
|
72
|
-
|
|
73
|
-
('LTR', units.liter),
|
|
74
|
-
('MLT', units.milliliter),
|
|
75
|
-
|
|
76
|
-
('C34', units.mole),
|
|
77
|
-
('D43',units.atomic_mass_unit),
|
|
78
|
-
|
|
79
|
-
('1', units.dimensionless),
|
|
80
|
-
('C62', units.dimensionless),
|
|
81
|
-
|
|
82
|
-
('BAR',units.bar),
|
|
83
|
-
('MBR',units.millibar),
|
|
84
|
-
('KBA',units.kilobar),
|
|
85
|
-
|
|
86
|
-
('RPM', units.rpm),
|
|
87
|
-
|
|
88
|
-
('HTZ', units.hertz),
|
|
89
|
-
('KHZ', units.kilohertz),
|
|
90
|
-
('MHZ',units.megahertz),
|
|
91
|
-
|
|
92
|
-
('SEC', units.second),
|
|
93
|
-
('MIN', units.minute),
|
|
94
|
-
('HUR', units.hour),
|
|
95
|
-
|
|
96
|
-
('MTR', units.meter)
|
|
97
|
-
|
|
98
|
-
]
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if __name__ == "__main__":
|
|
105
|
-
pass
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
labfreed-0.0.9.dist-info/RECORD
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
labfreed/__init__.py,sha256=NqKE8cu-i6wAIxbyZat0L_dbFSjpJgHYzJYqGEGXBBk,87
|
|
2
|
-
labfreed/validation.py,sha256=3w69iAX_fH6QdceMj_sgR9pQhJsSy5mXhxLxz_YNHfU,5850
|
|
3
|
-
labfreed/DisplayNameExtension/DisplayNameExtension.py,sha256=MKc9YzI5KKEfnH8glXEteB29ZMfZxbmvFzJTLKbOX_g,1051
|
|
4
|
-
labfreed/PAC_CAT/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
5
|
-
labfreed/PAC_CAT/data_model.py,sha256=hob-WNs2-633LmxQ7Ot3RBpcvStYFzdj20QDQZOQyqY,4306
|
|
6
|
-
labfreed/PAC_ID/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
labfreed/PAC_ID/data_model.py,sha256=c2exBF2AXwXxudPS9Cd74xex0VB5Q-EeJHQi43LRmwQ,9300
|
|
8
|
-
labfreed/PAC_ID/parse.py,sha256=g0AXzJ9El8TZ2c05GOMN6yfa3FUAFDFVndx5mefe_ZM,5175
|
|
9
|
-
labfreed/PAC_ID/serialize.py,sha256=0BhF7aXGlLpr312lkBvl1O5fXDFZeLLPgSBddO9Y86Q,1963
|
|
10
|
-
labfreed/PAC_ID/well_known_segment_keys.py,sha256=zrzMvvS42urPpiwinI-IhHPgT3r86zEBl4TlEMOfzbU,338
|
|
11
|
-
labfreed/TREX/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
|
|
12
|
-
labfreed/TREX/data_model.py,sha256=727da6PPvl-5gwPbljTDNprU38de80Cs1Q1bxKJ6DWI,29804
|
|
13
|
-
labfreed/TREX/parse.py,sha256=rV7EDCaY9cmBJNqsrSZQLNzcivyOCzLsKXW2sAOitaA,4867
|
|
14
|
-
labfreed/TREX/serialize.py,sha256=5M0c8l4xTtiX4PIKVRI3Gt-jNFYNcKOeuO3C-m1HE5g,89
|
|
15
|
-
labfreed/TREX/unece_units.py,sha256=7PL4eR8SGklnuR5gC4ooAvgFFYg9dCF9HmwIU25OZYw,2682
|
|
16
|
-
labfreed/conversion_tools/uncertainty.py,sha256=l3WxrLnWTQYfX28gFisXwDcVPvT8bCAd4q6Xl02dRdE,1117
|
|
17
|
-
labfreed/conversion_tools/unit_utilities.py,sha256=5NXDt-XRkajcg2lLdg0vDBWbmfhUCqeY4hu_k6PkbCY,2445
|
|
18
|
-
labfreed/utilities/base36.py,sha256=2lwmEMWm8qrFJkcrP-nMPwS0eCm2THhCJ3Vk-TdGQg0,2455
|
|
19
|
-
labfreed-0.0.9.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
|
|
20
|
-
labfreed-0.0.9.dist-info/WHEEL,sha256=BXjIu84EnBiZ4HkNUBN93Hamt5EPQMQ6VkF7-VZ_Pu0,100
|
|
21
|
-
labfreed-0.0.9.dist-info/METADATA,sha256=whgM7VD1R3S7JlP96c9mVBYWoDGwJzjdxdmE2nZRMFU,206
|
|
22
|
-
labfreed-0.0.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|