legend-pydataobj 1.11.7__py3-none-any.whl → 1.11.10__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.4
2
2
  Name: legend_pydataobj
3
- Version: 1.11.7
3
+ Version: 1.11.10
4
4
  Summary: LEGEND Python Data Objects
5
5
  Author: The LEGEND Collaboration
6
6
  Maintainer: The LEGEND Collaboration
@@ -1,6 +1,6 @@
1
- legend_pydataobj-1.11.7.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
1
+ legend_pydataobj-1.11.10.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
2
2
  lgdo/__init__.py,sha256=QMYK9HhoMi0pbahPN8mPD18gyTxscFgo7QKfCxVhy-0,3196
3
- lgdo/_version.py,sha256=WYo6AtimYOvXEEB_DEJYUqS-yeVHGFoR5t7JM_9dSwo,513
3
+ lgdo/_version.py,sha256=8C1gggsLVh7AtWQynH0LD96q9_ChbquuufT1aPfdUFU,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
@@ -15,7 +15,7 @@ lgdo/compression/utils.py,sha256=W2RkBrxPpXlat84dnU9Ad7d_tTws0irtGl7O1dNWjnk,114
15
15
  lgdo/compression/varlen.py,sha256=6ZZUItyoOfygDdE0DyoISeFZfqdbH6xl7T0eclfarzg,15127
16
16
  lgdo/lh5/__init__.py,sha256=y1XE_mpFWwamrl7WVjAVSVB25X4PrEfdVXSneSQEmlQ,825
17
17
  lgdo/lh5/concat.py,sha256=5nO7dNSb0UEP9rZiWGTKH5Cfwsm5LSm3tBJM4Kd70u0,6336
18
- lgdo/lh5/core.py,sha256=__-A6Abctzfwfo4-xJi68xs2e4vfzONEQTJVrUCOw-I,13922
18
+ lgdo/lh5/core.py,sha256=HT50rolOtTijgaGFskRgzoRbC0w-kxrRS2v9O5Q9Ugo,14067
19
19
  lgdo/lh5/datatype.py,sha256=O_7BqOlX8PFMyG0ppkfUT5aps5HEqX0bpuKcJO3jhu0,1691
20
20
  lgdo/lh5/exceptions.py,sha256=3kj8avXl4eBGvebl3LG12gJEmw91W0T8PYR0AfvUAyM,1211
21
21
  lgdo/lh5/iterator.py,sha256=ZaBBnmuNIjinwO0JUY55wLxX8Om9rVRRzXBC5uHmSKM,19772
@@ -33,7 +33,7 @@ lgdo/lh5/_serializers/read/utils.py,sha256=YfSqPO-83A1XvhhuULxQ0Qz2A5ODa3sb7ApNx
33
33
  lgdo/lh5/_serializers/read/vector_of_vectors.py,sha256=765P8mElGArAaEPkHTAUXFQ47t1_3-3BQAete0LckBQ,7207
34
34
  lgdo/lh5/_serializers/write/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  lgdo/lh5/_serializers/write/array.py,sha256=66DKnW2yqIBlUGNBPWcE-m4W0B2-nTKusDHGX9m6GY0,3223
36
- lgdo/lh5/_serializers/write/composite.py,sha256=I6lH0nWFIpAfZyG4-0rLxzg3mfazZ_FEhQVp1FZ0aA4,9254
36
+ lgdo/lh5/_serializers/write/composite.py,sha256=eEfisBAxpF1Q8v4AbORbBQyxg0p5ugMo9cBjicOC5KI,9979
37
37
  lgdo/lh5/_serializers/write/scalar.py,sha256=JPt_fcdTKOSFp5hfJdcKIfK4hxhcD8vhOlvDF-7btQ8,763
38
38
  lgdo/lh5/_serializers/write/vector_of_vectors.py,sha256=puGQX9XF5P_5DVbm_Cc6TvPrsDywgBLSYtkqFNltbB4,3493
