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

Method test_place

numpy/lib/tests/test_function_base.py:1545–1565  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1543 assert_array_equal(b, [3, 2, 2, 3, 3])
1544
1545 def test_place(self):
1546 # Make sure that non-np.ndarray objects
1547 # raise an error instead of doing nothing
1548 assert_raises(TypeError, place, [1, 2, 3], [True, False], [0, 1])
1549
1550 a = np.array([1, 4, 3, 2, 5, 8, 7])
1551 place(a, [0, 1, 0, 1, 0, 1, 0], [2, 4, 6])
1552 assert_array_equal(a, [1, 2, 3, 4, 5, 6, 7])
1553
1554 place(a, np.zeros(7), [])
1555 assert_array_equal(a, np.arange(1, 8))
1556
1557 place(a, [1, 0, 1, 0, 1, 0, 1], [8, 9])
1558 assert_array_equal(a, [8, 2, 9, 4, 8, 6, 9])
1559 assert_raises_regex(ValueError, "Cannot insert from an empty array",
1560 lambda: place(a, [0, 0, 0, 0, 0, 1, 0], []))
1561
1562 # See Issue #6974
1563 a = np.array(['12', '34'])
1564 place(a, [0, 1], '9')
1565 assert_array_equal(a, ['12', '9'])
1566
1567 def test_both(self):
1568 a = rand(10)

Callers

nothing calls this directly

Calls 4

assert_raisesFunction · 0.90
placeFunction · 0.90
assert_array_equalFunction · 0.90
assert_raises_regexFunction · 0.90

Tested by

no test coverage detected