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

Method test_testArithmetic

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

Source from the content-addressed store, hash-verified

85 assert_(eq(x, xm))
86
87 def test_testArithmetic(self):
88 # Test of basic arithmetic.
89 (x, y, a10, m1, m2, xm, ym, z, zm, xf, s) = self.d
90 a2d = array([[1, 2], [0, 4]])
91 a2dm = masked_array(a2d, [[0, 0], [1, 0]])
92 assert_(eq(a2d * a2d, a2d * a2dm))
93 assert_(eq(a2d + a2d, a2d + a2dm))
94 assert_(eq(a2d - a2d, a2d - a2dm))
95 for s in [(12,), (4, 3), (2, 6)]:
96 x = x.reshape(s)
97 y = y.reshape(s)
98 xm = xm.reshape(s)
99 ym = ym.reshape(s)
100 xf = xf.reshape(s)
101 assert_(eq(-x, -xm))
102 assert_(eq(x + y, xm + ym))
103 assert_(eq(x - y, xm - ym))
104 assert_(eq(x * y, xm * ym))
105 with np.errstate(divide='ignore', invalid='ignore'):
106 assert_(eq(x / y, xm / ym))
107 assert_(eq(a10 + y, a10 + ym))
108 assert_(eq(a10 - y, a10 - ym))
109 assert_(eq(a10 * y, a10 * ym))
110 with np.errstate(divide='ignore', invalid='ignore'):
111 assert_(eq(a10 / y, a10 / ym))
112 assert_(eq(x + a10, xm + a10))
113 assert_(eq(x - a10, xm - a10))
114 assert_(eq(x * a10, xm * a10))
115 assert_(eq(x / a10, xm / a10))
116 assert_(eq(x ** 2, xm ** 2))
117 assert_(eq(abs(x) ** 2.5, abs(xm) ** 2.5))
118 assert_(eq(x ** y, xm ** ym))
119 assert_(eq(np.add(x, y), add(xm, ym)))
120 assert_(eq(np.subtract(x, y), subtract(xm, ym)))
121 assert_(eq(np.multiply(x, y), multiply(xm, ym)))
122 with np.errstate(divide='ignore', invalid='ignore'):
123 assert_(eq(np.divide(x, y), divide(xm, ym)))
124
125 def test_testMixedArithmetic(self):
126 na = np.array([1])

Callers

nothing calls this directly

Calls 11

arrayFunction · 0.90
assert_Function · 0.90
eqFunction · 0.85
absFunction · 0.85
subtractFunction · 0.85
divideFunction · 0.85
reshapeMethod · 0.80
divideMethod · 0.80
addFunction · 0.50
multiplyFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected