MCPcopy
hub / github.com/pydata/xarray / test_create_mask_dask

Function test_create_mask_dask

xarray/tests/test_indexing.py:978–1000  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

976
977
978def test_create_mask_dask() -> None:
979 da = pytest.importorskip("dask.array")
980
981 indexer = indexing.OuterIndexer((1, slice(2), np.array([0, -1, 2])))
982 expected = np.array(2 * [[False, True, False]])
983 actual = indexing.create_mask(
984 indexer, (5, 5, 5), da.empty((2, 3), chunks=((1, 1), (2, 1)))
985 )
986 assert actual.chunks == ((1, 1), (2, 1))
987 np.testing.assert_array_equal(expected, actual)
988
989 indexer_vec = indexing.VectorizedIndexer(
990 (np.array([0, -1, 2]), slice(None), np.array([0, 1, -1]))
991 )
992 expected = np.array([[False, True, True]] * 2).T
993 actual = indexing.create_mask(
994 indexer_vec, (5, 2), da.empty((3, 2), chunks=((3,), (2,)))
995 )
996 assert isinstance(actual, da.Array)
997 np.testing.assert_array_equal(expected, actual)
998
999 with pytest.raises(ValueError):
1000 indexing.create_mask(indexer_vec, (5, 2), da.empty((5,), chunks=(1,)))
1001
1002
1003def test_create_mask_error() -> None:

Callers

nothing calls this directly

Calls 1

emptyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…