MCPcopy
hub / github.com/numpy/numpy / test_testCI

Method test_testCI

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

Source from the content-addressed store, hash-verified

268 assert_(eq(np.prod(x, 1), product(x, 1)))
269
270 def test_testCI(self):
271 # Test of conversions and indexing
272 x1 = np.array([1, 2, 4, 3])
273 x2 = array(x1, mask=[1, 0, 0, 0])
274 x3 = array(x1, mask=[0, 1, 0, 1])
275 x4 = array(x1)
276 # test conversion to strings
277 str(x2) # raises?
278 repr(x2) # raises?
279 assert_(eq(np.sort(x1), sort(x2, fill_value=0)))
280 # tests of indexing
281 assert_(type(x2[1]) is type(x1[1]))
282 assert_(x1[1] == x2[1])
283 assert_(x2[0] is masked)
284 assert_(eq(x1[2], x2[2]))
285 assert_(eq(x1[2:5], x2[2:5]))
286 assert_(eq(x1[:], x2[:]))
287 assert_(eq(x1[1:], x3[1:]))
288 x1[2] = 9
289 x2[2] = 9
290 assert_(eq(x1, x2))
291 x1[1:3] = 99
292 x2[1:3] = 99
293 assert_(eq(x1, x2))
294 x2[1] = masked
295 assert_(eq(x1, x2))
296 x2[1:3] = masked
297 assert_(eq(x1, x2))
298 x2[:] = x1
299 x2[1] = masked
300 assert_(allequal(getmask(x2), array([0, 1, 0, 0])))
301 x3[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0])
302 assert_(allequal(getmask(x3), array([0, 1, 1, 0])))
303 x4[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0])
304 assert_(allequal(getmask(x4), array([0, 1, 1, 0])))
305 assert_(allequal(x4, array([1, 2, 3, 4])))
306 x1 = np.arange(5) * 1.0
307 x2 = masked_values(x1, 3.0)
308 assert_(eq(x1, x2))
309 assert_(allequal(array([0, 0, 0, 1, 0], MaskType), x2.mask))
310 assert_(eq(3.0, x2.fill_value))
311 x1 = array([1, 'hello', 2, 3], object)
312 x2 = np.array([1, 'hello', 2, 3], object)
313 s1 = x1[1]
314 s2 = x2[1]
315 assert_equal(type(s2), str)
316 assert_equal(type(s1), str)
317 assert_equal(s1, s2)
318 assert_(x1[1:1].shape == (0,))
319
320 def test_testCopySize(self):
321 # Tests of some subtle points of copying and sizing.

Callers

nothing calls this directly

Calls 9

arrayFunction · 0.90
assert_Function · 0.90
sortFunction · 0.90
allequalFunction · 0.90
getmaskFunction · 0.90
masked_valuesFunction · 0.90
assert_equalFunction · 0.90
eqFunction · 0.85
sortMethod · 0.45

Tested by

no test coverage detected