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

Method test_at_negative_indexes

numpy/core/tests/test_ufunc.py:2224–2235  ·  view source on GitHub ↗
(self, dtype, ufunc)

Source from the content-addressed store, hash-verified

2222 @pytest.mark.parametrize("ufunc",
2223 [np.add, np.subtract, np.divide, np.minimum, np.maximum])
2224 def test_at_negative_indexes(self, dtype, ufunc):
2225 a = np.arange(0, 10).astype(dtype)
2226 indxs = np.array([-1, 1, -1, 2]).astype(np.intp)
2227 vals = np.array([1, 5, 2, 10], dtype=a.dtype)
2228
2229 expected = a.copy()
2230 for i, v in zip(indxs, vals):
2231 expected[i] = ufunc(expected[i], v)
2232
2233 ufunc.at(a, indxs, vals)
2234 assert_array_equal(a, expected)
2235 assert np.all(indxs == [-1, 1, -1, 2])
2236
2237 def test_at_not_none_signature(self):
2238 # Test ufuncs with non-trivial signature raise a TypeError

Callers

nothing calls this directly

Calls 5

assert_array_equalFunction · 0.90
ufuncClass · 0.85
astypeMethod · 0.80
copyMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected