labfreed 0.0.4__py3-none-any.whl → 0.2.0__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.
Potentially problematic release.
This version of labfreed might be problematic. Click here for more details.
- labfreed/__init__.py +4 -1
- labfreed/labfreed_infrastructure.py +276 -0
- labfreed/pac_cat/__init__.py +17 -0
- labfreed/pac_cat/category_base.py +51 -0
- labfreed/pac_cat/pac_cat.py +159 -0
- labfreed/pac_cat/predefined_categories.py +190 -0
- labfreed/pac_id/__init__.py +19 -0
- labfreed/pac_id/extension.py +48 -0
- labfreed/pac_id/id_segment.py +90 -0
- labfreed/pac_id/pac_id.py +140 -0
- labfreed/pac_id/url_parser.py +154 -0
- labfreed/pac_id/url_serializer.py +80 -0
- labfreed/pac_id_resolver/__init__.py +2 -0
- labfreed/pac_id_resolver/cit_v1.py +149 -0
- labfreed/pac_id_resolver/cit_v2.py +303 -0
- labfreed/pac_id_resolver/resolver.py +81 -0
- labfreed/pac_id_resolver/services.py +80 -0
- labfreed/qr/__init__.py +1 -0
- labfreed/qr/generate_qr.py +422 -0
- labfreed/trex/__init__.py +16 -0
- labfreed/trex/python_convenience/__init__.py +3 -0
- labfreed/trex/python_convenience/data_table.py +45 -0
- labfreed/trex/python_convenience/pyTREX.py +242 -0
- labfreed/trex/python_convenience/quantity.py +46 -0
- labfreed/trex/table_segment.py +227 -0
- labfreed/trex/trex.py +69 -0
- labfreed/trex/trex_base_models.py +336 -0
- labfreed/trex/value_segments.py +111 -0
- labfreed/{DisplayNameExtension → utilities}/base36.py +29 -13
- labfreed/well_known_extensions/__init__.py +5 -0
- labfreed/well_known_extensions/default_extension_interpreters.py +7 -0
- labfreed/well_known_extensions/display_name_extension.py +40 -0
- labfreed/well_known_extensions/trex_extension.py +31 -0
- labfreed/well_known_keys/gs1/__init__.py +6 -0
- labfreed/well_known_keys/gs1/gs1.py +4 -0
- labfreed/well_known_keys/gs1/gs1_ai_enum_sorted.py +57 -0
- labfreed/well_known_keys/labfreed/well_known_keys.py +16 -0
- labfreed/well_known_keys/unece/UneceUnits.json +33730 -0
- labfreed/well_known_keys/unece/__init__.py +4 -0
- labfreed/well_known_keys/unece/unece_units.py +68 -0
- labfreed-0.2.0.dist-info/METADATA +357 -0
- labfreed-0.2.0.dist-info/RECORD +44 -0
- {labfreed-0.0.4.dist-info → labfreed-0.2.0.dist-info}/WHEEL +1 -1
- labfreed/DisplayNameExtension/DisplayNameExtension.py +0 -34
- labfreed/PAC_CAT/__init__.py +0 -1
- labfreed/PAC_CAT/data_model.py +0 -109
- labfreed/PAC_ID/__init__.py +0 -0
- labfreed/PAC_ID/data_model.py +0 -114
- labfreed/PAC_ID/parse.py +0 -133
- labfreed/PAC_ID/serialize.py +0 -57
- labfreed/TREXExtension/data_model.py +0 -239
- labfreed/TREXExtension/parse.py +0 -46
- labfreed/TREXExtension/uncertainty.py +0 -32
- labfreed/TREXExtension/unit_utilities.py +0 -134
- labfreed-0.0.4.dist-info/METADATA +0 -15
- labfreed-0.0.4.dist-info/RECORD +0 -17
- {labfreed-0.0.4.dist-info → labfreed-0.2.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
from typing import Tuple
|
|
2
|
-
from typing_extensions import Annotated
|
|
3
|
-
from pydantic import BaseModel, AfterValidator
|
|
4
|
-
import quantities as pq
|
|
5
|
-
from quantities import Quantity, UnitQuantity, units, dimensionless
|
|
6
|
-
from .uncertainty import to_significant_digits_str
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def validate_unit(unit_name:str) -> str :
|
|
11
|
-
"""
|
|
12
|
-
Pydantic validator function for the unit.
|
|
13
|
-
Checks if the unit is a valid unit.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
unit (str): unit symbol, e.g. 'kg'
|
|
18
|
-
|
|
19
|
-
Returns:
|
|
20
|
-
str: the input unit.
|
|
21
|
-
|
|
22
|
-
Errors:
|
|
23
|
-
raises an AssertionError if validation fails
|
|
24
|
-
"""
|
|
25
|
-
if hasattr(pq, unit_name):
|
|
26
|
-
return unit_name
|
|
27
|
-
else:
|
|
28
|
-
assert False
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
class PydanticUncertainQuantity(BaseModel):
|
|
32
|
-
data:int|float
|
|
33
|
-
unit_name: Annotated[str, AfterValidator(validate_unit)]
|
|
34
|
-
unit_symbol: str
|
|
35
|
-
uncertainty:float|None=None
|
|
36
|
-
|
|
37
|
-
@property
|
|
38
|
-
def for_display(self):
|
|
39
|
-
return self.__str__()
|
|
40
|
-
|
|
41
|
-
def as_strings(self):
|
|
42
|
-
unit_symbol = self.unit_symbol
|
|
43
|
-
if unit_symbol == "dimensionless":
|
|
44
|
-
unit_symbol = ""
|
|
45
|
-
s = ''
|
|
46
|
-
|
|
47
|
-
val_str = to_significant_digits_str(self.data, self.uncertainty)
|
|
48
|
-
return f"{val_str}", f"{unit_symbol}", f"{val_str} {unit_symbol}"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
def __str__(self):
|
|
53
|
-
unit_symbol = self.unit_symbol
|
|
54
|
-
if unit_symbol == "dimensionless":
|
|
55
|
-
unit_symbol = ""
|
|
56
|
-
|
|
57
|
-
s = f"{to_significant_digits_str(self.data, self.uncertainty)} {unit_symbol}"
|
|
58
|
-
return s
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
unit_map = [
|
|
62
|
-
('MGM', units.milligram),
|
|
63
|
-
('CEL', units.celsius),
|
|
64
|
-
('LTR', units.liter),
|
|
65
|
-
('MLT', units.milliliter),
|
|
66
|
-
('GRM', units.gram),
|
|
67
|
-
('KGM', units.kilogram),
|
|
68
|
-
('C34', units.mole),
|
|
69
|
-
('D43',units.atomic_mass_unit),
|
|
70
|
-
('1', units.dimensionless),
|
|
71
|
-
('C62', units.dimensionless),
|
|
72
|
-
('BAR',units.bar),
|
|
73
|
-
('MBR',units.millibar),
|
|
74
|
-
('KBA',units.kilobar),
|
|
75
|
-
('RPM', units.rpm),
|
|
76
|
-
('HUR', units.hour),
|
|
77
|
-
('HTZ', units.hertz),
|
|
78
|
-
('KHZ', units.kilohertz),
|
|
79
|
-
('MHZ',units.megahertz),
|
|
80
|
-
('SEC', units.second),
|
|
81
|
-
('MIN', units.minute),
|
|
82
|
-
('URH', units.hour)
|
|
83
|
-
|
|
84
|
-
]
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def quantity_from_UN_CEFACT(value:str, unit_UN_CEFACT) -> PydanticUncertainQuantity:
|
|
88
|
-
"""
|
|
89
|
-
Maps units from https://unece.org/trade/documents/revision-17-annexes-i-iii
|
|
90
|
-
to an object of the quantities library https://python-quantities.readthedocs.io/en/latest/index.html
|
|
91
|
-
"""
|
|
92
|
-
# cast to numeric type. try int first, which will fail if string has no decimals.
|
|
93
|
-
# nothing to worry yet: try floast next. if that fails the input was not a str representation of a number
|
|
94
|
-
try:
|
|
95
|
-
value_out = int(value)
|
|
96
|
-
except ValueError:
|
|
97
|
-
try:
|
|
98
|
-
value_out = float(value)
|
|
99
|
-
except ValueError as e:
|
|
100
|
-
raise Exception(f'Input {value} is not a str representation of a number') from e
|
|
101
|
-
|
|
102
|
-
d = {um[0]: um[1] for um in unit_map}
|
|
103
|
-
|
|
104
|
-
unit = d.get(unit_UN_CEFACT)
|
|
105
|
-
if not unit:
|
|
106
|
-
raise NotImplementedError(f"lookup for unit {unit} not implemented")
|
|
107
|
-
out = PydanticUncertainQuantity(data=value_out, unit_name=unit.name, unit_symbol=unit.symbol)
|
|
108
|
-
|
|
109
|
-
return out
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def quantity_to_UN_CEFACT(value:PydanticUncertainQuantity ) -> Tuple[int|float, str]:
|
|
113
|
-
d = {um[1].symbol: um[0] for um in unit_map}
|
|
114
|
-
|
|
115
|
-
unit_un_cefact = d.get(value.unit_symbol)
|
|
116
|
-
if not unit_un_cefact:
|
|
117
|
-
raise NotImplementedError(f"lookup for unit {value.unit_symbol} not implemented")
|
|
118
|
-
return value.data, unit_un_cefact
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
if __name__ == "__main__":
|
|
129
|
-
pass
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: labfreed
|
|
3
|
-
Version: 0.0.4
|
|
4
|
-
Summary: Python implementation of LabFREED building blocks
|
|
5
|
-
Author-email: Reto Thürer <thuerer.r@buchi.com>
|
|
6
|
-
Requires-Python: >=3.10
|
|
7
|
-
Description-Content-Type: text/markdown
|
|
8
|
-
License-Expression: MIT
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
License-File: LICENSE
|
|
12
|
-
|
|
13
|
-
# LabFREED for Python
|
|
14
|
-
|
|
15
|
-
A python implementation of [LabFREED](www.labfreed.com).
|
labfreed-0.0.4.dist-info/RECORD
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
labfreed/__init__.py,sha256=PyF18K_9O9PbwpUrHsMwMVLHyepmCT4UIeVP5iCns90,87
|
|
2
|
-
labfreed/DisplayNameExtension/DisplayNameExtension.py,sha256=FlT53u1EntpsLmho6GZtgIWBZBNWkl9STxzJBvojR6M,1033
|
|
3
|
-
labfreed/DisplayNameExtension/base36.py,sha256=2lwmEMWm8qrFJkcrP-nMPwS0eCm2THhCJ3Vk-TdGQg0,2455
|
|
4
|
-
labfreed/PAC_CAT/__init__.py,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
5
|
-
labfreed/PAC_CAT/data_model.py,sha256=y1cTFZknObi5XOk4aqfgeJv6_G8Rjd9mxTRwNCQR0M4,4311
|
|
6
|
-
labfreed/PAC_ID/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
labfreed/PAC_ID/data_model.py,sha256=oVVqspdZ4B_C4V1rOmcde2_EqWUpDJc6vDUnX4Z1ZPw,3123
|
|
8
|
-
labfreed/PAC_ID/parse.py,sha256=ZmCpuht7o6RgDZCweF7Y0k7QFTd0gLtUpmjFsIlz_wA,4668
|
|
9
|
-
labfreed/PAC_ID/serialize.py,sha256=ujI4SFs-TsFb4FVU2hzwardEWu8-2MYjewE0IyC1yok,1871
|
|
10
|
-
labfreed/TREXExtension/data_model.py,sha256=eT4KyQklTO6m-wA28KyJ8wzT8ONhG3fOB3JU6b19ScY,8011
|
|
11
|
-
labfreed/TREXExtension/parse.py,sha256=Y04UK1KlMLG9tE_d7cQOiAJpm8Zh49UoJYjY7Lfqa4Y,1812
|
|
12
|
-
labfreed/TREXExtension/uncertainty.py,sha256=l3WxrLnWTQYfX28gFisXwDcVPvT8bCAd4q6Xl02dRdE,1117
|
|
13
|
-
labfreed/TREXExtension/unit_utilities.py,sha256=ZhivJnEXMvz7HxLJjI1oJ8y_pcPxW2abKkouiqTo4I4,3775
|
|
14
|
-
labfreed-0.0.4.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
|
|
15
|
-
labfreed-0.0.4.dist-info/WHEEL,sha256=_2ozNFCLWc93bK4WKHCO-eDUENDlo-dgc9cU3qokYO4,82
|
|
16
|
-
labfreed-0.0.4.dist-info/METADATA,sha256=KKfAscBUcBVVNUSHT3KjlqXjA3_fFd5APom23P_Boh0,446
|
|
17
|
-
labfreed-0.0.4.dist-info/RECORD,,
|
|
File without changes
|