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

Method test_basic

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

Source from the content-addressed store, hash-verified

685class TestCumprod:
686
687 def test_basic(self):
688 ba = [1, 2, 10, 11, 6, 5, 4]
689 ba2 = [[1, 2, 3, 4], [5, 6, 7, 9], [10, 3, 4, 5]]
690 for ctype in [np.int16, np.uint16, np.int32, np.uint32,
691 np.float32, np.float64, np.complex64, np.complex128]:
692 a = np.array(ba, ctype)
693 a2 = np.array(ba2, ctype)
694 if ctype in ['1', 'b']:
695 assert_raises(ArithmeticError, np.cumprod, a)
696 assert_raises(ArithmeticError, np.cumprod, a2, 1)
697 assert_raises(ArithmeticError, np.cumprod, a)
698 else:
699 assert_array_equal(np.cumprod(a, axis=-1),
700 np.array([1, 2, 20, 220,
701 1320, 6600, 26400], ctype))
702 assert_array_equal(np.cumprod(a2, axis=0),
703 np.array([[1, 2, 3, 4],
704 [5, 12, 21, 36],
705 [50, 36, 84, 180]], ctype))
706 assert_array_equal(np.cumprod(a2, axis=-1),
707 np.array([[1, 2, 6, 24],
708 [5, 30, 210, 1890],
709 [10, 30, 120, 600]], ctype))
710
711
712class TestDiff:

Callers

nothing calls this directly

Calls 3

assert_raisesFunction · 0.90
assert_array_equalFunction · 0.90
cumprodMethod · 0.80

Tested by

no test coverage detected