MCPcopy
hub / github.com/dask/dask / test_gradient

Function test_gradient

dask/array/tests/test_routines.py:643–660  ·  view source on GitHub ↗
(shape, varargs, axis, edge_order)

Source from the content-addressed store, hash-verified

641)
642@pytest.mark.parametrize("edge_order", [1, 2])
643def test_gradient(shape, varargs, axis, edge_order):
644 a = np.random.default_rng().integers(0, 10, shape)
645 d_a = da.from_array(a, chunks=(len(shape) * (5,)))
646
647 r_a = np.gradient(a, *varargs, axis=axis, edge_order=edge_order)
648 r_d_a = da.gradient(d_a, *varargs, axis=axis, edge_order=edge_order)
649
650 if isinstance(axis, Number):
651 assert_eq(r_d_a, r_a)
652 else:
653 assert len(r_d_a) == len(r_a)
654
655 for e_r_d_a, e_r_a in zip(r_d_a, r_a):
656 assert_eq(e_r_d_a, e_r_a)
657
658 assert_eq(
659 da.sqrt(sum(map(da.square, r_d_a))), np.sqrt(sum(map(np.square, r_a)))
660 )
661
662
663def test_bincount():

Callers

nothing calls this directly

Calls 3

assert_eqFunction · 0.90
sumFunction · 0.50
integersMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…