MCPcopy Create free account
hub / github.com/pydata/xarray / test_vindex

Function test_vindex

xarray/tests/test_nputils.py:15–32  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15def test_vindex() -> None:
16 x = np.arange(3 * 4 * 5).reshape((3, 4, 5))
17 vindex = NumpyVIndexAdapter(x)
18
19 # getitem
20 assert_array_equal(vindex[0], x[0])
21 assert_array_equal(vindex[[1, 2], [1, 2]], x[([1, 2], [1, 2])])
22 assert vindex[[0, 1], [0, 1], :].shape == (2, 5)
23 assert vindex[[0, 1], :, [0, 1]].shape == (2, 4)
24 assert vindex[:, [0, 1], [0, 1]].shape == (2, 3)
25
26 # setitem
27 vindex[:] = 0
28 assert_array_equal(x, np.zeros_like(x))
29 # assignment should not raise
30 vindex[[0, 1], [0, 1], :] = vindex[[0, 1], [0, 1], :]
31 vindex[[0, 1], :, [0, 1]] = vindex[[0, 1], :, [0, 1]]
32 vindex[:, [0, 1], [0, 1]] = vindex[:, [0, 1], [0, 1]]

Callers

nothing calls this directly

Calls 2

NumpyVIndexAdapterClass · 0.90
arangeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…