|
19 | 19 | """ |
20 | 20 |
|
21 | 21 | # Standard library imports |
22 | | -import unittest |
| 22 | +import unittest, random |
23 | 23 |
|
24 | 24 | # Third party imports |
25 | 25 | import numpy as np |
@@ -261,12 +261,16 @@ def test_read_session(self): |
261 | 261 | assert len(data) == len(channel_names) |
262 | 262 | assert len(data[ref_index]) == int(10 * chan_fs) |
263 | 263 |
|
264 | | - # Read by index reverted order channels specified |
265 | | - rev_data = ms.read_by_index(0, int(10*chan_fs), channel_names[::-1]) |
| 264 | + # Read by index mixed order channels specified |
| 265 | + mixed_order = channel_names.copy() |
| 266 | + random.shuffle(mixed_order) |
| 267 | + |
| 268 | + rev_data = ms.read_by_index(0, int(10*chan_fs), mixed_order) |
266 | 269 |
|
267 | 270 | assert len(rev_data) == len(channel_names) |
268 | | - assert len(rev_data[-1]) == len(data[0]) |
269 | | - np.testing.assert_array_equal(rev_data[-1], data[0]) |
| 271 | + for i, ch in enumerate(mixed_order): |
| 272 | + ch_idx = channel_names.index(ch) |
| 273 | + np.testing.assert_array_equal(rev_data[i], data[ch_idx]) |
270 | 274 |
|
271 | 275 | # Read by index - no channels specified |
272 | 276 | data = ms.read_by_index(0, int(10*chan_fs), None) |
@@ -302,12 +306,16 @@ def test_read_session(self): |
302 | 306 | assert len(data) == len(channel_names) |
303 | 307 | assert len(data[ref_index]) == int(10 * ref_fs) + 5 # TODO: why +5? |
304 | 308 |
|
305 | | - # Read by time reverted order channels specified |
306 | | - rev_data = ms.read_by_time(start_time, start_time + 10 * 1000000, channel_names[::-1]) |
| 309 | + # Read by time mixed order channels specified |
| 310 | + mixed_order = channel_names.copy() |
| 311 | + random.shuffle(mixed_order) |
| 312 | + |
| 313 | + rev_data = ms.read_by_time(start_time, start_time + 10 * 1000000, mixed_order) |
307 | 314 |
|
308 | 315 | assert len(rev_data) == len(channel_names) |
309 | | - assert len(rev_data[-1]) == len(data[0]) |
310 | | - np.testing.assert_array_equal(rev_data[-1], data[0]) |
| 316 | + for i, ch in enumerate(mixed_order): |
| 317 | + ch_idx = channel_names.index(ch) |
| 318 | + np.testing.assert_array_equal(rev_data[i], data[ch_idx]) |
311 | 319 |
|
312 | 320 | # Read by time - no channels specified |
313 | 321 | data = ms.read_by_time(start_time, start_time + 10 * 1000000) |
|
0 commit comments