MCPcopy
hub / github.com/dask/dask / test_diff_prepend

Function test_diff_prepend

dask/array/tests/test_cupy_routines.py:58–82  ·  view source on GitHub ↗
(n)

Source from the content-addressed store, hash-verified

56
57@pytest.mark.parametrize("n", [0, 1, 2])
58def test_diff_prepend(n):
59 x = cupy.arange(5) + 1
60 a = da.from_array(x, chunks=2)
61 assert_eq(da.diff(a, n, prepend=0), cupy.diff(x, n, prepend=0))
62 assert_eq(da.diff(a, n, prepend=[0]), cupy.diff(x, n, prepend=[0]))
63 assert_eq(da.diff(a, n, prepend=[-1, 0]), cupy.diff(x, n, prepend=[-1, 0]))
64
65 x = cupy.arange(16).reshape(4, 4)
66 a = da.from_array(x, chunks=2)
67 assert_eq(da.diff(a, n, axis=1, prepend=0), cupy.diff(x, n, axis=1, prepend=0))
68 assert_eq(
69 da.diff(a, n, axis=1, prepend=[[0], [0], [0], [0]]),
70 cupy.diff(x, n, axis=1, prepend=[[0], [0], [0], [0]]),
71 )
72 assert_eq(da.diff(a, n, axis=0, prepend=0), cupy.diff(x, n, axis=0, prepend=0))
73 assert_eq(
74 da.diff(a, n, axis=0, prepend=[[0, 0, 0, 0]]),
75 cupy.diff(x, n, axis=0, prepend=[[0, 0, 0, 0]]),
76 )
77
78 if n > 0:
79 # When order is 0 the result is the icupyut array, it doesn't raise
80 # an error
81 with pytest.raises(ValueError):
82 da.diff(a, n, prepend=cupy.zeros((3, 3)))
83
84
85@pytest.mark.parametrize("n", [0, 1, 2])

Callers

nothing calls this directly

Calls 5

assert_eqFunction · 0.90
diffMethod · 0.80
reshapeMethod · 0.80
arangeMethod · 0.45
zerosMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…