MCPcopy
hub / github.com/dask/dask / test_aligned_coarsen_chunks

Function test_aligned_coarsen_chunks

dask/array/tests/test_routines.py:2322–2343  ·  view source on GitHub ↗
(chunks, divisor)

Source from the content-addressed store, hash-verified

2320 ],
2321)
2322def test_aligned_coarsen_chunks(chunks, divisor):
2323 from dask.array.routines import aligned_coarsen_chunks as acc
2324
2325 aligned_chunks = acc(chunks, divisor)
2326 any_remainders = (np.array(aligned_chunks) % divisor) != 0
2327 valid_chunks = np.where((np.array(chunks) % divisor) == 0)[0]
2328
2329 # check that total number of elements is conserved
2330 assert sum(aligned_chunks) == sum(chunks)
2331 # check that valid chunks are not modified
2332 assert [chunks[idx] for idx in valid_chunks] == [
2333 aligned_chunks[idx] for idx in valid_chunks
2334 ]
2335 # check that no chunks are 0
2336 assert (np.array(aligned_chunks) > 0).all()
2337 # check that at most one chunk was added
2338 assert len(aligned_chunks) <= len(chunks) + 1
2339 # check that either 0 or 1 chunks are not divisible by divisor
2340 assert any_remainders.sum() in (0, 1)
2341 # check that the only indivisible chunk is the last
2342 if any_remainders.sum() == 1:
2343 assert any_remainders[-1] == 1
2344
2345
2346def test_insert():

Callers

nothing calls this directly

Calls 4

sumFunction · 0.50
whereMethod · 0.45
allMethod · 0.45
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…