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

Function test_broadcast_to_chunks

dask/array/tests/test_array_core.py:1379–1398  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1377
1378
1379def test_broadcast_to_chunks():
1380 x = np.random.default_rng().integers(10, size=(5, 1, 6))
1381 a = from_array(x, chunks=(3, 1, 3))
1382
1383 for shape, chunks, expected_chunks in [
1384 ((5, 3, 6), (3, -1, 3), ((3, 2), (3,), (3, 3))),
1385 ((5, 3, 6), (3, 1, 3), ((3, 2), (1, 1, 1), (3, 3))),
1386 ((2, 5, 3, 6), (1, 3, 1, 3), ((1, 1), (3, 2), (1, 1, 1), (3, 3))),
1387 ]:
1388 xb = np.broadcast_to(x, shape)
1389 ab = broadcast_to(a, shape, chunks=chunks)
1390 assert_eq(xb, ab)
1391 assert ab.chunks == expected_chunks
1392
1393 with pytest.raises(ValueError):
1394 broadcast_to(a, a.shape, chunks=((2, 3), (1,), (3, 3)))
1395 with pytest.raises(ValueError):
1396 broadcast_to(a, a.shape, chunks=((3, 2), (3,), (3, 3)))
1397 with pytest.raises(ValueError):
1398 broadcast_to(a, (5, 2, 6), chunks=((3, 2), (3,), (3, 3)))
1399
1400
1401def test_broadcast_arrays():

Callers

nothing calls this directly

Calls 4

from_arrayFunction · 0.90
broadcast_toFunction · 0.90
assert_eqFunction · 0.90
integersMethod · 0.45

Tested by

no test coverage detected