@@ -132,6 +132,27 @@ def validate_asarray(self, pmaker, params):
132132 # Shape matches expected shape
133133 assert_equal (out .shape , params ['shape' ])
134134
135+ def validate_array_interface_with_dtype (self , pmaker , params ):
136+ # Check proxy returns expected array from asarray
137+ prox , fio , hdr = pmaker ()
138+ orig = np .array (prox , dtype = None )
139+ assert_array_equal (orig , params ['arr_out' ])
140+ assert_dt_equal (orig .dtype , params ['dtype_out' ])
141+
142+ for dtype in np .sctypes ['float' ] + np .sctypes ['int' ] + np .sctypes ['uint' ]:
143+ # Directly coerce with a dtype
144+ direct = dtype (prox )
145+ assert_almost_equal (direct , orig .astype (dtype ))
146+ assert_dt_equal (direct .dtype , np .dtype (dtype ))
147+ assert_equal (direct .shape , params ['shape' ])
148+ # All three methods should produce equivalent results
149+ for arrmethod in (np .array , np .asarray , np .asanyarray ):
150+ out = arrmethod (prox , dtype = dtype )
151+ assert_array_equal (out , direct )
152+ assert_dt_equal (out .dtype , np .dtype (dtype ))
153+ # Shape matches expected shape
154+ assert_equal (out .shape , params ['shape' ])
155+
135156 def validate_get_scaled (self , pmaker , params ):
136157 # Check proxy returns expected array from asarray
137158 prox , fio , hdr = pmaker ()
0 commit comments