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

Method test_testInplace

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

Source from the content-addressed store, hash-verified

496 assert_(t[2] == 3)
497
498 def test_testInplace(self):
499 # Test of inplace operations and rich comparisons
500 y = arange(10)
501
502 x = arange(10)
503 xm = arange(10)
504 xm[2] = masked
505 x += 1
506 assert_(eq(x, y + 1))
507 xm += 1
508 assert_(eq(x, y + 1))
509
510 x = arange(10)
511 xm = arange(10)
512 xm[2] = masked
513 x -= 1
514 assert_(eq(x, y - 1))
515 xm -= 1
516 assert_(eq(xm, y - 1))
517
518 x = arange(10) * 1.0
519 xm = arange(10) * 1.0
520 xm[2] = masked
521 x *= 2.0
522 assert_(eq(x, y * 2))
523 xm *= 2.0
524 assert_(eq(xm, y * 2))
525
526 x = arange(10) * 2
527 xm = arange(10)
528 xm[2] = masked
529 x //= 2
530 assert_(eq(x, y))
531 xm //= 2
532 assert_(eq(x, y))
533
534 x = arange(10) * 1.0
535 xm = arange(10) * 1.0
536 xm[2] = masked
537 x /= 2.0
538 assert_(eq(x, y / 2.0))
539 xm /= arange(10)
540 assert_(eq(xm, ones((10,))))
541
542 x = arange(10).astype(np.float32)
543 xm = arange(10)
544 xm[2] = masked
545 x += 1.
546 assert_(eq(x, y + 1.))
547
548 def test_testPickle(self):
549 # Test of pickling

Callers

nothing calls this directly

Calls 5

assert_Function · 0.90
onesFunction · 0.90
arangeFunction · 0.85
eqFunction · 0.85
astypeMethod · 0.80

Tested by

no test coverage detected