(self)
| 124 | assert_array_equal(v_new, data) |
| 125 | |
| 126 | def test_getitem_1d_fancy(self): |
| 127 | v = self.cls(["x"], [0, 1, 2]) |
| 128 | # 1d-variable should be indexable by multi-dimensional Variable |
| 129 | ind = Variable(("a", "b"), [[0, 1], [0, 1]]) |
| 130 | v_new = v[ind] |
| 131 | assert v_new.dims == ("a", "b") |
| 132 | expected = np.array(v._data)[([0, 1], [0, 1]), ...] |
| 133 | assert_array_equal(v_new, expected) |
| 134 | |
| 135 | # boolean indexing |
| 136 | ind = Variable(("x",), [True, False, True]) |
| 137 | v_new = v[ind] |
| 138 | assert_identical(v[[0, 2]], v_new) |
| 139 | v_new = v[[True, False, True]] |
| 140 | assert_identical(v[[0, 2]], v_new) |
| 141 | |
| 142 | with pytest.raises(IndexError, match=r"Boolean indexer should"): |
| 143 | ind = Variable(("a",), [True, False, True]) |
| 144 | v[ind] |
| 145 | |
| 146 | def test_getitem_with_mask(self): |
| 147 | v = self.cls(["x"], [0, 1, 2]) |
nothing calls this directly
no test coverage detected