labfreed 0.2.5a14__py3-none-any.whl → 0.2.5a16__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 CHANGED
@@ -2,7 +2,7 @@
2
2
  Python implementation of LabFREED building blocks
3
3
  '''
4
4
 
5
- __version__ = "0.2.5a14"
5
+ __version__ = "0.2.5a16"
6
6
 
7
7
  from labfreed.pac_id import * # noqa: F403
8
8
  from labfreed.pac_cat import * # noqa: F403
@@ -7,12 +7,27 @@ class Quantity(BaseModel):
7
7
  value: float|int
8
8
  unit: str | None
9
9
  '''unit. Use SI symbols. Set to None of the Quantity is dimensionless'''
10
- significant_digits: int|None = None
10
+ log_least_significant_digit: int|None = None
11
+
12
+ @model_validator(mode='before')
13
+ @classmethod
14
+ def decimals_to_log_significant_digits(cls, d:dict):
15
+ if decimals:= d.pop('decimals', None):
16
+ d['log_least_significant_digit'] = - decimals
17
+ return d
18
+
19
+ @model_validator(mode='before')
20
+ @classmethod
21
+ def dimensionless_unit(cls, d:dict):
22
+ unit= d.get('decimals')
23
+ if unit and unit in ['1', '', 'dimensionless']:
24
+ d['unit'] = None
25
+ return d
11
26
 
12
27
  @model_validator(mode='after')
13
28
  def significat_digits_for_int(self):
14
29
  if isinstance(self.value, int):
15
- self.significant_digits = 0
30
+ self.log_least_significant_digit = 0
16
31
  return self
17
32
 
18
33
  @property
@@ -24,8 +39,8 @@ class Quantity(BaseModel):
24
39
  unit_symbol = self.unit
25
40
  if self.unit == "dimensionless" or not self.unit:
26
41
  unit_symbol = ""
27
- if self.significant_digits is not None:
28
- val = f"{self.value:.{self.significant_digits}f}"
42
+ if self.log_least_significant_digit is not None:
43
+ val = f"{self.value:.{self.log_least_significant_digit}f}"
29
44
  else:
30
45
  val = str(self.value)
31
46
  return f"{val} {unit_symbol}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: labfreed
3
- Version: 0.2.5a14
3
+ Version: 0.2.5a16
4
4
  Summary: Python implementation of LabFREED building blocks
5
5
  Author-email: Reto Thürer <thuerer.r@buchi.com>
6
6
  Requires-Python: >=3.11
@@ -1,4 +1,4 @@
1
- labfreed/__init__.py,sha256=Xk43nuTS15q2hVs80RmBDzHe4t2hTf3ftguCEPNi4UY,339
1
+ labfreed/__init__.py,sha256=W9MSpeMsumM8UJ4mP7IvSHEoqPhh6-0Gf_6Gnvy9MKE,339
2
2
  labfreed/labfreed_infrastructure.py,sha256=yxZkI0mPrHyeZGWKtgFIV9R54edSUcww-w1ExHt8F-o,9990
3
3
  labfreed/pac_cat/__init__.py,sha256=KNPtQzBD1XVohvG_ucOs7RJj-oi6biUTGB1k-T2o6pk,568
4
4
  labfreed/pac_cat/category_base.py,sha256=lFQNiTUukyhWdaSCAI7CZxLtj6kNtnBCE4UsePwsGqE,1801
@@ -25,7 +25,7 @@ labfreed/trex/value_segments.py,sha256=qizDsinE-ddta8jzkJbGT3OUjHpYhI2GwxjZ6InzL
25
25
  labfreed/trex/python_convenience/__init__.py,sha256=dyAQG7t-uYN6VfGXbWIq2bHxGcGI63l7FS2-VPYs2RQ,137
26
26
  labfreed/trex/python_convenience/data_table.py,sha256=De0UMVCUUPeK-bUTToRTvL88EywHf6EOPYjgoUHsUpA,3158
27
27
  labfreed/trex/python_convenience/pyTREX.py,sha256=U026jtsESo1h2H_EQi11A9AksafjRXgRsbWOwmI9z0E,10147
28
- labfreed/trex/python_convenience/quantity.py,sha256=NlbKsXmr-nvN42gLw1gGn7GVRTdaIuYZky7SLekdhI8,1729
28
+ labfreed/trex/python_convenience/quantity.py,sha256=WAP1gyq3OaurEeT3o_0vIWnJ5HrVpgeKnu14i0Y_KDU,2250
29
29
  labfreed/utilities/base36.py,sha256=_yX8aQ1OwrK5tnJU1NUEzQSFGr9xAVnNvPObpNzCPYs,2895
30
30
  labfreed/well_known_extensions/__init__.py,sha256=CjZTjx8Cn8763Hhnv_--Wj1LcFpFs2cyQwWrrzOS4xM,246
31
31
  labfreed/well_known_extensions/default_extension_interpreters.py,sha256=3-BkJrAyBa99NN5Q2QPAm59CcWmPket-rvLzgltp8KY,201
@@ -38,7 +38,7 @@ labfreed/well_known_keys/labfreed/well_known_keys.py,sha256=nqk66kHdSwJTJfMKlP-x
38
38
  labfreed/well_known_keys/unece/UneceUnits.json,sha256=kwfQSp_nTuWbADfBBgqTWrvPl6XtM5SedEVLbMJrM7M,898953
39
39
  labfreed/well_known_keys/unece/__init__.py,sha256=MSP9lmjg9_D9iqG9Yq2_ajYfQSNS9wIT7FXA1c--59M,122
40
40
  labfreed/well_known_keys/unece/unece_units.py,sha256=gNDQk6KGl-nGMf9Ycq_fQ8P2xxKITgLkcQWPd4H49gI,1630
41
- labfreed-0.2.5a14.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
- labfreed-0.2.5a14.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
- labfreed-0.2.5a14.dist-info/METADATA,sha256=5KFMLd3qSQBPKYmrUwVdTOxzr9t5lxZojhw3dDVS63o,18093
44
- labfreed-0.2.5a14.dist-info/RECORD,,
41
+ labfreed-0.2.5a16.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
+ labfreed-0.2.5a16.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
+ labfreed-0.2.5a16.dist-info/METADATA,sha256=pOBpp28qMsluJhXrgO-rnffPEiofIVQEKAfcMNQOHSc,18093
44
+ labfreed-0.2.5a16.dist-info/RECORD,,