MCPcopy
hub / github.com/dask/dask / test_view

Function test_view

dask/array/tests/test_cupy_core.py:190–223  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

188
189
190def test_view():
191 x = np.arange(56).reshape((7, 8))
192 d = da.from_array(cupy.array(x), chunks=(2, 3))
193
194 result = d.view()
195 assert type(result._meta) == cupy.ndarray
196 assert_eq(result, result) # Check that _meta and computed arrays match types
197 assert_eq(result, x.view(), check_type=False)
198
199 result = d.view("i4")
200 assert type(result._meta) == cupy.ndarray
201 assert_eq(result, result) # Check that _meta and computed arrays match types
202 assert_eq(result, x.view("i4"), check_type=False)
203
204 result = d.view("i2")
205 assert type(result._meta) == cupy.ndarray
206 assert_eq(result, result) # Check that _meta and computed arrays match types
207 assert_eq(result, x.view("i2"), check_type=False)
208 assert all(isinstance(s, int) for s in d.shape)
209
210 x = np.arange(8, dtype="i1")
211 d = da.from_array(cupy.array(x), chunks=(4,))
212 result = d.view("i4")
213 assert type(result._meta) == cupy.ndarray
214 assert_eq(result, result) # Check that _meta and computed arrays match types
215 assert_eq(x.view("i4"), d.view("i4"), check_type=False)
216
217 with pytest.raises(ValueError):
218 x = np.arange(8, dtype="i1")
219 d = da.from_array(cupy.array(x), chunks=(3,))
220 d.view("i4")
221
222 with pytest.raises(ValueError):
223 d.view("i4", order="asdf")
224
225
226def test_view_fortran():

Callers

nothing calls this directly

Calls 5

assert_eqFunction · 0.90
allFunction · 0.85
reshapeMethod · 0.80
viewMethod · 0.80
arangeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…