()
| 13 | |
| 14 | |
| 15 | def 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]] |
nothing calls this directly
no test coverage detected
searching dependent graphs…