@@ -63,7 +63,7 @@ def test_init():
63
63
bio .seek (16 )
64
64
bio .write (arr .tostring (order = 'F' ))
65
65
hdr = FunkyHeader (shape )
66
- ap = ArrayProxy (bio , hdr )
66
+ ap = ArrayProxy . from_header (bio , hdr )
67
67
assert_true (ap .file_like is bio )
68
68
assert_equal (ap .shape , shape )
69
69
# shape should be read only
@@ -79,7 +79,7 @@ def test_init():
79
79
bio = BytesIO ()
80
80
bio .seek (16 )
81
81
bio .write (arr .tostring (order = 'C' ))
82
- ap = CArrayProxy (bio , FunkyHeader ((2 , 3 , 4 )))
82
+ ap = CArrayProxy . from_header (bio , FunkyHeader ((2 , 3 , 4 )))
83
83
assert_array_equal (np .asarray (ap ), arr )
84
84
85
85
@@ -97,7 +97,7 @@ def test_nifti1_init():
97
97
arr = np .arange (24 , dtype = np .int16 ).reshape (shape )
98
98
write_raw_data (arr , hdr , bio )
99
99
hdr .set_slope_inter (2 , 10 )
100
- ap = ArrayProxy (bio , hdr )
100
+ ap = ArrayProxy . from_header (bio , hdr )
101
101
assert_true (ap .file_like == bio )
102
102
assert_equal (ap .shape , shape )
103
103
# Check there has been a copy of the header
@@ -110,7 +110,7 @@ def test_nifti1_init():
110
110
f = open ('test.nii' , 'wb' )
111
111
write_raw_data (arr , hdr , f )
112
112
f .close ()
113
- ap = ArrayProxy ('test.nii' , hdr )
113
+ ap = ArrayProxy . from_header ('test.nii' , hdr )
114
114
assert_true (ap .file_like == 'test.nii' )
115
115
assert_equal (ap .shape , shape )
116
116
assert_array_equal (np .asarray (ap ), arr * 2.0 + 10 )
@@ -130,15 +130,15 @@ def test_proxy_slicing():
130
130
fobj = BytesIO ()
131
131
fobj .write (b'\0 ' * offset )
132
132
fobj .write (arr .tostring (order = order ))
133
- prox = klass (fobj , hdr )
133
+ prox = klass . from_header (fobj , hdr )
134
134
for sliceobj in slicer_samples (shape ):
135
135
assert_array_equal (arr [sliceobj ], prox [sliceobj ])
136
136
# Check slicing works with scaling
137
137
hdr .set_slope_inter (2.0 , 1.0 )
138
138
fobj = BytesIO ()
139
139
fobj .write (b'\0 ' * offset )
140
140
fobj .write (arr .tostring (order = 'F' ))
141
- prox = ArrayProxy (fobj , hdr )
141
+ prox = ArrayProxy . from_header (fobj , hdr )
142
142
sliceobj = (None , slice (None ), 1 , - 1 )
143
143
assert_array_equal (arr [sliceobj ] * 2.0 + 1.0 , prox [sliceobj ])
144
144
@@ -147,7 +147,7 @@ def test_is_proxy():
147
147
# Test is_proxy function
148
148
hdr = FunkyHeader ((2 , 3 , 4 ))
149
149
bio = BytesIO ()
150
- prox = ArrayProxy (bio , hdr )
150
+ prox = ArrayProxy . from_header (bio , hdr )
151
151
assert_true (is_proxy (prox ))
152
152
assert_false (is_proxy (bio ))
153
153
assert_false (is_proxy (hdr ))
@@ -163,7 +163,7 @@ def test_reshape_dataobj():
163
163
shape = (1 , 2 , 3 , 4 )
164
164
hdr = FunkyHeader (shape )
165
165
bio = BytesIO ()
166
- prox = ArrayProxy (bio , hdr )
166
+ prox = ArrayProxy . from_header (bio , hdr )
167
167
arr = np .arange (np .prod (shape ), dtype = prox .dtype ).reshape (shape )
168
168
bio .write (b'\x00 ' * prox .offset + arr .tostring (order = 'F' ))
169
169
assert_array_equal (prox , arr )
@@ -198,7 +198,7 @@ def get_slope_inter(self):
198
198
arr = np .arange (24 , dtype = np .int32 ).reshape (shape , order = 'F' )
199
199
bio .write (b'\x00 ' * hdr .get_data_offset ())
200
200
bio .write (arr .tostring (order = 'F' ))
201
- prox = ArrayProxy (bio , hdr )
201
+ prox = ArrayProxy . from_header (bio , hdr )
202
202
assert_array_almost_equal (np .array (prox ), arr * 2.1 + 3.14 )
203
203
# Check unscaled read works
204
204
assert_array_almost_equal (prox .get_unscaled (), arr )
0 commit comments