labfreed 0.2.5a13__py3-none-any.whl → 0.2.5a15__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.5a13"
5
+ __version__ = "0.2.5a15"
6
6
 
7
7
  from labfreed.pac_id import * # noqa: F403
8
8
  from labfreed.pac_cat import * # noqa: F403
@@ -61,7 +61,7 @@ class DataTable(BaseModel):
61
61
 
62
62
  def get_column(self, col:str|int) -> list:
63
63
  if isinstance(col, str):
64
- col_index = self.col_names.index()
64
+ col_index = self.col_names.index(col)
65
65
  else:
66
66
  col_index = col
67
67
  col_data = [row[col_index] for row in self.data]
@@ -72,14 +72,14 @@ class DataTable(BaseModel):
72
72
  return self.data[row_index]
73
73
 
74
74
 
75
- def get_row_as_dict(self, row_index:int) -> list:
75
+ def get_row_as_dict(self, row_index:int) -> dict:
76
76
  d = {k:v for k, v in zip(self.col_names, self.data[row_index])}
77
77
  return d
78
78
 
79
79
 
80
80
  def get_cell(self, row_index:int, col:str|int):
81
81
  if isinstance(col, str):
82
- col_index = self.col_names.index()
82
+ col_index = self.col_names.index(col)
83
83
  else:
84
84
  col_index = col
85
85
  return self.data[row_index][col_index]
@@ -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', None)
23
+ if 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.5a13
3
+ Version: 0.2.5a15
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=VM3BQHQMSYtH0ZAIY5fZWj4I7KoABakJMjohkJb9X1A,339
1
+ labfreed/__init__.py,sha256=sGeuTG6NG1sI0kXknhWI6jg5Sp7tfxvucgvqdNQ3VYM,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
@@ -23,9 +23,9 @@ labfreed/trex/trex.py,sha256=WDoPvuhiilLtRSIkntCmDGkFBnD6oRZg0E6hhoV-I2g,2400
23
23
  labfreed/trex/trex_base_models.py,sha256=591559BISc82fyIoEP_dq_GHDbPCVzApx7FM3TRQPlY,7545
24
24
  labfreed/trex/value_segments.py,sha256=qizDsinE-ddta8jzkJbGT3OUjHpYhI2GwxjZ6InzLDs,3712
25
25
  labfreed/trex/python_convenience/__init__.py,sha256=dyAQG7t-uYN6VfGXbWIq2bHxGcGI63l7FS2-VPYs2RQ,137
26
- labfreed/trex/python_convenience/data_table.py,sha256=SE1qKJ87XMwwbhcW_sfyZjRxi0QbaFkGpSt_OOJmoNc,3152
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=AQSfzdpbyTeEbwREfBwxBf3IDB-cvty7ivlV-6_f964,2247
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.5a13.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
- labfreed-0.2.5a13.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
- labfreed-0.2.5a13.dist-info/METADATA,sha256=6ymOp3hKT20wDfTkw09wxl6jNzJQUkI9Qpwok22xh4E,18093
44
- labfreed-0.2.5a13.dist-info/RECORD,,
41
+ labfreed-0.2.5a15.dist-info/licenses/LICENSE,sha256=gHFOv9FRKHxO8cInP3YXyPoJnuNeqrvcHjaE_wPSsQ8,1100
42
+ labfreed-0.2.5a15.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
43
+ labfreed-0.2.5a15.dist-info/METADATA,sha256=Jakjy-5Gol8yYoUiDxVWu8TnQ1xsOVkP0fWeX5_-L5w,18093
44
+ labfreed-0.2.5a15.dist-info/RECORD,,