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

Method test_testInplace

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

Source from the content-addressed store, hash-verified

558 assert_(t[2] == 3)
559
560 def test_testInplace(self):
561 # Test of inplace operations and rich comparisons
562 y = arange(10)
563
564 x = arange(10)
565 xm = arange(10)
566 xm[2] = masked
567 x += 1
568 assert_(eq(x, y + 1))
569 xm += 1
570 assert_(eq(x, y + 1))
571
572 x = arange(10)
573 xm = arange(10)
574 xm[2] = masked
575 x -= 1
576 assert_(eq(x, y - 1))
577 xm -= 1
578 assert_(eq(xm, y - 1))
579
580 x = arange(10) * 1.0
581 xm = arange(10) * 1.0
582 xm[2] = masked
583 x *= 2.0
584 assert_(eq(x, y * 2))
585 xm *= 2.0
586 assert_(eq(xm, y * 2))
587
588 x = arange(10) * 2
589 xm = arange(10)
590 xm[2] = masked
591 x //= 2
592 assert_(eq(x, y))
593 xm //= 2
594 assert_(eq(x, y))
595
596 x = arange(10) * 1.0
597 xm = arange(10) * 1.0
598 xm[2] = masked
599 x /= 2.0
600 assert_(eq(x, y / 2.0))
601 xm /= arange(10)
602 assert_(eq(xm, ones((10,))))
603
604 x = arange(10).astype(np.float32)
605 xm = arange(10)
606 xm[2] = masked
607 x += 1.
608 assert_(eq(x, y + 1.))
609
610 def test_testPickle(self):
611 # Test of pickling

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected