legend-pydataobj 1.11.10__py3-none-any.whl → 1.11.11__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.
- {legend_pydataobj-1.11.10.dist-info → legend_pydataobj-1.11.11.dist-info}/METADATA +1 -1
- {legend_pydataobj-1.11.10.dist-info → legend_pydataobj-1.11.11.dist-info}/RECORD +9 -9
- lgdo/_version.py +2 -2
- lgdo/lh5/datatype.py +5 -1
- lgdo/types/struct.py +52 -2
- {legend_pydataobj-1.11.10.dist-info → legend_pydataobj-1.11.11.dist-info}/WHEEL +0 -0
- {legend_pydataobj-1.11.10.dist-info → legend_pydataobj-1.11.11.dist-info}/entry_points.txt +0 -0
- {legend_pydataobj-1.11.10.dist-info → legend_pydataobj-1.11.11.dist-info}/licenses/LICENSE +0 -0
- {legend_pydataobj-1.11.10.dist-info → legend_pydataobj-1.11.11.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
legend_pydataobj-1.11.
|
1
|
+
legend_pydataobj-1.11.11.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
2
2
|
lgdo/__init__.py,sha256=QMYK9HhoMi0pbahPN8mPD18gyTxscFgo7QKfCxVhy-0,3196
|
3
|
-
lgdo/_version.py,sha256=
|
3
|
+
lgdo/_version.py,sha256=HzpeLL9TNpOYOyQgpvUDsI17SsmttCLNA6_o2M0opbs,515
|
4
4
|
lgdo/cli.py,sha256=s_EWTBWW76l7zWb6gaTSTjiT-0RzzcYEmjeFEQCVxfk,4647
|
5
5
|
lgdo/lgdo_utils.py,sha256=6a2YWEwpyEMXlAyTHZMO01aqxy6SxJzPZkGNWKNWuS0,2567
|
6
6
|
lgdo/lh5_store.py,sha256=5BzbJA9sLcqjp8bJDc2olwOiw0VS6rmfg3cfh1kQkRY,8512
|
@@ -16,7 +16,7 @@ lgdo/compression/varlen.py,sha256=6ZZUItyoOfygDdE0DyoISeFZfqdbH6xl7T0eclfarzg,15
|
|
16
16
|
lgdo/lh5/__init__.py,sha256=y1XE_mpFWwamrl7WVjAVSVB25X4PrEfdVXSneSQEmlQ,825
|
17
17
|
lgdo/lh5/concat.py,sha256=5nO7dNSb0UEP9rZiWGTKH5Cfwsm5LSm3tBJM4Kd70u0,6336
|
18
18
|
lgdo/lh5/core.py,sha256=HT50rolOtTijgaGFskRgzoRbC0w-kxrRS2v9O5Q9Ugo,14067
|
19
|
-
lgdo/lh5/datatype.py,sha256=
|
19
|
+
lgdo/lh5/datatype.py,sha256=ry3twFaosuBoskiTKqtBYRMk9PQAf403593xKaItfog,1827
|
20
20
|
lgdo/lh5/exceptions.py,sha256=3kj8avXl4eBGvebl3LG12gJEmw91W0T8PYR0AfvUAyM,1211
|
21
21
|
lgdo/lh5/iterator.py,sha256=ZaBBnmuNIjinwO0JUY55wLxX8Om9rVRRzXBC5uHmSKM,19772
|
22
22
|
lgdo/lh5/store.py,sha256=3wAaQDd1Zmo0_bQ9DbB-FbKS4Uy_Tb642qKHXtZpSw4,10643
|
@@ -44,13 +44,13 @@ lgdo/types/fixedsizearray.py,sha256=7RjUwTz1bW0pcrdy27JlfrXPAuOU89Kj7pOuSUCojK8,
|
|
44
44
|
lgdo/types/histogram.py,sha256=y6j2VDuGYYnLy7WI4J90ApS0PAwic4kCpouZPX09Nus,19974
|
45
45
|
lgdo/types/lgdo.py,sha256=RQ2P70N7IWMBDnLLuJI3sm6zQTIKyOMSsKZtBNzmE90,2928
|
46
46
|
lgdo/types/scalar.py,sha256=c5Es2vyDqyWTPV6mujzfIzMpC1jNWkEIcvYyWQUxH3Q,1933
|
47
|
-
lgdo/types/struct.py,sha256=
|
47
|
+
lgdo/types/struct.py,sha256=m3pYfGfKptV8ti3wb4n1nsPKMvhjdWCFoRdR5YooZBM,6353
|
48
48
|
lgdo/types/table.py,sha256=VIHQOPXJHJgiCjMMb_p7EdbcCqLFSObHMdHSxC1Dm5Y,19212
|
49
49
|
lgdo/types/vectorofvectors.py,sha256=K8w7CZou857I9YGkeOe2uYB20gbHl4OV9xhnnJPNOjc,24665
|
50
50
|
lgdo/types/vovutils.py,sha256=7BWPP0BSj-92ifbCIUBcfqxG5-TS8uxujTyJJuDFI04,10302
|
51
51
|
lgdo/types/waveformtable.py,sha256=f2tS4f1OEoYaTM5ldCX9zmw8iSISCT3t3wS1SrPdu_o,9901
|
52
|
-
legend_pydataobj-1.11.
|
53
|
-
legend_pydataobj-1.11.
|
54
|
-
legend_pydataobj-1.11.
|
55
|
-
legend_pydataobj-1.11.
|
56
|
-
legend_pydataobj-1.11.
|
52
|
+
legend_pydataobj-1.11.11.dist-info/METADATA,sha256=31ymnKEL5SpQecBon8Pg_SuL7axx4VityFgjGpm46bM,44444
|
53
|
+
legend_pydataobj-1.11.11.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
|
54
|
+
legend_pydataobj-1.11.11.dist-info/entry_points.txt,sha256=0KWfnwbuwhNn0vPUqARukjp04Ca6lzfZBSirouRmk7I,76
|
55
|
+
legend_pydataobj-1.11.11.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
|
56
|
+
legend_pydataobj-1.11.11.dist-info/RECORD,,
|
lgdo/_version.py
CHANGED
lgdo/lh5/datatype.py
CHANGED
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
2
2
|
|
3
3
|
import re
|
4
4
|
from collections import OrderedDict
|
5
|
+
from itertools import permutations as perm
|
5
6
|
|
6
7
|
from .. import types as lgdo
|
7
8
|
|
@@ -14,7 +15,10 @@ _lgdo_datatype_map: dict[str, lgdo.LGDO] = OrderedDict(
|
|
14
15
|
lgdo.ArrayOfEncodedEqualSizedArrays,
|
15
16
|
r"^array_of_encoded_equalsized_arrays<1,1>\{.+\}$",
|
16
17
|
),
|
17
|
-
(
|
18
|
+
(
|
19
|
+
lgdo.Histogram,
|
20
|
+
rf"^struct\{{(?:{'|'.join([','.join(p) for p in perm(['binning', 'weights', 'isdensity'])])})\}}$",
|
21
|
+
),
|
18
22
|
(lgdo.Struct, r"^struct\{.*\}$"),
|
19
23
|
(lgdo.Table, r"^table\{.*\}$"),
|
20
24
|
(lgdo.FixedSizeArray, r"^fixedsize_array<\d+>\{.+\}$"),
|
lgdo/types/struct.py
CHANGED
@@ -5,7 +5,9 @@ utilities.
|
|
5
5
|
|
6
6
|
from __future__ import annotations
|
7
7
|
|
8
|
+
import copy
|
8
9
|
import logging
|
10
|
+
import re
|
9
11
|
from collections.abc import Mapping
|
10
12
|
from typing import Any
|
11
13
|
|
@@ -56,7 +58,21 @@ class Struct(LGDO, dict):
|
|
56
58
|
# assign
|
57
59
|
super().update({k: v})
|
58
60
|
|
59
|
-
#
|
61
|
+
# check the datatype attribute passed by the user and sort the fields
|
62
|
+
# to ensure consistent behavior
|
63
|
+
if attrs is not None and "datatype" in attrs:
|
64
|
+
_attrs = copy.copy(dict(attrs))
|
65
|
+
|
66
|
+
if not _is_struct_datatype(self.datatype_name(), _attrs["datatype"]):
|
67
|
+
msg = (
|
68
|
+
f"datatype attribute ({self.attrs['datatype']}) is not "
|
69
|
+
f"compatible with class datatype!"
|
70
|
+
)
|
71
|
+
raise ValueError(msg)
|
72
|
+
|
73
|
+
_attrs["datatype"] = _sort_datatype_fields(_attrs["datatype"])
|
74
|
+
attrs = _attrs
|
75
|
+
|
60
76
|
super().__init__(attrs)
|
61
77
|
|
62
78
|
def datatype_name(self) -> str:
|
@@ -64,7 +80,10 @@ class Struct(LGDO, dict):
|
|
64
80
|
|
65
81
|
def form_datatype(self) -> str:
|
66
82
|
return (
|
67
|
-
self.datatype_name()
|
83
|
+
self.datatype_name()
|
84
|
+
+ "{"
|
85
|
+
+ ",".join(sorted([str(k) for k in self.keys()]))
|
86
|
+
+ "}"
|
68
87
|
)
|
69
88
|
|
70
89
|
def update_datatype(self) -> None:
|
@@ -157,3 +176,34 @@ class Struct(LGDO, dict):
|
|
157
176
|
"not possible. Call view_as() on the fields instead."
|
158
177
|
)
|
159
178
|
raise NotImplementedError(msg)
|
179
|
+
|
180
|
+
|
181
|
+
def _is_struct_datatype(dt_name, expr):
|
182
|
+
return re.search("^" + dt_name + r"\{(.*)\}$", expr) is not None
|
183
|
+
|
184
|
+
|
185
|
+
def _get_struct_fields(expr: str) -> list[str]:
|
186
|
+
assert _is_struct_datatype(".*", expr)
|
187
|
+
|
188
|
+
arr = re.search(r"\{(.*)\}$", expr).group(1).split(",")
|
189
|
+
if arr == [""]:
|
190
|
+
arr = []
|
191
|
+
|
192
|
+
return sorted(arr)
|
193
|
+
|
194
|
+
|
195
|
+
def _struct_datatype_equal(dt_name, dt1, dt2):
|
196
|
+
if any(not _is_struct_datatype(dt_name, dt) for dt in (dt1, dt2)):
|
197
|
+
return False
|
198
|
+
|
199
|
+
return _get_struct_fields(dt1) == _get_struct_fields(dt2)
|
200
|
+
|
201
|
+
|
202
|
+
def _sort_datatype_fields(expr):
|
203
|
+
assert _is_struct_datatype(".*", expr)
|
204
|
+
|
205
|
+
match = re.search(r"^(.*)\{.*\}$", expr)
|
206
|
+
struct_type = match.group(1)
|
207
|
+
fields = _get_struct_fields(expr)
|
208
|
+
|
209
|
+
return struct_type + "{" + ",".join(sorted([str(k) for k in fields])) + "}"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|