39
39
  lgdo/types/__init__.py,sha256=DNfOErPiAZg-7Gygkp6ZKAi20Yrm1mfderZHvKo1Y4s,821
@@ -49,8 +49,8 @@ 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.7.dist-info/METADATA,sha256=Z0-UFMzWILag78U1HkNpbYwKDb_JZkZ8kZLtW4T8gw0,44443
53
- legend_pydataobj-1.11.7.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
54
- legend_pydataobj-1.11.7.dist-info/entry_points.txt,sha256=0KWfnwbuwhNn0vPUqARukjp04Ca6lzfZBSirouRmk7I,76
55
- legend_pydataobj-1.11.7.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
56
- legend_pydataobj-1.11.7.dist-info/RECORD,,
52
+ legend_pydataobj-1.11.10.dist-info/METADATA,sha256=oWYdBOz-guRsPbd6918FxEhKM2C_8sQrhSqpp4AlL30,44444
53
+ legend_pydataobj-1.11.10.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
54
+ legend_pydataobj-1.11.10.dist-info/entry_points.txt,sha256=0KWfnwbuwhNn0vPUqARukjp04Ca6lzfZBSirouRmk7I,76
55
+ legend_pydataobj-1.11.10.dist-info/top_level.txt,sha256=KyR-EUloqiXcQ62IWnzBmtInDtvsHl4q2ZJAZgTcLXE,5
56
+ legend_pydataobj-1.11.10.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.1.0)
2
+ Generator: setuptools (80.3.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
lgdo/_version.py CHANGED
@@ -17,5 +17,5 @@ __version__: str
17
17
  __version_tuple__: VERSION_TUPLE
18
18
  version_tuple: VERSION_TUPLE
19
19
 
20
- __version__ = version = '1.11.7'
21
- __version_tuple__ = version_tuple = (1, 11, 7)
20
+ __version__ = version = '1.11.10'
21
+ __version_tuple__ = version_tuple = (1, 11, 10)
@@ -186,19 +186,31 @@ def _h5_write_struct(
186
186
  write_start=0,
187
187
  **h5py_kwargs,
188
188
  ):
189
+ # this works for structs and derived (tables)
189
190
  assert isinstance(obj, types.Struct)
190
191
 
191
192
  # In order to append a column, we need to update the
192
- # `table{old_fields}` value in `group.attrs['datatype"]` to include
193
- # the new fields. One way to do this is to override
194
- # `obj.attrs["datatype"]` to include old and new fields. Then we
195
- # can write the fields to the table as normal.
193
+ # `struct/table{old_fields}` value in `group.attrs['datatype"]` to include
194
+ # the new fields. One way to do this is to override `obj.attrs["datatype"]`
195
+ # to include old and new fields. Then we can write the fields to the
196
+ # struct/table as normal.
196
197
  if wo_mode == "ac":
198
+ if name not in group:
199
+ msg = "Cannot append column to non-existing struct on disk"
200
+ raise LH5EncodeError(msg, lh5_file, group, name)
201
+
197
202
  old_group = utils.get_h5_group(name, group)
203
+ if "datatype" not in old_group.attrs:
204
+ msg = "Cannot append column to an existing non-LGDO object on disk"
205
+ raise LH5EncodeError(msg, lh5_file, group, name)
206
+
198
207
  lgdotype = datatype.datatype(old_group.attrs["datatype"])
199
208
  fields = datatype.get_struct_fields(old_group.attrs["datatype"])
200
- if not issubclass(lgdotype, types.Struct):
201
- msg = f"Trying to append columns to an object of type {lgdotype.__name__}"
209
+ if lgdotype is not type(obj):
210
+ msg = (
211
+ "Trying to append columns to an object of different "
212
+ f"type {lgdotype.__name__}!={type(obj)}"
213
+ )
202
214
  raise LH5EncodeError(msg, lh5_file, group, name)
203
215
 
204
216
  # If the mode is `append_column`, make sure we aren't appending
@@ -211,8 +223,12 @@ def _h5_write_struct(
211
223
  "column(s) to a table with the same field(s)"
212
224
  )
213
225
  raise LH5EncodeError(msg, lh5_file, group, name)
226
+
214
227
  # It doesn't matter what key we access, as all fields in the old table have the same size
215
- if old_group[next(iter(old_group.keys()))].size != obj.size:
228
+ if (
229
+ isinstance(obj, types.Table)
230
+ and old_group[next(iter(old_group.keys()))].size != obj.size
231
+ ):
216
232
  msg = (
217
233
  f"Table sizes don't match. Trying to append column of size {obj.size} "
218
234
  f"to a table of size {old_group[next(iter(old_group.keys()))].size}."
@@ -222,16 +238,25 @@ def _h5_write_struct(
222
238
  # Now we can append the obj.keys() to the old fields, and then update obj.attrs.
223
239
  fields.extend(list(obj.keys()))
224
240
  obj.attrs.pop("datatype")
225
- obj.attrs["datatype"] = "table" + "{" + ",".join(fields) + "}"
241
+
242
+ obj.attrs["datatype"] = obj.datatype_name() + "{" + ",".join(fields) + "}"
243
+
244
+ # propagating wo_mode="ac" to nested LGDOs does not make any sense
245
+ wo_mode = "append"
246
+
247
+ # overwrite attributes of the existing struct
248
+ attrs_overwrite = True
249
+ else:
250
+ attrs_overwrite = wo_mode == "o"
226
251
 
227
252
  group = utils.get_h5_group(
228
253
  name,
229
254
  group,
230
255
  grp_attrs=obj.attrs,
231
- overwrite=(wo_mode in ["o", "ac"]),
256
+ overwrite=attrs_overwrite,
232
257
  )
233
258
  # If the mode is overwrite, then we need to peek into the file's
234
- # table's existing fields. If we are writing a new table to the
259
+ # table's existing fields. If we are writing a new table to the
235
260
  # group that does not contain an old field, we should delete that
236
261
  # old field from the file
237
262
  if wo_mode == "o":
@@ -260,11 +285,9 @@ def _h5_write_struct(
260
285
  else:
261
286
  obj_fld = obj[field]
262
287
 
263
- # Convert keys to string for dataset names
264
- f = str(field)
265
288
  _h5_write_lgdo(
266
289
  obj_fld,
267
- f,
290
+ str(field),
268
291
  lh5_file,
269
292
  group=group,
270
293
  start_row=start_row,
lgdo/lh5/core.py CHANGED
@@ -273,11 +273,13 @@ def write(
273
273
  end of array is the same as ``append``.
274
274
  - ``overwrite_file`` or ``of``: delete file if present prior to
275
275
  writing to it. `write_start` should be 0 (its ignored).
276
- - ``append_column`` or ``ac``: append columns from an
277
- :class:`~.lgdo.table.Table` `obj` only if there is an existing
278
- :class:`~.lgdo.table.Table` in the `lh5_file` with the same
279
- `name` and :class:`~.lgdo.table.Table.size`. If the sizes don't
280
- match, or if there are matching fields, it errors out.
276
+ - ``append_column`` or ``ac``: append fields/columns from an
277
+ :class:`~.lgdo.struct.Struct` `obj` (and derived types such as
278
+ :class:`~.lgdo.table.Table`) only if there is an existing
279
+ :class:`~.lgdo.struct.Struct` in the `lh5_file` with the same `name`.
280
+ If there are matching fields, it errors out. If appending to a
281
+ ``Table`` and the size of the new column is different from the size
282
+ of the existing table, it errors out.
281
283
  write_start
282
284
  row in the output file (if already existing) to start overwriting
283
285
  from.