@@ -83,6 +83,27 @@ def test_init():
8383 assert_array_equal (np .asarray (ap ), arr )
8484
8585
86+ def test_tuplespec ():
87+ bio = BytesIO ()
88+ shape = [2 , 3 , 4 ]
89+ dtype = np .int32
90+ arr = np .arange (24 , dtype = dtype ).reshape (shape )
91+ bio .seek (16 )
92+ bio .write (arr .tostring (order = 'F' ))
93+ hdr = FunkyHeader (shape )
94+ tuple_spec = (hdr .get_data_shape (), hdr .get_data_dtype (),
95+ hdr .get_data_offset (), 1. , 0. )
96+ ap_header = ArrayProxy (bio , hdr )
97+ ap_tuple = ArrayProxy (bio , tuple_spec )
98+ for prop in ('shape' , 'dtype' , 'offset' , 'slope' , 'inter' , 'is_proxy' ):
99+ assert_equal (getattr (ap_header , prop ), getattr (ap_tuple , prop ))
100+ for method , args in (('get_unscaled' , ()), ('__array__' , ()),
101+ ('__getitem__' , ((0 , 2 , 1 ), ))
102+ ):
103+ assert_array_equal (getattr (ap_header , method )(* args ),
104+ getattr (ap_tuple , method )(* args ))
105+
106+
86107def write_raw_data (arr , hdr , fileobj ):
87108 hdr .set_data_shape (arr .shape )
88109 hdr .set_data_dtype (arr .dtype )
@@ -185,6 +206,14 @@ def __array__(self):
185206 assert_equal (arr .shape , shape )
186207
187208
209+ def test_reshaped_is_proxy ():
210+ shape = (1 , 2 , 3 , 4 )
211+ hdr = FunkyHeader (shape )
212+ bio = BytesIO ()
213+ prox = ArrayProxy (bio , hdr )
214+ assert_true (isinstance (prox .reshape ((2 , 3 , 4 )), ArrayProxy ))
215+
216+
188217def test_get_unscaled ():
189218 # Test fetch of raw array
190219 class FunkyHeader2 (FunkyHeader ):
0 commit comments