@@ -202,7 +202,7 @@ def validate_data_interface(self, imaker, params):
202
202
# Check get data returns array, and caches
203
203
img = imaker ()
204
204
assert_equal (img .shape , img .dataobj .shape )
205
- assert_equal (len ( img .shape ), img .dataobj . ndim )
205
+ assert_equal (img .ndim , len ( img .shape ) )
206
206
assert_data_similar (img .dataobj , params )
207
207
for meth_name in self .meth_names :
208
208
if params ['is_proxy' ]:
@@ -211,6 +211,8 @@ def validate_data_interface(self, imaker, params):
211
211
self ._check_array_interface (imaker , meth_name )
212
212
# Data shape is same as image shape
213
213
assert_equal (img .shape , getattr (img , meth_name )().shape )
214
+ # Data ndim is same as image ndim
215
+ assert_equal (img .ndim , getattr (img , meth_name )().ndim )
214
216
# Values to get_data caching parameter must be 'fill' or
215
217
# 'unchanged'
216
218
assert_raises (ValueError , img .get_data , caching = 'something' )
@@ -395,6 +397,17 @@ def validate_shape(self, imaker, params):
395
397
# Read only
396
398
assert_raises (AttributeError , setattr , img , 'shape' , np .eye (4 ))
397
399
400
+ def validate_ndim (self , imaker , params ):
401
+ # Validate shape
402
+ img = imaker ()
403
+ # Same as expected ndim
404
+ assert_equal (img .ndim , len (params ['shape' ]))
405
+ # Same as array ndim if passed
406
+ if 'data' in params :
407
+ assert_equal (img .ndim , params ['data' ].ndim )
408
+ # Read only
409
+ assert_raises (AttributeError , setattr , img , 'ndim' , 5 )
410
+
398
411
def validate_shape_deprecated (self , imaker , params ):
399
412
# Check deprecated get_shape API
400
413
img = imaker ()
0 commit comments