@@ -154,27 +154,36 @@ def test_nifti1_init():
154
154
assert_array_equal (np .asarray (ap ), arr * 2.0 + 10 )
155
155
156
156
157
- def test_proxy_slicing ():
158
- shapes = (15 , 16 , 17 )
159
- for n_dim in range (1 , len (shapes ) + 1 ):
160
- shape = shapes [:n_dim ]
161
- arr = np .arange (np .prod (shape )).reshape (shape )
162
- for offset in (0 , 20 ):
163
- hdr = Nifti1Header ()
164
- hdr .set_data_offset (offset )
165
- hdr .set_data_dtype (arr .dtype )
166
- hdr .set_data_shape (shape )
167
- for order , klass in ('F' , ArrayProxy ), ('C' , CArrayProxy ):
168
- fobj = BytesIO ()
169
- fobj .write (b'\0 ' * offset )
170
- fobj .write (arr .tobytes (order = order ))
171
- prox = klass (fobj , hdr )
172
- for sliceobj in slicer_samples (shape ):
173
- assert_array_equal (arr [sliceobj ], prox [sliceobj ])
174
- # Check slicing works with scaling
157
+ @pytest .mark .parametrize ("n_dim" , (1 , 2 , 3 ))
158
+ @pytest .mark .parametrize ("offset" , (0 , 20 ))
159
+ def test_proxy_slicing (n_dim , offset ):
160
+ shape = (15 , 16 , 17 )[:n_dim ]
161
+ arr = np .arange (np .prod (shape )).reshape (shape )
162
+ hdr = Nifti1Header ()
163
+ hdr .set_data_offset (offset )
164
+ hdr .set_data_dtype (arr .dtype )
165
+ hdr .set_data_shape (shape )
166
+ for order , klass in ('F' , ArrayProxy ), ('C' , CArrayProxy ):
167
+ fobj = BytesIO ()
168
+ fobj .write (b'\0 ' * offset )
169
+ fobj .write (arr .tobytes (order = order ))
170
+ prox = klass (fobj , hdr )
171
+ assert prox .order == order
172
+ for sliceobj in slicer_samples (shape ):
173
+ assert_array_equal (arr [sliceobj ], prox [sliceobj ])
174
+
175
+
176
+ def test_proxy_slicing_with_scaling ():
177
+ shape = (15 , 16 , 17 )
178
+ offset = 20
179
+ arr = np .arange (np .prod (shape )).reshape (shape )
180
+ hdr = Nifti1Header ()
181
+ hdr .set_data_offset (offset )
182
+ hdr .set_data_dtype (arr .dtype )
183
+ hdr .set_data_shape (shape )
175
184
hdr .set_slope_inter (2.0 , 1.0 )
176
185
fobj = BytesIO ()
177
- fobj .write (b' \0 ' * offset )
186
+ fobj .write (bytes ( offset ) )
178
187
fobj .write (arr .tobytes (order = 'F' ))
179
188
prox = ArrayProxy (fobj , hdr )
180
189
sliceobj = (None , slice (None ), 1 , - 1 )
0 commit comments