6
6
# Redistribution and use in section and binary forms, with or without
7
7
# modification, are permitted under the terms of the BSD License. See
8
8
# LICENSE file in the root of the Project.
9
+ from nixio .exceptions .exceptions import InvalidSlice
9
10
import os
10
11
import time
11
12
import unittest
@@ -385,13 +386,16 @@ def test_multi_tag_tagged_data(self):
385
386
assert np .array_equal (y_data [:2000 ], data [:])
386
387
387
388
# multi dimensional data
389
+ # position 1 should fail since the position in the third dimension does not point to a valid point
390
+ # positon 2 and 3 should deliver valid DataViews
391
+ # same for segment 0 should again return an invalid DataView because of dimension 3
388
392
sample_iv = 1.0
389
393
ticks = [1.2 , 2.3 , 3.4 , 4.5 , 6.7 ]
390
394
unit = "ms"
391
- pos = self .block .create_data_array ("pos" , "test" , data = [[1 , 1 , 1 ], [1 , 1 , 1 ]])
395
+ pos = self .block .create_data_array ("pos" , "test" , data = [[1 , 1 , 1 ], [1 , 1 , 1.2 ], [ 1 , 1 , 1.2 ]])
392
396
pos .append_set_dimension ()
393
397
pos .append_set_dimension ()
394
- ext = self .block .create_data_array ("ext" , "test" , data = [[1 , 5 , 2 ], [0 , 4 , 1 ]])
398
+ ext = self .block .create_data_array ("ext" , "test" , data = [[1 , 5 , 2 ], [1 , 5 , 2 ], [ 0 , 4 , 1 ]])
395
399
ext .append_set_dimension ()
396
400
ext .append_set_dimension ()
397
401
units = ["none" , "ms" , "ms" ]
@@ -414,20 +418,31 @@ def test_multi_tag_tagged_data(self):
414
418
segtag .units = units
415
419
416
420
posdata = postag .tagged_data (0 , 0 )
421
+ assert not posdata .valid
422
+ assert "InvalidSlice error" in posdata .debug_message
423
+ assert posdata .data_extent is None
424
+ assert posdata .shape is None
425
+ with self .assertRaises (InvalidSlice ):
426
+ posdata ._write_data (np .random .randn (1 ))
427
+ assert sum (posdata [:].shape ) == 0
428
+
429
+ posdata = postag .tagged_data (1 , 0 )
430
+ assert posdata .valid
431
+ assert posdata .debug_message == ""
417
432
assert len (posdata .shape ) == 3
418
433
assert posdata .shape == (1 , 1 , 1 )
419
434
assert np .isclose (posdata [0 , 0 , 0 ], data [1 , 1 , 0 ])
420
435
421
- posdata = postag .tagged_data (1 , 0 )
436
+ posdata = postag .tagged_data (2 , 0 )
422
437
assert len (posdata .shape ) == 3
423
438
assert posdata .shape == (1 , 1 , 1 )
424
439
assert np .isclose (posdata [0 , 0 , 0 ], data [1 , 1 , 0 ])
425
440
426
- segdata = segtag .tagged_data (0 , 0 )
441
+ segdata = segtag .tagged_data (1 , 0 )
427
442
assert len (segdata .shape ) == 3
428
443
assert segdata .shape == (1 , 5 , 2 )
429
444
430
- segdata = segtag .tagged_data (1 , 0 )
445
+ segdata = segtag .tagged_data (2 , 0 )
431
446
assert len (segdata .shape ) == 3
432
447
assert segdata .shape == (1 , 4 , 1 )
433
448
0 commit comments