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

Method test_testPut

numpy/ma/tests/test_old_ma.py:309–329  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

307 assert_(eq(y5, y6))
308
309 def test_testPut(self):
310 # Test of put
311 d = arange(5)
312 n = [0, 0, 0, 1, 1]
313 m = make_mask(n)
314 m2 = m.copy()
315 x = array(d, mask=m)
316 assert_(x[3] is masked)
317 assert_(x[4] is masked)
318 x[[1, 4]] = [10, 40]
319 assert_(x._mask is m)
320 assert_(x[3] is masked)
321 assert_(x[4] is not masked)
322 assert_(eq(x, [0, 10, 2, -1, 40]))
323
324 x = array(d, mask=m2, copy=True)
325 x.put([0, 1, 2], [-1, 100, 200])
326 assert_(x._mask is not m2)
327 assert_(x[3] is masked)
328 assert_(x[4] is masked)
329 assert_(eq(x, [-1, 100, 200, 0, 0]))
330
331 def test_testPut2(self):
332 # Test of put

Callers

nothing calls this directly

Calls 7

make_maskFunction · 0.90
arrayFunction · 0.90
assert_Function · 0.90
arangeFunction · 0.85
eqFunction · 0.85
putMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected