MCPcopy
hub / github.com/numpy/numpy / test_testArithmetic

Method test_testArithmetic

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

Source from the content-addressed store, hash-verified

147 assert_(eq(x, xm))
148
149 def test_testArithmetic(self):
150 # Test of basic arithmetic.
151 x, y, a10, _, _, xm, ym, _, _, xf, s = self._create_data()
152 a2d = array([[1, 2], [0, 4]])
153 a2dm = masked_array(a2d, [[0, 0], [1, 0]])
154 assert_(eq(a2d * a2d, a2d * a2dm))
155 assert_(eq(a2d + a2d, a2d + a2dm))
156 assert_(eq(a2d - a2d, a2d - a2dm))
157 for s in [(12,), (4, 3), (2, 6)]:
158 x = x.reshape(s)
159 y = y.reshape(s)
160 xm = xm.reshape(s)
161 ym = ym.reshape(s)
162 xf = xf.reshape(s)
163 assert_(eq(-x, -xm))
164 assert_(eq(x + y, xm + ym))
165 assert_(eq(x - y, xm - ym))
166 assert_(eq(x * y, xm * ym))
167 with np.errstate(divide='ignore', invalid='ignore'):
168 assert_(eq(x / y, xm / ym))
169 assert_(eq(a10 + y, a10 + ym))
170 assert_(eq(a10 - y, a10 - ym))
171 assert_(eq(a10 * y, a10 * ym))
172 with np.errstate(divide='ignore', invalid='ignore'):
173 assert_(eq(a10 / y, a10 / ym))
174 assert_(eq(x + a10, xm + a10))
175 assert_(eq(x - a10, xm - a10))
176 assert_(eq(x * a10, xm * a10))
177 assert_(eq(x / a10, xm / a10))
178 assert_(eq(x ** 2, xm ** 2))
179 assert_(eq(abs(x) ** 2.5, abs(xm) ** 2.5))
180 assert_(eq(x ** y, xm ** ym))
181 assert_(eq(np.add(x, y), add(xm, ym)))
182 assert_(eq(np.subtract(x, y), subtract(xm, ym)))
183 assert_(eq(np.multiply(x, y), multiply(xm, ym)))
184 with np.errstate(divide='ignore', invalid='ignore'):
185 assert_(eq(np.divide(x, y), divide(xm, ym)))
186
187 def test_testMixedArithmetic(self):
188 na = np.array([1])

Callers

nothing calls this directly

Calls 8

_create_dataMethod · 0.95
arrayFunction · 0.90
assert_Function · 0.90
eqFunction · 0.85
addFunction · 0.85
reshapeMethod · 0.80
multiplyFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected