Skip to content

Commit

Permalink
[sigcompress] improve decode with pre-allocated structure
Browse files Browse the repository at this point in the history
  • Loading branch information
gipert committed Oct 28, 2023
1 parent 44ea845 commit c1d2b7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lgdo/compression/radware.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ def decode(
dtype=int32,
attrs=sig_in.getattrs(),
)
else:
if not (
isinstance(sig_out, lgdo.ArrayOfEqualSizedArrays)
and sig_out.nda.shape == (len(sig_in), sig_in.decoded_size.value)
):
raise ValueError("sig_out is of the wrong format")

siglen = np.empty(len(sig_in), dtype=uint32)
# save original encoded vector lengths
Expand Down
7 changes: 7 additions & 0 deletions tests/compression/test_radware_sigcompress.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ def test_aoesa(wftable):
for wf1, wf2 in zip(dec_aoesa, wftable.values):
assert np.array_equal(wf1, wf2)

# test using pre-allocated decoded array
sig_out = ArrayOfEqualSizedArrays(
shape=wftable.values.nda.shape, dtype=wftable.values.dtype
)
decode(enc_vov, sig_out=sig_out, shift=shift)
assert wftable.values == sig_out


def test_performance(lgnd_test_data):
store = LH5Store()
Expand Down

0 comments on commit c1d2b7b

Please sign in to comment.