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

Method test_place

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

Source from the content-addressed store, hash-verified

1324 assert_array_equal(b, [3, 2, 2, 3, 3])
1325
1326 def test_place(self):
1327 # Make sure that non-np.ndarray objects
1328 # raise an error instead of doing nothing
1329 assert_raises(TypeError, place, [1, 2, 3], [True, False], [0, 1])
1330
1331 a = np.array([1, 4, 3, 2, 5, 8, 7])
1332 place(a, [0, 1, 0, 1, 0, 1, 0], [2, 4, 6])
1333 assert_array_equal(a, [1, 2, 3, 4, 5, 6, 7])
1334
1335 place(a, np.zeros(7), [])
1336 assert_array_equal(a, np.arange(1, 8))
1337
1338 place(a, [1, 0, 1, 0, 1, 0, 1], [8, 9])
1339 assert_array_equal(a, [8, 2, 9, 4, 8, 6, 9])
1340 assert_raises_regex(ValueError, "Cannot insert from an empty array",
1341 lambda: place(a, [0, 0, 0, 0, 0, 1, 0], []))
1342
1343 # See Issue #6974
1344 a = np.array(['12', '34'])
1345 place(a, [0, 1], '9')
1346 assert_array_equal(a, ['12', '9'])
1347
1348 def test_both(self):
1349 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