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

Method test_basic_arithmetic

numpy/ma/tests/test_core.py:1042–1075  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1040 np.seterr(**self.err_status)
1041
1042 def test_basic_arithmetic(self):
1043 # Test of basic arithmetic.
1044 (x, y, a10, m1, m2, xm, ym, z, zm, xf) = self.d
1045 a2d = array([[1, 2], [0, 4]])
1046 a2dm = masked_array(a2d, [[0, 0], [1, 0]])
1047 assert_equal(a2d * a2d, a2d * a2dm)
1048 assert_equal(a2d + a2d, a2d + a2dm)
1049 assert_equal(a2d - a2d, a2d - a2dm)
1050 for s in [(12,), (4, 3), (2, 6)]:
1051 x = x.reshape(s)
1052 y = y.reshape(s)
1053 xm = xm.reshape(s)
1054 ym = ym.reshape(s)
1055 xf = xf.reshape(s)
1056 assert_equal(-x, -xm)
1057 assert_equal(x + y, xm + ym)
1058 assert_equal(x - y, xm - ym)
1059 assert_equal(x * y, xm * ym)
1060 assert_equal(x / y, xm / ym)
1061 assert_equal(a10 + y, a10 + ym)
1062 assert_equal(a10 - y, a10 - ym)
1063 assert_equal(a10 * y, a10 * ym)
1064 assert_equal(a10 / y, a10 / ym)
1065 assert_equal(x + a10, xm + a10)
1066 assert_equal(x - a10, xm - a10)
1067 assert_equal(x * a10, xm * a10)
1068 assert_equal(x / a10, xm / a10)
1069 assert_equal(x ** 2, xm ** 2)
1070 assert_equal(abs(x) ** 2.5, abs(xm) ** 2.5)
1071 assert_equal(x ** y, xm ** ym)
1072 assert_equal(np.add(x, y), add(xm, ym))
1073 assert_equal(np.subtract(x, y), subtract(xm, ym))
1074 assert_equal(np.multiply(x, y), multiply(xm, ym))
1075 assert_equal(np.divide(x, y), divide(xm, ym))
1076
1077 def test_divide_on_different_shapes(self):
1078 x = arange(6, dtype=float)

Callers

nothing calls this directly

Calls 10

arrayFunction · 0.90
assert_equalFunction · 0.90
addFunction · 0.90
multiplyFunction · 0.90
absFunction · 0.85
subtractFunction · 0.85
divideFunction · 0.85
reshapeMethod · 0.80
divideMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected