legend-pydataobj 1.11.0__py3-none-any.whl → 1.11.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: legend_pydataobj
3
- Version: 1.11.0
3
+ Version: 1.11.2
4
4
  Summary: LEGEND Python Data Objects
5
5
  Author: The LEGEND Collaboration
6
6
  Maintainer: The LEGEND Collaboration
@@ -1,11 +1,11 @@
1
1
  lgdo/__init__.py,sha256=1YUuAFQHNrOOkr3ZfrtEJOpYqgzbHRYA81ssbQZitQE,3196
2
- lgdo/_version.py,sha256=rZqhcUFwPMyj_mTWUN2A6qcFr8Ptv08CSbXbruC3jR4,413
2
+ lgdo/_version.py,sha256=bDTqFh70ehioLDtrFoQMAZrx_nk6Lp2-C5J8Rwl7BYA,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
- lgdo/utils.py,sha256=9t_GYdB8aQhZ4Vz6ujmASzwCgTuP7ZdINtPTVPyIR6E,3661
8
+ lgdo/utils.py,sha256=WRTmXnaQ-h2hVxwJ27qiOigdsD3DHcaDrdDjvupCuZU,3940
9
9
  lgdo/compression/__init__.py,sha256=gqbdx4NnpCcW-C7kUXV-hVUZFiNlbCwIbs3uzFe4AFE,1127
10
10
  lgdo/compression/base.py,sha256=82cQJujfvoAOKBFx761dEcx_xM02TBCBBuBo6i78tuI,838
11
11
  lgdo/compression/generic.py,sha256=tF3UhLJbUDcovLxpIzgQRxFSjZ5Fz3uDRy9kI4mFntQ,2515
@@ -28,7 +28,7 @@ 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=98P_XoXE8QWLQeSyBm9QHBF_5WGHKrfpNppLhj3QrbE,7169
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
@@ -43,13 +43,13 @@ lgdo/types/histogram.py,sha256=XuE81aRXgIY-g-rFgr9Jo7KZ-0tsNpq1lRVRyA4uTSQ,19679
43
43
  lgdo/types/lgdo.py,sha256=UnJDi1emQYVgH_H29Vipfs4LelPopxG5pgZUu1eKOlw,2761
44
44
  lgdo/types/scalar.py,sha256=c5Es2vyDqyWTPV6mujzfIzMpC1jNWkEIcvYyWQUxH3Q,1933
45
45
  lgdo/types/struct.py,sha256=Q0OWLVd4B0ciLb8t6VsxU3MPbmGLZ7WfQNno1lSQS0Q,4918
46
- lgdo/types/table.py,sha256=lB_jj6C0C5w8jbo17Lp0P8_uY8jy7opkTJc1OrbCGEI,17956
46
+ lgdo/types/table.py,sha256=oJfUmRsjP4Q1k4f-nae3xSQQuGrMcLPGbY7UxMlXMCU,18596
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.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
51
- legend_pydataobj-1.11.0.dist-info/METADATA,sha256=d4lBYc7gKmmSdW59x4tUxcfUSlETmAknC1f2TchfgNc,44382
52
- legend_pydataobj-1.11.0.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
53
- legend_pydataobj-1.11.0.dist-info/entry_points.txt,sha256=Uu5MTlppBZxB4QGlLv-oX8FqACWjAZDNii__TBDJwLQ,72
54
- legend_pydataobj-1.11.0.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
55
- legend_pydataobj-1.11.0.dist-info/RECORD,,
50
+ legend_pydataobj-1.11.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
51
+ legend_pydataobj-1.11.2.dist-info/METADATA,sha256=HmjRC4KWBKPaWMGAjKEiufOsmFikbbBG2oZkkEVAWHo,44382
52
+ legend_pydataobj-1.11.2.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
53
+ legend_pydataobj-1.11.2.dist-info/entry_points.txt,sha256=Uu5MTlppBZxB4QGlLv-oX8FqACWjAZDNii__TBDJwLQ,72
54
+ legend_pydataobj-1.11.2.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
55
+ legend_pydataobj-1.11.2.dist-info/RECORD,,
lgdo/_version.py CHANGED
@@ -12,5 +12,5 @@ __version__: str
12
12
  __version_tuple__: VERSION_TUPLE
13
13
  version_tuple: VERSION_TUPLE
14
14
 
15
- __version__ = version = '1.11.0'
16
- __version_tuple__ = version_tuple = (1, 11, 0)
15
+ __version__ = version = '1.11.2'
16
+ __version_tuple__ = version_tuple = (1, 11, 2)
@@ -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
- end = obj_buf_start + n_rows_read
193
- obj_buf.cumulative_length.nda[end:] = obj_buf.cumulative_length.nda[end - 1]
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/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
 
@@ -266,6 +267,7 @@ class Table(Struct):
266
267
  self,
267
268
  expr: str,
268
269
  parameters: Mapping[str, str] | None = None,
270
+ modules: Mapping[str, ModuleType] | None = None,
269
271
  ) -> LGDO:
270
272
  """Apply column operations to the table and return a new LGDO.
271
273
 
@@ -299,6 +301,10 @@ class Table(Struct):
299
301
  a dictionary of function parameters. Passed to
300
302
  :func:`numexpr.evaluate`` as `local_dict` argument or to
301
303
  :func:`eval` as `locals` argument.
304
+ modules
305
+ a dictionary of additional modules used by the expression. If this is not `None`
306
+ then :func:`eval`is used and the expression can depend on any modules from this dictionary in
307
+ addition to awkward and numpy. These are passed to :func:`eval` as `globals` argument.
302
308
 
303
309
  Examples
304
310
  --------
@@ -339,8 +345,8 @@ class Table(Struct):
339
345
  msg = f"evaluating {expr!r} with locals={(self_unwrap | parameters)} and {has_ak=}"
340
346
  log.debug(msg)
341
347
 
342
- # use numexpr if we are only dealing with numpy data types
343
- if not has_ak:
348
+ # use numexpr if we are only dealing with numpy data types (and no global dictionary)
349
+ if not has_ak and modules is None:
344
350
  out_data = ne.evaluate(
345
351
  expr,
346
352
  local_dict=(self_unwrap | parameters),
@@ -366,6 +372,9 @@ class Table(Struct):
366
372
 
367
373
  # resort to good ol' eval()
368
374
  globs = {"ak": ak, "np": np}
375
+ if modules is not None:
376
+ globs = globs | modules
377
+
369
378
  out_data = eval(expr, globs, (self_unwrap | parameters))
370
379
 
371
380
  msg = f"...the result is {out_data!r}"
@@ -380,6 +389,10 @@ class Table(Struct):
380
389
  if np.isscalar(out_data):
381
390
  return Scalar(out_data)
382
391
 
392
+ # if out_data is already an LGDO just return it
393
+ if isinstance(out_data, LGDO):
394
+ return out_data
395
+
383
396
  msg = (
384
397
  f"evaluation resulted in a {type(out_data)} object, "
385
398
  "I don't know which LGDO this corresponds to"
lgdo/utils.py CHANGED
@@ -49,6 +49,14 @@ def get_element_type(obj: object) -> str:
49
49
  return "complex"
50
50
  if kind in ["S", "U"]:
51
51
  return "string"
52
+ if (
53
+ kind == "O"
54
+ and dt.metadata is not None
55
+ and dt.metadata.get("vlen", None) in (str, bytes)
56
+ ):
57
+ # variable length strings in HDF5 are read as numpy object arrays in h5py.
58
+ # see also h5py.check_vlen_dtype.
59
+ return "string"
52
60
 
53
61
  # couldn't figure it out
54
62
  msg = "cannot determine lgdo element_type for object of type"