MCPcopy Create free account
hub / github.com/numpy/numpy / test_multidim

Method test_multidim

numpy/core/tests/test_indexing.py:1195–1223  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1193 self.a, (np.zeros_like(self.a, dtype=bool)[None, ...],))
1194
1195 def test_multidim(self):
1196 # Automatically test combinations with complex indexes on 2nd (or 1st)
1197 # spot and the simple ones in one other spot.
1198 with warnings.catch_warnings():
1199 # This is so that np.array(True) is not accepted in a full integer
1200 # index, when running the file separately.
1201 warnings.filterwarnings('error', '', DeprecationWarning)
1202 warnings.filterwarnings('error', '', np.VisibleDeprecationWarning)
1203
1204 def isskip(idx):
1205 return isinstance(idx, str) and idx == "skip"
1206
1207 for simple_pos in [0, 2, 3]:
1208 tocheck = [self.fill_indices, self.complex_indices,
1209 self.fill_indices, self.fill_indices]
1210 tocheck[simple_pos] = self.simple_indices
1211 for index in product(*tocheck):
1212 index = tuple(i for i in index if not isskip(i))
1213 self._check_multi_index(self.a, index)
1214 self._check_multi_index(self.b, index)
1215
1216 # Check very simple item getting:
1217 self._check_multi_index(self.a, (0, 0, 0, 0))
1218 self._check_multi_index(self.b, (0, 0, 0, 0))
1219 # Also check (simple cases of) too many indices:
1220 assert_raises(IndexError, self.a.__getitem__, (0, 0, 0, 0, 0))
1221 assert_raises(IndexError, self.a.__setitem__, (0, 0, 0, 0, 0), 0)
1222 assert_raises(IndexError, self.a.__getitem__, (0, 0, [1], 0, 0))
1223 assert_raises(IndexError, self.a.__setitem__, (0, 0, [1], 0, 0), 0)
1224
1225 def test_1d(self):
1226 a = np.arange(10)

Callers

nothing calls this directly

Calls 3

_check_multi_indexMethod · 0.95
assert_raisesFunction · 0.90
productFunction · 0.85

Tested by

no test coverage detected