@@ -265,7 +265,7 @@ def test_extend(self):
265
265
assert_arrays_equal (sdict [k ][len (DATA ['tractogram' ]):],
266
266
new_data [k ])
267
267
268
- # Extending with an empty PerArrayDicts should change nothing.
268
+ # Extending with an empty PerArrayDict should change nothing.
269
269
sdict_orig = copy .deepcopy (sdict )
270
270
sdict .extend (PerArrayDict ())
271
271
for k in sdict_orig .keys ():
@@ -280,10 +280,17 @@ def test_extend(self):
280
280
sdict2 = PerArrayDict (len (DATA ['tractogram' ]), new_data )
281
281
assert_raises (ValueError , sdict .extend , sdict2 )
282
282
283
+ # Other dict has not the same entries (key mistmached).
284
+ new_data = {'mean_curvature' : 2 * np .array (DATA ['mean_curvature' ]),
285
+ 'mean_torsion' : 3 * np .array (DATA ['mean_torsion' ]),
286
+ 'other' : 4 * np .array (DATA ['mean_colors' ])}
287
+ sdict2 = PerArrayDict (len (DATA ['tractogram' ]), new_data )
288
+ assert_raises (ValueError , sdict .extend , sdict2 )
289
+
283
290
# Other dict has the right number of entries but wrong shape.
284
291
new_data = {'mean_curvature' : 2 * np .array (DATA ['mean_curvature' ]),
285
292
'mean_torsion' : 3 * np .array (DATA ['mean_torsion' ]),
286
- 'other ' : 4 * np .array (DATA ['mean_torsion' ])}
293
+ 'mean_colors ' : 4 * np .array (DATA ['mean_torsion' ])}
287
294
sdict2 = PerArrayDict (len (DATA ['tractogram' ]), new_data )
288
295
assert_raises (ValueError , sdict .extend , sdict2 )
289
296
@@ -343,7 +350,7 @@ def test_extend(self):
343
350
total_nb_rows = DATA ['tractogram' ].streamlines .total_nb_rows
344
351
sdict = PerArraySequenceDict (total_nb_rows , DATA ['data_per_point' ])
345
352
346
- # Test compatible PerArrayDicts .
353
+ # Test compatible PerArraySequenceDicts .
347
354
list_nb_points = [2 , 7 , 4 ]
348
355
data_per_point_shapes = {"colors" : DATA ['colors' ][0 ].shape [1 :],
349
356
"fa" : DATA ['fa' ][0 ].shape [1 :]}
@@ -360,13 +367,13 @@ def test_extend(self):
360
367
assert_arrays_equal (sdict [k ][len (DATA ['tractogram' ]):],
361
368
new_data [k ])
362
369
363
- # Extending with an empty PerArrayDicts should change nothing.
370
+ # Extending with an empty PerArraySequenceDicts should change nothing.
364
371
sdict_orig = copy .deepcopy (sdict )
365
372
sdict .extend (PerArraySequenceDict ())
366
373
for k in sdict_orig .keys ():
367
374
assert_arrays_equal (sdict [k ], sdict_orig [k ])
368
375
369
- # Test incompatible PerArrayDicts .
376
+ # Test incompatible PerArraySequenceDicts .
370
377
# Other dict has more entries.
371
378
data_per_point_shapes = {"colors" : DATA ['colors' ][0 ].shape [1 :],
372
379
"fa" : DATA ['fa' ][0 ].shape [1 :],
@@ -377,6 +384,15 @@ def test_extend(self):
377
384
sdict2 = PerArraySequenceDict (np .sum (list_nb_points ), new_data )
378
385
assert_raises (ValueError , sdict .extend , sdict2 )
379
386
387
+ # Other dict has not the same entries (key mistmached).
388
+ data_per_point_shapes = {"colors" : DATA ['colors' ][0 ].shape [1 :],
389
+ "other" : DATA ['fa' ][0 ].shape [1 :]}
390
+ _ , new_data , _ = make_fake_tractogram (list_nb_points ,
391
+ data_per_point_shapes ,
392
+ rng = DATA ['rng' ])
393
+ sdict2 = PerArraySequenceDict (np .sum (list_nb_points ), new_data )
394
+ assert_raises (ValueError , sdict .extend , sdict2 )
395
+
380
396
# Other dict has the right number of entries but wrong shape.
381
397
data_per_point_shapes = {"colors" : DATA ['colors' ][0 ].shape [1 :],
382
398
"fa" : DATA ['fa' ][0 ].shape [1 :] + (3 ,)}
0 commit comments