MCPcopy Create free account
hub / github.com/dask/dask / test_tree_reduce_depth

Function test_tree_reduce_depth

dask/array/tests/test_reductions.py:576–610  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

574
575
576def test_tree_reduce_depth():
577 # 2D
578 x = da.from_array(np.arange(242).reshape((11, 22)), chunks=(3, 4))
579 thresh = {0: 2, 1: 3}
580 assert_max_deps(x.sum(split_every=thresh), 2 * 3)
581 assert_max_deps(x.sum(axis=(), split_every=thresh), 1)
582 assert_max_deps(x.sum(axis=0, split_every=thresh), 2)
583 assert_max_deps(x.sum(axis=1, split_every=thresh), 3)
584 assert_max_deps(x.sum(split_every=20), 20, False)
585 assert_max_deps(x.sum(axis=(), split_every=20), 1)
586 assert_max_deps(x.sum(axis=0, split_every=20), 4)
587 assert_max_deps(x.sum(axis=1, split_every=20), 6)
588
589 # 3D
590 x = da.from_array(np.arange(11 * 22 * 29).reshape((11, 22, 29)), chunks=(3, 4, 5))
591 thresh = {0: 2, 1: 3, 2: 4}
592 assert_max_deps(x.sum(split_every=thresh), 2 * 3 * 4)
593 assert_max_deps(x.sum(axis=(), split_every=thresh), 1)
594 assert_max_deps(x.sum(axis=0, split_every=thresh), 2)
595 assert_max_deps(x.sum(axis=1, split_every=thresh), 3)
596 assert_max_deps(x.sum(axis=2, split_every=thresh), 4)
597 assert_max_deps(x.sum(axis=(0, 1), split_every=thresh), 2 * 3)
598 assert_max_deps(x.sum(axis=(0, 2), split_every=thresh), 2 * 4)
599 assert_max_deps(x.sum(axis=(1, 2), split_every=thresh), 3 * 4)
600 assert_max_deps(x.sum(split_every=20), 20, False)
601 assert_max_deps(x.sum(axis=(), split_every=20), 1)
602 assert_max_deps(x.sum(axis=0, split_every=20), 4)
603 assert_max_deps(x.sum(axis=1, split_every=20), 6)
604 assert_max_deps(x.sum(axis=2, split_every=20), 6)
605 assert_max_deps(x.sum(axis=(0, 1), split_every=20), 20, False)
606 assert_max_deps(x.sum(axis=(0, 2), split_every=20), 20, False)
607 assert_max_deps(x.sum(axis=(1, 2), split_every=20), 20, False)
608 assert_max_deps(x.sum(axis=(0, 1), split_every=40), 4 * 6)
609 assert_max_deps(x.sum(axis=(0, 2), split_every=40), 4 * 6)
610 assert_max_deps(x.sum(axis=(1, 2), split_every=40), 6 * 6)
611
612
613def test_tree_reduce_set_options():

Callers

nothing calls this directly

Calls 4

reshapeMethod · 0.80
assert_max_depsFunction · 0.70
arangeMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected