legend-pydataobj 1.11.7__py3-none-any.whl → 1.12.0a2__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.7.dist-info → legend_pydataobj-1.12.0a2.dist-info}/METADATA +1 -1
- {legend_pydataobj-1.11.7.dist-info → legend_pydataobj-1.12.0a2.dist-info}/RECORD +23 -24
- lgdo/__init__.py +5 -4
- lgdo/_version.py +2 -2
- lgdo/lh5/__init__.py +1 -3
- lgdo/lh5/_serializers/read/composite.py +1 -3
- lgdo/lh5/concat.py +3 -9
- lgdo/lh5/core.py +21 -30
- lgdo/lh5/iterator.py +48 -27
- lgdo/lh5/store.py +15 -68
- lgdo/lh5/tools.py +0 -111
- lgdo/types/array.py +84 -15
- lgdo/types/encoded.py +25 -20
- lgdo/types/histogram.py +1 -1
- lgdo/types/lgdo.py +50 -0
- lgdo/types/table.py +49 -28
- lgdo/types/vectorofvectors.py +72 -76
- lgdo/types/vovutils.py +14 -4
- lgdo/types/waveformtable.py +19 -21
- lgdo/lh5_store.py +0 -284
- {legend_pydataobj-1.11.7.dist-info → legend_pydataobj-1.12.0a2.dist-info}/WHEEL +0 -0
- {legend_pydataobj-1.11.7.dist-info → legend_pydataobj-1.12.0a2.dist-info}/entry_points.txt +0 -0
- {legend_pydataobj-1.11.7.dist-info → legend_pydataobj-1.12.0a2.dist-info}/licenses/LICENSE +0 -0
- {legend_pydataobj-1.11.7.dist-info → legend_pydataobj-1.12.0a2.dist-info}/top_level.txt +0 -0
lgdo/types/vectorofvectors.py
CHANGED
@@ -20,12 +20,12 @@ from .. import utils
|
|
20
20
|
from . import arrayofequalsizedarrays as aoesa
|
21
21
|
from . import vovutils
|
22
22
|
from .array import Array
|
23
|
-
from .lgdo import
|
23
|
+
from .lgdo import LGDOCollection
|
24
24
|
|
25
25
|
log = logging.getLogger(__name__)
|
26
26
|
|
27
27
|
|
28
|
-
class VectorOfVectors(
|
28
|
+
class VectorOfVectors(LGDOCollection):
|
29
29
|
"""A n-dimensional variable-length 1D array of variable-length 1D arrays.
|
30
30
|
|
31
31
|
If the vector is 2-dimensional, the internal representation is as two NumPy
|
@@ -210,20 +210,17 @@ class VectorOfVectors(LGDO):
|
|
210
210
|
elif self.flattened_data is None:
|
211
211
|
self.flattened_data = flattened_data
|
212
212
|
|
213
|
-
|
214
|
-
self.dtype = self.flattened_data.dtype
|
215
|
-
|
216
|
-
# set ndim
|
217
|
-
self.ndim = 2
|
218
|
-
pointer = self.flattened_data
|
219
|
-
while True:
|
220
|
-
if isinstance(pointer, Array):
|
221
|
-
break
|
213
|
+
super().__init__(attrs)
|
222
214
|
|
223
|
-
|
224
|
-
|
215
|
+
@property
|
216
|
+
def ndim(self):
|
217
|
+
return 1 + (
|
218
|
+
1 if isinstance(self.flattened_data, Array) else self.flattened_data.ndim
|
219
|
+
)
|
225
220
|
|
226
|
-
|
221
|
+
@property
|
222
|
+
def dtype(self) -> np.dtype:
|
223
|
+
return self.flattened_data.dtype
|
227
224
|
|
228
225
|
def datatype_name(self) -> str:
|
229
226
|
return "array"
|
@@ -276,7 +273,30 @@ class VectorOfVectors(LGDO):
|
|
276
273
|
else:
|
277
274
|
raise NotImplementedError
|
278
275
|
|
279
|
-
def
|
276
|
+
def reserve_capacity(self, cap_cl, *cap_args) -> None:
|
277
|
+
"""Set capacity of internal data arrays. Expect number of args to
|
278
|
+
equal `self.n_dim`. First arg is capacity of cumulative length array.
|
279
|
+
If `self.n_dim` is 2, second argument is capacity of flattened data,
|
280
|
+
otherwise arguments are fed recursively to remaining dimensions.
|
281
|
+
"""
|
282
|
+
self.cumulative_length.reserve_capacity(cap_cl)
|
283
|
+
self.flattened_data.reserve_capacity(*cap_args)
|
284
|
+
|
285
|
+
def get_capacity(self) -> tuple[int]:
|
286
|
+
"""Get tuple containing capacity of each dimension. First dimension
|
287
|
+
is cumulative length array. Last dimension is flattened data.
|
288
|
+
"""
|
289
|
+
fd_cap = self.flattened_data.get_capacity()
|
290
|
+
if isinstance(fd_cap, int):
|
291
|
+
return (self.cumulative_length.get_capacity(), fd_cap)
|
292
|
+
return (self.cumulative_length.get_capacity(), *fd_cap)
|
293
|
+
|
294
|
+
def trim_capacity(self) -> None:
|
295
|
+
"Set capacity for all dimensions to minimum needed to hold data"
|
296
|
+
self.cumulative_length.trim_capacity()
|
297
|
+
self.flattened_data.trim_capacity()
|
298
|
+
|
299
|
+
def resize(self, new_size: int, trim: bool = False) -> None:
|
280
300
|
"""Resize vector along the first axis.
|
281
301
|
|
282
302
|
`self.flattened_data` is resized only if `new_size` is smaller than the
|
@@ -286,6 +306,8 @@ class VectorOfVectors(LGDO):
|
|
286
306
|
`self.cumulative_length` is padded with its last element. This
|
287
307
|
corresponds to appending empty vectors.
|
288
308
|
|
309
|
+
If `trim` is ``True``, resize capacity to match new size
|
310
|
+
|
289
311
|
Examples
|
290
312
|
--------
|
291
313
|
>>> vov = VectorOfVectors([[1, 2, 3], [4, 5]])
|
@@ -303,23 +325,22 @@ class VectorOfVectors(LGDO):
|
|
303
325
|
[3],
|
304
326
|
]
|
305
327
|
"""
|
306
|
-
vidx = self.cumulative_length
|
307
328
|
old_s = len(self)
|
308
|
-
dlen = new_size - old_s
|
309
|
-
csum = vidx[-1] if len(self) > 0 else 0
|
310
329
|
|
311
330
|
# first resize the cumulative length
|
312
|
-
self.cumulative_length.resize(new_size)
|
331
|
+
self.cumulative_length.resize(new_size, trim)
|
313
332
|
|
314
333
|
# if new_size > size, new elements are filled with zeros, let's fix
|
315
334
|
# that
|
316
|
-
if
|
317
|
-
self.cumulative_length[old_s:] =
|
335
|
+
if new_size > old_s:
|
336
|
+
self.cumulative_length[old_s:] = self.cumulative_length[old_s - 1]
|
318
337
|
|
319
338
|
# then resize the data array
|
320
339
|
# if dlen > 0 this has no effect
|
321
340
|
if len(self.cumulative_length) > 0:
|
322
|
-
self.flattened_data.resize(self.cumulative_length[-1])
|
341
|
+
self.flattened_data.resize(self.cumulative_length[-1], trim)
|
342
|
+
else:
|
343
|
+
self.flattened_data.resize(0, trim)
|
323
344
|
|
324
345
|
def append(self, new: NDArray) -> None:
|
325
346
|
"""Append a 1D vector `new` at the end.
|
@@ -334,20 +355,7 @@ class VectorOfVectors(LGDO):
|
|
334
355
|
[8 9],
|
335
356
|
]
|
336
357
|
"""
|
337
|
-
|
338
|
-
# first extend cumulative_length by +1
|
339
|
-
self.cumulative_length.resize(len(self) + 1)
|
340
|
-
# set it at the right value
|
341
|
-
newlen = (
|
342
|
-
self.cumulative_length[-2] + len(new) if len(self) > 1 else len(new)
|
343
|
-
)
|
344
|
-
self.cumulative_length[-1] = newlen
|
345
|
-
# then resize flattened_data to accommodate the new vector
|
346
|
-
self.flattened_data.resize(len(self.flattened_data) + len(new))
|
347
|
-
# finally set it
|
348
|
-
self[-1] = new
|
349
|
-
else:
|
350
|
-
raise NotImplementedError
|
358
|
+
self.insert(len(self), new)
|
351
359
|
|
352
360
|
def insert(self, i: int, new: NDArray) -> None:
|
353
361
|
"""Insert a vector at index `i`.
|
@@ -364,23 +372,15 @@ class VectorOfVectors(LGDO):
|
|
364
372
|
[8 9],
|
365
373
|
[4 5],
|
366
374
|
]
|
367
|
-
|
368
|
-
Warning
|
369
|
-
-------
|
370
|
-
This method involves a significant amount of memory re-allocation and
|
371
|
-
is expected to perform poorly on large vectors.
|
372
375
|
"""
|
373
376
|
if self.ndim == 2:
|
374
|
-
if i
|
375
|
-
msg = f"index {i} is out of bounds for vector
|
377
|
+
if i > len(self):
|
378
|
+
msg = f"index {i} is out of bounds for vector with size {len(self)}"
|
376
379
|
raise IndexError(msg)
|
377
380
|
|
378
|
-
self.
|
379
|
-
|
380
|
-
)
|
381
|
-
self.cumulative_length = Array(
|
382
|
-
np.insert(self.cumulative_length, i, self.cumulative_length[i - 1])
|
383
|
-
)
|
381
|
+
i_start = 0 if i == 0 else self.cumulative_length[i - 1]
|
382
|
+
self.flattened_data.insert(i_start, new)
|
383
|
+
self.cumulative_length.insert(i, i_start)
|
384
384
|
self.cumulative_length[i:] += np.uint32(len(new))
|
385
385
|
else:
|
386
386
|
raise NotImplementedError
|
@@ -400,11 +400,6 @@ class VectorOfVectors(LGDO):
|
|
400
400
|
[[8 9],
|
401
401
|
[4 5],
|
402
402
|
]
|
403
|
-
|
404
|
-
Warning
|
405
|
-
-------
|
406
|
-
This method involves a significant amount of memory re-allocation and
|
407
|
-
is expected to perform poorly on large vectors.
|
408
403
|
"""
|
409
404
|
if self.ndim == 2:
|
410
405
|
if i >= len(self):
|
@@ -414,27 +409,17 @@ class VectorOfVectors(LGDO):
|
|
414
409
|
vidx = self.cumulative_length
|
415
410
|
dlen = len(new) - len(self[i])
|
416
411
|
|
417
|
-
if dlen
|
418
|
-
#
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
)
|
429
|
-
else:
|
430
|
-
# set the already allocated indices
|
431
|
-
self.flattened_data[vidx[i - 1] : vidx[i]] = new[: len(self[i])]
|
432
|
-
# then insert the remaining
|
433
|
-
self.flattened_data = Array(
|
434
|
-
np.insert(self.flattened_data, vidx[i], new[len(self[i]) :])
|
435
|
-
)
|
436
|
-
|
437
|
-
vidx[i:] = vidx[i:] + dlen
|
412
|
+
if dlen != 0:
|
413
|
+
# move the subsequent entries
|
414
|
+
vidx[i:] += dlen
|
415
|
+
self.flattened_data.resize(vidx[-1])
|
416
|
+
self.flattened_data._nda[vidx[i] : vidx[-1]] = self.flattened_data._nda[
|
417
|
+
vidx[i] - dlen : vidx[-1] - dlen
|
418
|
+
]
|
419
|
+
|
420
|
+
# set the already allocated indices
|
421
|
+
start = vidx[i - 1] if i > 0 else 0
|
422
|
+
self.flattened_data[start : vidx[i]] = new
|
438
423
|
else:
|
439
424
|
raise NotImplementedError
|
440
425
|
|
@@ -484,7 +469,18 @@ class VectorOfVectors(LGDO):
|
|
484
469
|
cum_lens = np.add(start, lens.cumsum(), dtype=int)
|
485
470
|
|
486
471
|
# fill with fast vectorized routine
|
487
|
-
|
472
|
+
if np.issubdtype(self.flattened_data.dtype, np.unsignedinteger):
|
473
|
+
nan_val = np.iinfo(self.flattened_data.dtype).max
|
474
|
+
if np.issubdtype(self.flattened_data.dtype, np.integer):
|
475
|
+
nan_val = np.iinfo(self.flattened_data.dtype).min
|
476
|
+
else:
|
477
|
+
nan_val = np.nan
|
478
|
+
vovutils._nb_fill(
|
479
|
+
vec,
|
480
|
+
lens,
|
481
|
+
np.array([nan_val]).astype(self.flattened_data.nda.dtype),
|
482
|
+
self.flattened_data.nda[start : cum_lens[-1]],
|
483
|
+
)
|
488
484
|
|
489
485
|
# add new vector(s) length to cumulative_length
|
490
486
|
self.cumulative_length[i : i + len(lens)] = cum_lens
|
lgdo/types/vovutils.py
CHANGED
@@ -81,7 +81,7 @@ def _nb_build_cl(sorted_array_in: NDArray, cumulative_length_out: NDArray) -> ND
|
|
81
81
|
|
82
82
|
@numba.guvectorize(
|
83
83
|
[
|
84
|
-
f"{data_type}[:,:],{size_type}[:],{data_type}[:]"
|
84
|
+
f"{data_type}[:,:],{size_type}[:],{data_type},{data_type}[:]"
|
85
85
|
for data_type in [
|
86
86
|
"b1",
|
87
87
|
"i1",
|
@@ -99,10 +99,12 @@ def _nb_build_cl(sorted_array_in: NDArray, cumulative_length_out: NDArray) -> ND
|
|
99
99
|
]
|
100
100
|
for size_type in ["i4", "i8", "u4", "u8"]
|
101
101
|
],
|
102
|
-
"(l,m),(l),(n)",
|
102
|
+
"(l,m),(l),(),(n)",
|
103
103
|
**nb_kwargs,
|
104
104
|
)
|
105
|
-
def _nb_fill(
|
105
|
+
def _nb_fill(
|
106
|
+
aoa_in: NDArray, len_in: NDArray, nan_val: int | float, flattened_array_out: NDArray
|
107
|
+
):
|
106
108
|
"""Vectorized function to fill flattened array from array of arrays and
|
107
109
|
lengths. Values in aoa_in past lengths will not be copied.
|
108
110
|
|
@@ -112,6 +114,9 @@ def _nb_fill(aoa_in: NDArray, len_in: NDArray, flattened_array_out: NDArray):
|
|
112
114
|
array of arrays containing values to be copied
|
113
115
|
len_in
|
114
116
|
array of vector lengths for each row of aoa_in
|
117
|
+
nan_val
|
118
|
+
value to use when len_in is longer than aoa_in. Should use
|
119
|
+
np.nan for floating point, and 0xfff... for integer types
|
115
120
|
flattened_array_out
|
116
121
|
flattened array to copy values into. Must be longer than sum of
|
117
122
|
lengths in len_in
|
@@ -122,9 +127,14 @@ def _nb_fill(aoa_in: NDArray, len_in: NDArray, flattened_array_out: NDArray):
|
|
122
127
|
raise ValueError(msg)
|
123
128
|
|
124
129
|
start = 0
|
130
|
+
max_len = aoa_in.shape[1]
|
125
131
|
for i, ll in enumerate(len_in):
|
126
132
|
stop = start + ll
|
127
|
-
|
133
|
+
if ll > max_len:
|
134
|
+
flattened_array_out[start : start + max_len] = aoa_in[i, :max_len]
|
135
|
+
flattened_array_out[start + max_len : stop] = nan_val
|
136
|
+
else:
|
137
|
+
flattened_array_out[start:stop] = aoa_in[i, :ll]
|
128
138
|
start = stop
|
129
139
|
|
130
140
|
|
lgdo/types/waveformtable.py
CHANGED
@@ -112,12 +112,10 @@ class WaveformTable(Table):
|
|
112
112
|
if not isinstance(t0, Array):
|
113
113
|
shape = (size,)
|
114
114
|
t0_dtype = t0.dtype if hasattr(t0, "dtype") else np.float32
|
115
|
-
|
116
|
-
t0
|
117
|
-
|
118
|
-
|
119
|
-
nda.resize(shape, refcheck=True)
|
120
|
-
t0 = Array(nda=nda)
|
115
|
+
if isinstance(t0, np.ndarray):
|
116
|
+
t0 = Array(nda=t0, shape=shape, dtype=t0_dtype)
|
117
|
+
else:
|
118
|
+
t0 = Array(fill_val=t0, shape=shape, dtype=t0_dtype)
|
121
119
|
|
122
120
|
if t0_units is not None:
|
123
121
|
t0.attrs["units"] = f"{t0_units}"
|
@@ -125,12 +123,11 @@ class WaveformTable(Table):
|
|
125
123
|
if not isinstance(dt, Array):
|
126
124
|
shape = (size,)
|
127
125
|
dt_dtype = dt.dtype if hasattr(dt, "dtype") else np.float32
|
128
|
-
|
129
|
-
dt
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
dt = Array(nda=nda)
|
126
|
+
if isinstance(dt, np.ndarray):
|
127
|
+
dt = Array(nda=dt, shape=shape, dtype=dt_dtype)
|
128
|
+
else:
|
129
|
+
dt = Array(fill_val=dt, shape=shape, dtype=dt_dtype)
|
130
|
+
|
134
131
|
if dt_units is not None:
|
135
132
|
dt.attrs["units"] = f"{dt_units}"
|
136
133
|
|
@@ -174,14 +171,15 @@ class WaveformTable(Table):
|
|
174
171
|
if hasattr(values, "dtype")
|
175
172
|
else np.dtype(np.float64)
|
176
173
|
)
|
177
|
-
|
178
|
-
values
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
174
|
+
if isinstance(values, np.ndarray):
|
175
|
+
values = ArrayOfEqualSizedArrays(
|
176
|
+
dims=(1, 1), nda=values, shape=shape, dtype=dtype
|
177
|
+
)
|
178
|
+
else:
|
179
|
+
values = ArrayOfEqualSizedArrays(
|
180
|
+
dims=(1, 1), fill_val=0, shape=shape, dtype=dtype
|
181
|
+
)
|
182
|
+
|
185
183
|
if values_units is not None:
|
186
184
|
values.attrs["units"] = f"{values_units}"
|
187
185
|
|
@@ -215,7 +213,7 @@ class WaveformTable(Table):
|
|
215
213
|
return
|
216
214
|
shape = self.values.nda.shape
|
217
215
|
shape = (shape[0], wf_len)
|
218
|
-
self.values.
|
216
|
+
self.values.resize(shape)
|
219
217
|
|
220
218
|
def resize_wf_len(self, new_len: int) -> None:
|
221
219
|
"""Alias for `wf_len.setter`, for when we want to make it clear in
|
lgdo/lh5_store.py
DELETED
@@ -1,284 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
.. warning::
|
3
|
-
This subpackage is deprecated, use :mod:`lgdo.lh5`.
|
4
|
-
"""
|
5
|
-
|
6
|
-
from __future__ import annotations
|
7
|
-
|
8
|
-
import sys
|
9
|
-
from collections.abc import Iterator
|
10
|
-
from typing import Union
|
11
|
-
from warnings import warn
|
12
|
-
|
13
|
-
import h5py
|
14
|
-
import numpy as np
|
15
|
-
import pandas as pd
|
16
|
-
|
17
|
-
from . import lh5
|
18
|
-
from .types import (
|
19
|
-
Array,
|
20
|
-
ArrayOfEncodedEqualSizedArrays, # noqa: F401
|
21
|
-
ArrayOfEqualSizedArrays, # noqa: F401
|
22
|
-
FixedSizeArray, # noqa: F401
|
23
|
-
Histogram, # noqa: F401
|
24
|
-
Scalar,
|
25
|
-
Struct,
|
26
|
-
Table, # noqa: F401
|
27
|
-
VectorOfEncodedVectors, # noqa: F401
|
28
|
-
VectorOfVectors,
|
29
|
-
WaveformTable, # noqa: F401
|
30
|
-
)
|
31
|
-
|
32
|
-
LGDO = Union[Array, Scalar, Struct, VectorOfVectors]
|
33
|
-
|
34
|
-
|
35
|
-
class LH5Iterator(lh5.LH5Iterator):
|
36
|
-
"""
|
37
|
-
.. warning::
|
38
|
-
This class is deprecated, use :class:`lgdo.lh5.iterator.LH5Iterator`.
|
39
|
-
|
40
|
-
"""
|
41
|
-
|
42
|
-
def __init__(
|
43
|
-
self,
|
44
|
-
lh5_files: str | list[str],
|
45
|
-
groups: str | list[str],
|
46
|
-
base_path: str = "",
|
47
|
-
entry_list: list[int] | list[list[int]] | None = None,
|
48
|
-
entry_mask: list[bool] | list[list[bool]] | None = None,
|
49
|
-
field_mask: dict[str, bool] | list[str] | tuple[str] | None = None,
|
50
|
-
buffer_len: int = 3200,
|
51
|
-
friend: Iterator | None = None,
|
52
|
-
) -> None:
|
53
|
-
warn(
|
54
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Iterator."
|
55
|
-
"Please replace 'from lgdo.lh5_store import LH5Iterator' with 'from lgdo.lh5 import LH5Iterator'."
|
56
|
-
"lgdo.lh5_store will be removed in a future release.",
|
57
|
-
DeprecationWarning,
|
58
|
-
stacklevel=2,
|
59
|
-
)
|
60
|
-
super().__init__(
|
61
|
-
lh5_files,
|
62
|
-
groups,
|
63
|
-
base_path,
|
64
|
-
entry_list,
|
65
|
-
entry_mask,
|
66
|
-
field_mask,
|
67
|
-
buffer_len,
|
68
|
-
friend,
|
69
|
-
)
|
70
|
-
|
71
|
-
def write_object(
|
72
|
-
self,
|
73
|
-
obj: LGDO,
|
74
|
-
name: str,
|
75
|
-
lh5_file: str | h5py.File,
|
76
|
-
group: str | h5py.Group = "/",
|
77
|
-
start_row: int = 0,
|
78
|
-
n_rows: int | None = None,
|
79
|
-
wo_mode: str = "append",
|
80
|
-
write_start: int = 0,
|
81
|
-
**h5py_kwargs,
|
82
|
-
) -> None:
|
83
|
-
"""
|
84
|
-
.. warning::
|
85
|
-
This method is deprecated, use :meth:`lgdo.lh5.iterator.LH5Iterator.write`.
|
86
|
-
|
87
|
-
"""
|
88
|
-
warn(
|
89
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Iterator. "
|
90
|
-
"The object you are calling this function from uses the old LH5Iterator class."
|
91
|
-
"Please replace 'from lgdo.lh5_store import LH5Iterator' with 'from lgdo.lh5 import LH5Iterator'."
|
92
|
-
"lgdo.lh5_store will be removed in a future release.",
|
93
|
-
DeprecationWarning,
|
94
|
-
stacklevel=2,
|
95
|
-
)
|
96
|
-
self.write(
|
97
|
-
obj,
|
98
|
-
name,
|
99
|
-
lh5_file,
|
100
|
-
group,
|
101
|
-
start_row,
|
102
|
-
n_rows,
|
103
|
-
wo_mode,
|
104
|
-
write_start,
|
105
|
-
h5py_kwargs,
|
106
|
-
)
|
107
|
-
|
108
|
-
def read_object(
|
109
|
-
self,
|
110
|
-
name: str,
|
111
|
-
lh5_file: str | h5py.File | list[str | h5py.File],
|
112
|
-
start_row: int = 0,
|
113
|
-
n_rows: int = sys.maxsize,
|
114
|
-
idx: np.ndarray | list | tuple | list[np.ndarray | list | tuple] = None,
|
115
|
-
field_mask: dict[str, bool] | list[str] | tuple[str] | None = None,
|
116
|
-
obj_buf: LGDO = None,
|
117
|
-
obj_buf_start: int = 0,
|
118
|
-
decompress: bool = True,
|
119
|
-
) -> tuple[LGDO, int]:
|
120
|
-
"""
|
121
|
-
.. warning::
|
122
|
-
This method is deprecated, use :meth:`lgdo.lh5.iterator.LH5Iterator.read`.
|
123
|
-
|
124
|
-
"""
|
125
|
-
warn(
|
126
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Iterator. "
|
127
|
-
"The object you are calling this function from uses the old LH5Iterator class."
|
128
|
-
"Please replace 'from lgdo.lh5_store import LH5Iterator' with 'from lgdo.lh5 import LH5Iterator'."
|
129
|
-
"lgdo.lh5_store will be removed in a future release.",
|
130
|
-
DeprecationWarning,
|
131
|
-
stacklevel=2,
|
132
|
-
)
|
133
|
-
return self.read(
|
134
|
-
name,
|
135
|
-
lh5_file,
|
136
|
-
start_row,
|
137
|
-
n_rows,
|
138
|
-
idx,
|
139
|
-
field_mask,
|
140
|
-
obj_buf,
|
141
|
-
obj_buf_start,
|
142
|
-
decompress,
|
143
|
-
)
|
144
|
-
|
145
|
-
|
146
|
-
class LH5Store(lh5.LH5Store):
|
147
|
-
"""
|
148
|
-
.. warning::
|
149
|
-
This class is deprecated, use :class:`lgdo.lh5.iterator.LH5Store`.
|
150
|
-
|
151
|
-
"""
|
152
|
-
|
153
|
-
def __init__(self, base_path: str = "", keep_open: bool = False):
|
154
|
-
warn(
|
155
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5 containing LH5Store. "
|
156
|
-
"Please replace 'from lgdo.lh5_store import LH5Store' with 'from lgdo.lh5 import LH5Store'."
|
157
|
-
"lgdo.lh5_store will be removed in a future release.",
|
158
|
-
DeprecationWarning,
|
159
|
-
stacklevel=2,
|
160
|
-
)
|
161
|
-
super().__init__(base_path, keep_open)
|
162
|
-
|
163
|
-
def read_object(
|
164
|
-
self,
|
165
|
-
name: str,
|
166
|
-
lh5_file: str | h5py.File | list[str | h5py.File],
|
167
|
-
**kwargs,
|
168
|
-
) -> tuple[LGDO, int]:
|
169
|
-
"""
|
170
|
-
.. warning::
|
171
|
-
This method is deprecated, use :meth:`lgdo.lh5.store.LH5Store.read`.
|
172
|
-
|
173
|
-
"""
|
174
|
-
warn(
|
175
|
-
"LH5Store.read_object() has been renamed to LH5Store.read(), "
|
176
|
-
"Please update your code."
|
177
|
-
"LH5Store.read_object() will be removed in a future release.",
|
178
|
-
DeprecationWarning,
|
179
|
-
stacklevel=2,
|
180
|
-
)
|
181
|
-
return super().read(self, name, lh5_file, **kwargs)
|
182
|
-
|
183
|
-
def write_object(
|
184
|
-
self,
|
185
|
-
obj: LGDO,
|
186
|
-
name: str,
|
187
|
-
lh5_file: str | h5py.File,
|
188
|
-
**kwargs,
|
189
|
-
) -> tuple[LGDO, int]:
|
190
|
-
"""
|
191
|
-
.. warning::
|
192
|
-
This method is deprecated, use :meth:`lgdo.lh5.store.LH5Store.write`.
|
193
|
-
|
194
|
-
"""
|
195
|
-
warn(
|
196
|
-
"LH5Store.write_object() has been renamed to LH5Store.write(), "
|
197
|
-
"Please update your code."
|
198
|
-
"LH5Store.write_object() will be removed in a future release.",
|
199
|
-
DeprecationWarning,
|
200
|
-
stacklevel=2,
|
201
|
-
)
|
202
|
-
return super().read(self, obj, name, lh5_file, **kwargs)
|
203
|
-
|
204
|
-
|
205
|
-
def load_dfs(
|
206
|
-
f_list: str | list[str],
|
207
|
-
par_list: list[str],
|
208
|
-
lh5_group: str = "",
|
209
|
-
idx_list: list[np.ndarray | list | tuple] | None = None,
|
210
|
-
) -> pd.DataFrame:
|
211
|
-
"""
|
212
|
-
.. warning::
|
213
|
-
This function is deprecated, use :meth:`lgdo.types.lgdo.LGDO.view_as` to
|
214
|
-
view LGDO data as a Pandas data structure.
|
215
|
-
|
216
|
-
"""
|
217
|
-
warn(
|
218
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
|
219
|
-
"Please replace 'from lgdo.lh5_store import load_dfs' with 'from lgdo.lh5 import load_dfs'. "
|
220
|
-
"lgdo.lh5_store will be removed in a future release.",
|
221
|
-
DeprecationWarning,
|
222
|
-
stacklevel=2,
|
223
|
-
)
|
224
|
-
return lh5.load_dfs(f_list, par_list, lh5_group, idx_list)
|
225
|
-
|
226
|
-
|
227
|
-
def load_nda(
|
228
|
-
f_list: str | list[str],
|
229
|
-
par_list: list[str],
|
230
|
-
lh5_group: str = "",
|
231
|
-
idx_list: list[np.ndarray | list | tuple] | None = None,
|
232
|
-
) -> dict[str, np.ndarray]:
|
233
|
-
"""
|
234
|
-
.. warning::
|
235
|
-
This function is deprecated, use :meth:`lgdo.types.lgdo.LGDO.view_as` to
|
236
|
-
view LGDO data as a NumPy data structure.
|
237
|
-
|
238
|
-
"""
|
239
|
-
warn(
|
240
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
|
241
|
-
"Please replace 'from lgdo.lh5_store import load_nda' with 'from lgdo.lh5 import load_nda'. "
|
242
|
-
"lgdo.lh5_store will be removed in a future release.",
|
243
|
-
DeprecationWarning,
|
244
|
-
stacklevel=2,
|
245
|
-
)
|
246
|
-
return lh5.load_nda(f_list, par_list, lh5_group, idx_list)
|
247
|
-
|
248
|
-
|
249
|
-
def ls(lh5_file: str | h5py.Group, lh5_group: str = "") -> list[str]:
|
250
|
-
"""
|
251
|
-
.. warning::
|
252
|
-
This function is deprecated, import :func:`lgdo.lh5.tools.ls`.
|
253
|
-
|
254
|
-
"""
|
255
|
-
warn(
|
256
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
|
257
|
-
"Please replace 'from lgdo.lh5_store import ls' with 'from lgdo.lh5 import ls'. "
|
258
|
-
"lgdo.lh5_store will be removed in a future release.",
|
259
|
-
DeprecationWarning,
|
260
|
-
stacklevel=2,
|
261
|
-
)
|
262
|
-
return lh5.ls(lh5_file, lh5_group)
|
263
|
-
|
264
|
-
|
265
|
-
def show(
|
266
|
-
lh5_file: str | h5py.Group,
|
267
|
-
lh5_group: str = "/",
|
268
|
-
attrs: bool = False,
|
269
|
-
indent: str = "",
|
270
|
-
header: bool = True,
|
271
|
-
) -> None:
|
272
|
-
"""
|
273
|
-
.. warning::
|
274
|
-
This function is deprecated, import :func:`lgdo.lh5.tools.show`.
|
275
|
-
|
276
|
-
"""
|
277
|
-
warn(
|
278
|
-
"lgdo.lh5_store has moved to a subfolder lgdo.lh5. "
|
279
|
-
"Please replace 'from lgdo.lh5_store import show' with 'from lgdo.lh5 import show'. "
|
280
|
-
"lgdo.lh5_store will be removed in a future release.",
|
281
|
-
DeprecationWarning,
|
282
|
-
stacklevel=2,
|
283
|
-
)
|
284
|
-
lh5.show(lh5_file, lh5_group, attrs, indent, header)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|