MCPcopy Index your code
hub / github.com/pydata/xarray / test_fake_target_chunksize

Function test_fake_target_chunksize

xarray/tests/test_namedarray.py:624–642  ·  view source on GitHub ↗

Check that `fake_target_chunksize` returns the expected chunksize and dtype. - It pretends to dask we are chunking an array with an 8-byte dtype, ie. a float64. As such, it will *double* the amount of memory a 4-byte dtype (like float32) would try to use, fooling it into actually us

(
    input_array: DuckArray[Any],
    expected_chunksize_faked: int,
    expected_dtype: DTypeLike,
)

Source from the content-addressed store, hash-verified

622 ],
623)
624def test_fake_target_chunksize(
625 input_array: DuckArray[Any],
626 expected_chunksize_faked: int,
627 expected_dtype: DTypeLike,
628) -> None:
629 """
630 Check that `fake_target_chunksize` returns the expected chunksize and dtype.
631 - It pretends to dask we are chunking an array with an 8-byte dtype, ie. a float64.
632 As such, it will *double* the amount of memory a 4-byte dtype (like float32) would try to use,
633 fooling it into actually using the correct amount of memory. For object dtypes, which are
634 generally larger, it will reduce the effective dask configuration chunksize, reducing the size of
635 the arrays per chunk such that we get the same amount of memory used.
636 """
637 target_chunksize = 1024
638
639 faked_chunksize, dtype = fake_target_chunksize(input_array, target_chunksize)
640
641 assert faked_chunksize == expected_chunksize_faked
642 assert dtype == expected_dtype
643
644
645@requires_cftime

Callers

nothing calls this directly

Calls 1

fake_target_chunksizeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…