MCPcopy Index your code
hub / github.com/numpy/numpy / test_as_index

Method test_as_index

numpy/lib/tests/test_arraypad.py:89–102  ·  view source on GitHub ↗

Test results if `as_index=True`.

(self)

Source from the content-addressed store, hash-verified

87 )
88
89 def test_as_index(self):
90 """Test results if `as_index=True`."""
91 assert_equal(
92 _as_pairs([2.6, 3.3], 10, as_index=True),
93 np.array([[3, 3]] * 10, dtype=np.intp)
94 )
95 assert_equal(
96 _as_pairs([2.6, 4.49], 10, as_index=True),
97 np.array([[3, 4]] * 10, dtype=np.intp)
98 )
99 for x in (-3, [-3], [[-3]], [-3, 4], [3, -4], [[-3, 4]], [[4, -3]],
100 [[1, 2]] * 9 + [[1, -2]]):
101 with pytest.raises(ValueError, match="negative values"):
102 _as_pairs(x, 10, as_index=True)
103
104 def test_exceptions(self):
105 """Ensure faulty usage is discovered."""

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
_as_pairsFunction · 0.90

Tested by

no test coverage detected