From ea7d84fe40df71d454eaf4117b4d726ebab7ca86 Mon Sep 17 00:00:00 2001 From: zm711 <92116279+zm711@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:35:41 -0400 Subject: [PATCH] test that all rawios accept slice(None) --- neo/test/rawiotest/rawio_compliance.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/neo/test/rawiotest/rawio_compliance.py b/neo/test/rawiotest/rawio_compliance.py index 784ffa46b..e913c5cf5 100644 --- a/neo/test/rawiotest/rawio_compliance.py +++ b/neo/test/rawiotest/rawio_compliance.py @@ -172,7 +172,7 @@ def read_analogsignals(reader): channel_names = signal_channels["name"][mask] channel_ids = signal_channels["id"][mask] - # acces by channel inde/ids/names should give the same chunk + # acces by channel index/ids/names should give the same chunk channel_indexes2 = channel_indexes[::2] channel_names2 = channel_names[::2] channel_ids2 = channel_ids[::2] @@ -214,6 +214,29 @@ def read_analogsignals(reader): ) np.testing.assert_array_equal(raw_chunk0, raw_chunk1) + # test slice(None). This should return the same array as giving + # all channel indexes or using None as an argument in `get_analogsignal_chunk` + # see https://github.com/NeuralEnsemble/python-neo/issues/1533 + + raw_chunk_slice_none = reader.get_analogsignal_chunk( + block_index=block_index, + seg_index=seg_index, + i_start=i_start, + i_stop=i_stop, + stream_index=stream_index, + channel_indexes=slice(None) + ) + raw_chunk_channel_indexes = reader.get_analogsignal_chunk( + block_index=block_index, + seg_index=seg_index, + i_start=i_start, + i_stop=i_stop, + stream_index=stream_index, + channel_indexes=channel_indexes + ) + + np.testing.assert_array_equal(raw_chunk_slice_none, raw_chunk_channel_indexes) + # test prefer_slice=True/False if nb_chan >= 3: for prefer_slice in (True, False):