legend-pydataobj 1.11.1__py3-none-any.whl → 1.11.3__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.1.dist-info → legend_pydataobj-1.11.3.dist-info}/METADATA +2 -2
- {legend_pydataobj-1.11.1.dist-info → legend_pydataobj-1.11.3.dist-info}/RECORD +17 -17
- {legend_pydataobj-1.11.1.dist-info → legend_pydataobj-1.11.3.dist-info}/WHEEL +1 -1
- lgdo/__init__.py +6 -6
- lgdo/_version.py +2 -2
- lgdo/compression/__init__.py +3 -3
- lgdo/lh5/__init__.py +2 -2
- lgdo/lh5/_serializers/__init__.py +10 -10
- lgdo/lh5/_serializers/read/vector_of_vectors.py +3 -2
- lgdo/lh5/exceptions.py +6 -0
- lgdo/types/__init__.py +3 -3
- lgdo/types/histogram.py +8 -3
- lgdo/types/lgdo.py +6 -0
- lgdo/types/table.py +21 -2
- {legend_pydataobj-1.11.1.dist-info → legend_pydataobj-1.11.3.dist-info}/LICENSE +0 -0
- {legend_pydataobj-1.11.1.dist-info → legend_pydataobj-1.11.3.dist-info}/entry_points.txt +0 -0
- {legend_pydataobj-1.11.1.dist-info → legend_pydataobj-1.11.3.dist-info}/top_level.txt +0 -0
@@ -1,26 +1,26 @@
|
|
1
|
-
lgdo/__init__.py,sha256=
|
2
|
-
lgdo/_version.py,sha256=
|
1
|
+
lgdo/__init__.py,sha256=QMYK9HhoMi0pbahPN8mPD18gyTxscFgo7QKfCxVhy-0,3196
|
2
|
+
lgdo/_version.py,sha256=T2YM9w8KO8zThn0UoO-QJVXyTdR0uuWyR6VszamBivY,413
|
3
3
|
lgdo/cli.py,sha256=Qm2EPmoIVxENAR8BeW7oWpTdHT4GbV-owfzM5NkgjvM,9353
|
4
4
|
lgdo/lgdo_utils.py,sha256=6a2YWEwpyEMXlAyTHZMO01aqxy6SxJzPZkGNWKNWuS0,2567
|
5
5
|
lgdo/lh5_store.py,sha256=5BzbJA9sLcqjp8bJDc2olwOiw0VS6rmfg3cfh1kQkRY,8512
|
6
6
|
lgdo/logging.py,sha256=82wIOj7l7xr3WYyeHdpSXbbjzHJsy-uRyKYUYx2vMfQ,1003
|
7
7
|
lgdo/units.py,sha256=VQYME86_ev9S7Fq8RyCOQNqYr29MphTTYemmEouZafk,161
|
8
8
|
lgdo/utils.py,sha256=WRTmXnaQ-h2hVxwJ27qiOigdsD3DHcaDrdDjvupCuZU,3940
|
9
|
-
lgdo/compression/__init__.py,sha256=
|
9
|
+
lgdo/compression/__init__.py,sha256=xHt_8Th0LxxNwj9iYHf5uGNTm3A_4qyW7zEVdAX3NwI,1127
|
10
10
|
lgdo/compression/base.py,sha256=82cQJujfvoAOKBFx761dEcx_xM02TBCBBuBo6i78tuI,838
|
11
11
|
lgdo/compression/generic.py,sha256=tF3UhLJbUDcovLxpIzgQRxFSjZ5Fz3uDRy9kI4mFntQ,2515
|
12
12
|
lgdo/compression/radware.py,sha256=GcNTtjuyL7VBBqziUBmSqNXuhqy1bJJgvcyvyumPtrc,23839
|
13
13
|
lgdo/compression/utils.py,sha256=W2RkBrxPpXlat84dnU9Ad7d_tTws0irtGl7O1dNWjnk,1140
|
14
14
|
lgdo/compression/varlen.py,sha256=6ZZUItyoOfygDdE0DyoISeFZfqdbH6xl7T0eclfarzg,15127
|
15
|
-
lgdo/lh5/__init__.py,sha256=
|
15
|
+
lgdo/lh5/__init__.py,sha256=FflSA1LF3RTom1YvlGmTleJcl1ytxwez8B_Hn_o10wU,811
|
16
16
|
lgdo/lh5/core.py,sha256=__-A6Abctzfwfo4-xJi68xs2e4vfzONEQTJVrUCOw-I,13922
|
17
17
|
lgdo/lh5/datatype.py,sha256=O_7BqOlX8PFMyG0ppkfUT5aps5HEqX0bpuKcJO3jhu0,1691
|
18
|
-
lgdo/lh5/exceptions.py,sha256=
|
18
|
+
lgdo/lh5/exceptions.py,sha256=3kj8avXl4eBGvebl3LG12gJEmw91W0T8PYR0AfvUAyM,1211
|
19
19
|
lgdo/lh5/iterator.py,sha256=ZaBBnmuNIjinwO0JUY55wLxX8Om9rVRRzXBC5uHmSKM,19772
|
20
20
|
lgdo/lh5/store.py,sha256=3wAaQDd1Zmo0_bQ9DbB-FbKS4Uy_Tb642qKHXtZpSw4,10643
|
21
21
|
lgdo/lh5/tools.py,sha256=T9CgHA8A3_tVBMtiNJ6hATQKhdqI61m3cX4p2wGKc6c,9937
|
22
22
|
lgdo/lh5/utils.py,sha256=ioz8DlyXZsejwnU2qYdIccdHcF12H62jgLkZsiDOLSM,6243
|
23
|
-
lgdo/lh5/_serializers/__init__.py,sha256=
|
23
|
+
lgdo/lh5/_serializers/__init__.py,sha256=eZzxMp1SeZWG0PkEXUiCz3XyprQ8EmelHUmJogC8xYE,1263
|
24
24
|
lgdo/lh5/_serializers/read/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
25
25
|
lgdo/lh5/_serializers/read/array.py,sha256=uWfMCihfAmW2DE2ewip2qCK_kvQC_mb2zvOv26uzijc,1000
|
26
26
|
lgdo/lh5/_serializers/read/composite.py,sha256=yTm5dfTgkIL7eG9iZXxhdiRhG04cQLd_hybP4wmxCJE,11809
|
@@ -28,28 +28,28 @@ lgdo/lh5/_serializers/read/encoded.py,sha256=Q98c08d8LkZq2AlY4rThYECVaEqwbv4T2Ur
|
|
28
28
|
lgdo/lh5/_serializers/read/ndarray.py,sha256=lFCXD6bSzmMOH7cVmvRYXakkfMCI8EoqTPNONRJ1F0s,3690
|
29
29
|
lgdo/lh5/_serializers/read/scalar.py,sha256=kwhWm1T91pXf86CqtUUD8_qheSR92gXZrQVtssV5YCg,922
|
30
30
|
lgdo/lh5/_serializers/read/utils.py,sha256=USacxDA0eY-u9lDOZDuJHcScoSVMNeAYljmRvW0T1Jk,7587
|
31
|
-
lgdo/lh5/_serializers/read/vector_of_vectors.py,sha256=
|
31
|
+
lgdo/lh5/_serializers/read/vector_of_vectors.py,sha256=Fqh2gXFqeR2y0ofQn4GoSdSAATPvHiuBzzcgL16e6ss,7205
|
32
32
|
lgdo/lh5/_serializers/write/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
33
33
|
lgdo/lh5/_serializers/write/array.py,sha256=eyVPwwddVOR9TNNyliCNYlS-XYXsdTEA8QoTnnOYJbw,2943
|
34
34
|
lgdo/lh5/_serializers/write/composite.py,sha256=I6lH0nWFIpAfZyG4-0rLxzg3mfazZ_FEhQVp1FZ0aA4,9254
|
35
35
|
lgdo/lh5/_serializers/write/scalar.py,sha256=JPt_fcdTKOSFp5hfJdcKIfK4hxhcD8vhOlvDF-7btQ8,763
|
36
36
|
lgdo/lh5/_serializers/write/vector_of_vectors.py,sha256=puGQX9XF5P_5DVbm_Cc6TvPrsDywgBLSYtkqFNltbB4,3493
|
37
|
-
lgdo/types/__init__.py,sha256=
|
37
|
+
lgdo/types/__init__.py,sha256=DNfOErPiAZg-7Gygkp6ZKAi20Yrm1mfderZHvKo1Y4s,821
|
38
38
|
lgdo/types/array.py,sha256=sUxh1CNCaefrnybt5qdjmmMpVQa_RqFxUv1tJ_pyBbc,6537
|
39
39
|
lgdo/types/arrayofequalsizedarrays.py,sha256=DOGJiTmc1QCdm7vLbE6uIRXoMPtt8uuCfmwQawgWf5s,4949
|
40
40
|
lgdo/types/encoded.py,sha256=JW4U5ow7KLMzhKnmhdnxbC3SZJAs4bOEDZWKG4KY1uU,15293
|
41
41
|
lgdo/types/fixedsizearray.py,sha256=7RjUwTz1bW0pcrdy27JlfrXPAuOU89Kj7pOuSUCojK8,1527
|
42
|
-
lgdo/types/histogram.py,sha256=
|
43
|
-
lgdo/types/lgdo.py,sha256=
|
42
|
+
lgdo/types/histogram.py,sha256=y6j2VDuGYYnLy7WI4J90ApS0PAwic4kCpouZPX09Nus,19974
|
43
|
+
lgdo/types/lgdo.py,sha256=RQ2P70N7IWMBDnLLuJI3sm6zQTIKyOMSsKZtBNzmE90,2928
|
44
44
|
lgdo/types/scalar.py,sha256=c5Es2vyDqyWTPV6mujzfIzMpC1jNWkEIcvYyWQUxH3Q,1933
|
45
45
|
lgdo/types/struct.py,sha256=Q0OWLVd4B0ciLb8t6VsxU3MPbmGLZ7WfQNno1lSQS0Q,4918
|
46
|
-
lgdo/types/table.py,sha256=
|
46
|
+
lgdo/types/table.py,sha256=KPxKeLKqKQPkC_H75XraW0c1KRAhDdyGKBktVkD-KLw,18779
|
47
47
|
lgdo/types/vectorofvectors.py,sha256=cic9PsZ5EptQ6RMsykYeVHA8T7fh_KBZCcqeTP4i1wU,24395
|
48
48
|
lgdo/types/vovutils.py,sha256=7BWPP0BSj-92ifbCIUBcfqxG5-TS8uxujTyJJuDFI04,10302
|
49
49
|
lgdo/types/waveformtable.py,sha256=f2tS4f1OEoYaTM5ldCX9zmw8iSISCT3t3wS1SrPdu_o,9901
|
50
|
-
legend_pydataobj-1.11.
|
51
|
-
legend_pydataobj-1.11.
|
52
|
-
legend_pydataobj-1.11.
|
53
|
-
legend_pydataobj-1.11.
|
54
|
-
legend_pydataobj-1.11.
|
55
|
-
legend_pydataobj-1.11.
|
50
|
+
legend_pydataobj-1.11.3.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
51
|
+
legend_pydataobj-1.11.3.dist-info/METADATA,sha256=rYpLl_oH_V8OMAXKOb-0YOl_Y_GdtCfi91ZnrI7rVTU,44382
|
52
|
+
legend_pydataobj-1.11.3.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
53
|
+
legend_pydataobj-1.11.3.dist-info/entry_points.txt,sha256=Uu5MTlppBZxB4QGlLv-oX8FqACWjAZDNii__TBDJwLQ,72
|
54
|
+
legend_pydataobj-1.11.3.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
|
55
|
+
legend_pydataobj-1.11.3.dist-info/RECORD,,
|
lgdo/__init__.py
CHANGED
@@ -62,23 +62,23 @@ from .types import (
|
|
62
62
|
)
|
63
63
|
|
64
64
|
__all__ = [
|
65
|
+
"LGDO",
|
65
66
|
"Array",
|
66
|
-
"ArrayOfEqualSizedArrays",
|
67
67
|
"ArrayOfEncodedEqualSizedArrays",
|
68
|
+
"ArrayOfEqualSizedArrays",
|
68
69
|
"FixedSizeArray",
|
69
70
|
"Histogram",
|
70
|
-
"
|
71
|
+
"LH5Iterator",
|
72
|
+
"LH5Store",
|
71
73
|
"Scalar",
|
72
74
|
"Struct",
|
73
75
|
"Table",
|
74
|
-
"VectorOfVectors",
|
75
76
|
"VectorOfEncodedVectors",
|
77
|
+
"VectorOfVectors",
|
76
78
|
"WaveformTable",
|
79
|
+
"__version__",
|
77
80
|
"load_dfs",
|
78
81
|
"load_nda",
|
79
82
|
"ls",
|
80
83
|
"show",
|
81
|
-
"LH5Iterator",
|
82
|
-
"LH5Store",
|
83
|
-
"__version__",
|
84
84
|
]
|
lgdo/_version.py
CHANGED
lgdo/compression/__init__.py
CHANGED
lgdo/lh5/__init__.py
CHANGED
@@ -24,22 +24,22 @@ from .write.scalar import _h5_write_scalar
|
|
24
24
|
from .write.vector_of_vectors import _h5_write_vector_of_vectors
|
25
25
|
|
26
26
|
__all__ = [
|
27
|
-
"_h5_read_lgdo",
|
28
|
-
"_h5_read_vector_of_vectors",
|
29
|
-
"_h5_read_ndarray",
|
30
27
|
"_h5_read_array",
|
28
|
+
"_h5_read_array_of_encoded_equalsized_arrays",
|
29
|
+
"_h5_read_array_of_equalsized_arrays",
|
31
30
|
"_h5_read_encoded_array",
|
32
31
|
"_h5_read_fixedsize_array",
|
33
|
-
"_h5_read_array_of_equalsized_arrays",
|
34
|
-
"_h5_read_struct",
|
35
|
-
"_h5_read_table",
|
36
32
|
"_h5_read_histogram",
|
33
|
+
"_h5_read_lgdo",
|
34
|
+
"_h5_read_ndarray",
|
37
35
|
"_h5_read_scalar",
|
38
|
-
"
|
36
|
+
"_h5_read_struct",
|
37
|
+
"_h5_read_table",
|
39
38
|
"_h5_read_vector_of_encoded_vectors",
|
40
|
-
"
|
39
|
+
"_h5_read_vector_of_vectors",
|
41
40
|
"_h5_write_array",
|
42
|
-
"_h5_write_vector_of_vectors",
|
43
|
-
"_h5_write_struct",
|
44
41
|
"_h5_write_lgdo",
|
42
|
+
"_h5_write_scalar",
|
43
|
+
"_h5_write_struct",
|
44
|
+
"_h5_write_vector_of_vectors",
|
45
45
|
]
|
@@ -189,8 +189,9 @@ def _h5_read_vector_of_vectors(
|
|
189
189
|
# if the buffer is partially filled, cumulative_length will be invalid
|
190
190
|
# (i.e. non monotonically increasing). Let's fix that but filling the
|
191
191
|
# rest of the array with the length of flattened_data
|
192
|
-
|
193
|
-
|
192
|
+
if n_rows_read > 0:
|
193
|
+
end = obj_buf_start + n_rows_read
|
194
|
+
obj_buf.cumulative_length.nda[end:] = obj_buf.cumulative_length.nda[end - 1]
|
194
195
|
|
195
196
|
return obj_buf, n_rows_read
|
196
197
|
|
lgdo/lh5/exceptions.py
CHANGED
@@ -16,6 +16,9 @@ class LH5DecodeError(Exception):
|
|
16
16
|
+ super().__str__()
|
17
17
|
)
|
18
18
|
|
19
|
+
def __reduce__(self) -> tuple: # for pickling.
|
20
|
+
return self.__class__, (*self.args, self.file, self.obj)
|
21
|
+
|
19
22
|
|
20
23
|
class LH5EncodeError(Exception):
|
21
24
|
def __init__(
|
@@ -32,3 +35,6 @@ class LH5EncodeError(Exception):
|
|
32
35
|
f"while writing object {self.group}/{self.name} to file {self.file}: "
|
33
36
|
+ super().__str__()
|
34
37
|
)
|
38
|
+
|
39
|
+
def __reduce__(self) -> tuple: # for pickling.
|
40
|
+
return self.__class__, (*self.args, self.file, self.group, self.name)
|
lgdo/types/__init__.py
CHANGED
@@ -15,17 +15,17 @@ from .vectorofvectors import VectorOfVectors
|
|
15
15
|
from .waveformtable import WaveformTable
|
16
16
|
|
17
17
|
__all__ = [
|
18
|
+
"LGDO",
|
18
19
|
"Array",
|
19
|
-
"ArrayOfEqualSizedArrays",
|
20
20
|
"ArrayOfEncodedEqualSizedArrays",
|
21
|
+
"ArrayOfEqualSizedArrays",
|
21
22
|
"FixedSizeArray",
|
22
23
|
"Histogram",
|
23
|
-
"LGDO",
|
24
24
|
"Scalar",
|
25
25
|
"Struct",
|
26
26
|
"Table",
|
27
|
-
"VectorOfVectors",
|
28
27
|
"VectorOfEncodedVectors",
|
28
|
+
"VectorOfVectors",
|
29
29
|
"WaveformTable",
|
30
30
|
]
|
31
31
|
|
lgdo/types/histogram.py
CHANGED
@@ -418,13 +418,18 @@ class Histogram(Struct):
|
|
418
418
|
|
419
419
|
def __setitem__(self, name: str, obj: LGDO) -> None:
|
420
420
|
# do not allow for new attributes on this
|
421
|
-
|
422
|
-
|
421
|
+
known_keys = ("binning", "weights", "isdensity")
|
422
|
+
if name in known_keys and not dict.__contains__(self, name):
|
423
|
+
# but allow initialization while unpickling (after __init__() this is unreachable)
|
424
|
+
dict.__setitem__(self, name, obj)
|
425
|
+
else:
|
426
|
+
msg = "histogram fields cannot be mutated "
|
427
|
+
raise TypeError(msg)
|
423
428
|
|
424
429
|
def __getattr__(self, name: str) -> None:
|
425
430
|
# do not allow for new attributes on this
|
426
431
|
msg = "histogram fields cannot be mutated"
|
427
|
-
raise
|
432
|
+
raise AttributeError(msg)
|
428
433
|
|
429
434
|
def add_field(self, name: str | int, obj: LGDO) -> None: # noqa: ARG002
|
430
435
|
"""
|
lgdo/types/lgdo.py
CHANGED
@@ -11,6 +11,12 @@ import pandas as pd
|
|
11
11
|
class LGDO(ABC):
|
12
12
|
"""Abstract base class representing a LEGEND Data Object (LGDO)."""
|
13
13
|
|
14
|
+
def __new__(cls, *_args, **_kwargs):
|
15
|
+
# allow for (un-)pickling LGDO objects.
|
16
|
+
obj = super().__new__(cls)
|
17
|
+
obj.attrs = {}
|
18
|
+
return obj
|
19
|
+
|
14
20
|
@abstractmethod
|
15
21
|
def __init__(self, attrs: dict[str, Any] | None = None) -> None:
|
16
22
|
self.attrs = {} if attrs is None else dict(attrs)
|
lgdo/types/table.py
CHANGED
@@ -7,6 +7,7 @@ from __future__ import annotations
|
|
7
7
|
|
8
8
|
import logging
|
9
9
|
from collections.abc import Mapping
|
10
|
+
from types import ModuleType
|
10
11
|
from typing import Any
|
11
12
|
from warnings import warn
|
12
13
|
|
@@ -40,6 +41,12 @@ class Table(Struct):
|
|
40
41
|
:meth:`__len__` to access valid data, which returns the ``size`` attribute.
|
41
42
|
"""
|
42
43
|
|
44
|
+
def __new__(cls, *args, **kwargs):
|
45
|
+
# allow for (un-)pickling LGDO objects.
|
46
|
+
obj = super().__new__(cls, *args, **kwargs)
|
47
|
+
obj.size = None
|
48
|
+
return obj
|
49
|
+
|
43
50
|
def __init__(
|
44
51
|
self,
|
45
52
|
col_dict: Mapping[str, LGDO] | pd.DataFrame | ak.Array | None = None,
|
@@ -266,6 +273,7 @@ class Table(Struct):
|
|
266
273
|
self,
|
267
274
|
expr: str,
|
268
275
|
parameters: Mapping[str, str] | None = None,
|
276
|
+
modules: Mapping[str, ModuleType] | None = None,
|
269
277
|
) -> LGDO:
|
270
278
|
"""Apply column operations to the table and return a new LGDO.
|
271
279
|
|
@@ -299,6 +307,10 @@ class Table(Struct):
|
|
299
307
|
a dictionary of function parameters. Passed to
|
300
308
|
:func:`numexpr.evaluate`` as `local_dict` argument or to
|
301
309
|
:func:`eval` as `locals` argument.
|
310
|
+
modules
|
311
|
+
a dictionary of additional modules used by the expression. If this is not `None`
|
312
|
+
then :func:`eval`is used and the expression can depend on any modules from this dictionary in
|
313
|
+
addition to awkward and numpy. These are passed to :func:`eval` as `globals` argument.
|
302
314
|
|
303
315
|
Examples
|
304
316
|
--------
|
@@ -339,8 +351,8 @@ class Table(Struct):
|
|
339
351
|
msg = f"evaluating {expr!r} with locals={(self_unwrap | parameters)} and {has_ak=}"
|
340
352
|
log.debug(msg)
|
341
353
|
|
342
|
-
# use numexpr if we are only dealing with numpy data types
|
343
|
-
if not has_ak:
|
354
|
+
# use numexpr if we are only dealing with numpy data types (and no global dictionary)
|
355
|
+
if not has_ak and modules is None:
|
344
356
|
out_data = ne.evaluate(
|
345
357
|
expr,
|
346
358
|
local_dict=(self_unwrap | parameters),
|
@@ -366,6 +378,9 @@ class Table(Struct):
|
|
366
378
|
|
367
379
|
# resort to good ol' eval()
|
368
380
|
globs = {"ak": ak, "np": np}
|
381
|
+
if modules is not None:
|
382
|
+
globs = globs | modules
|
383
|
+
|
369
384
|
out_data = eval(expr, globs, (self_unwrap | parameters))
|
370
385
|
|
371
386
|
msg = f"...the result is {out_data!r}"
|
@@ -380,6 +395,10 @@ class Table(Struct):
|
|
380
395
|
if np.isscalar(out_data):
|
381
396
|
return Scalar(out_data)
|
382
397
|
|
398
|
+
# if out_data is already an LGDO just return it
|
399
|
+
if isinstance(out_data, LGDO):
|
400
|
+
return out_data
|
401
|
+
|
383
402
|
msg = (
|
384
403
|
f"evaluation resulted in a {type(out_data)} object, "
|
385
404
|
"I don't know which LGDO this corresponds to"
|
File without changes
|
File without changes
|
File without changes
|