@@ -108,7 +108,7 @@ def validate_header(self, imaker, params):
108
108
hdr = img .header # we can fetch it
109
109
# Read only
110
110
with pytest .raises (AttributeError ):
111
- setattr ( img , ' header' , hdr )
111
+ img . header = hdr
112
112
113
113
def validate_header_deprecated (self , imaker , params ):
114
114
# Check deprecated header API
@@ -164,9 +164,9 @@ def validate_filenames(self, imaker, params):
164
164
def validate_no_slicing (self , imaker , params ):
165
165
img = imaker ()
166
166
with pytest .raises (TypeError ):
167
- img . __getitem__ ( 'string' )
167
+ img [ 'string' ]
168
168
with pytest .raises (TypeError ):
169
- img . __getitem__ ( slice ( None ))
169
+ img [:]
170
170
171
171
def validate_get_data_deprecated (self , imaker , params ):
172
172
# Check deprecated header API
@@ -231,10 +231,10 @@ def validate_data_interface(self, imaker, params):
231
231
# dataobj is read only
232
232
fake_data = np .zeros (img .shape ).astype (img .get_data_dtype ())
233
233
with pytest .raises (AttributeError ):
234
- setattr ( img , ' dataobj' , fake_data )
234
+ img . dataobj = fake_data
235
235
# So is in_memory
236
236
with pytest .raises (AttributeError ):
237
- setattr ( img , ' in_memory' , False )
237
+ img . in_memory = False
238
238
239
239
def _check_proxy_interface (self , imaker , meth_name ):
240
240
# Parameters assert this is an array proxy
@@ -402,7 +402,7 @@ def validate_data_deprecated(self, imaker, params):
402
402
# Check setting _data raises error
403
403
fake_data = np .zeros (img .shape ).astype (img .get_data_dtype ())
404
404
with pytest .raises (AttributeError ):
405
- setattr ( img , ' _data' , fake_data )
405
+ img . _data = fake_data
406
406
407
407
def validate_shape (self , imaker , params ):
408
408
# Validate shape
@@ -414,7 +414,7 @@ def validate_shape(self, imaker, params):
414
414
assert img .shape == params ['data' ].shape
415
415
# Read only
416
416
with pytest .raises (AttributeError ):
417
- setattr ( img , ' shape' , np .eye (4 ) )
417
+ img . shape = np .eye (4 )
418
418
419
419
def validate_ndim (self , imaker , params ):
420
420
# Validate shape
@@ -426,7 +426,7 @@ def validate_ndim(self, imaker, params):
426
426
assert img .ndim == params ['data' ].ndim
427
427
# Read only
428
428
with pytest .raises (AttributeError ):
429
- setattr ( img , ' ndim' , 5 )
429
+ img . ndim = 5
430
430
431
431
def validate_shape_deprecated (self , imaker , params ):
432
432
# Check deprecated get_shape API
@@ -497,7 +497,7 @@ def validate_affine(self, imaker, params):
497
497
assert img .affine [0 , 0 ] == 1.5
498
498
# Read only
499
499
with pytest .raises (AttributeError ):
500
- setattr ( img , ' affine' , np .eye (4 ) )
500
+ img . affine = np .eye (4 )
501
501
502
502
def validate_affine_deprecated (self , imaker , params ):
503
503
# Check deprecated affine API
0 commit comments