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

Method test_testOddFeatures

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

Source from the content-addressed store, hash-verified

362 assert_(all(take(ym, i, axis=0) == zm))
363
364 def test_testOddFeatures(self):
365 # Test of other odd features
366 x = arange(20)
367 x = x.reshape(4, 5)
368 x.flat[5] = 12
369 assert_(x[1, 0] == 12)
370 z = x + 10j * x
371 assert_(eq(z.real, x))
372 assert_(eq(z.imag, 10 * x))
373 assert_(eq((z * conjugate(z)).real, 101 * x * x))
374 z.imag[...] = 0.0
375
376 x = arange(10)
377 x[3] = masked
378 assert_(str(x[3]) == str(masked))
379 c = x >= 8
380 assert_(count(where(c, masked, masked)) == 0)
381 assert_(shape(where(c, masked, masked)) == c.shape)
382 z = where(c, x, masked)
383 assert_(z.dtype is x.dtype)
384 assert_(z[3] is masked)
385 assert_(z[4] is masked)
386 assert_(z[7] is masked)
387 assert_(z[8] is not masked)
388 assert_(z[9] is not masked)
389 assert_(eq(x, z))
390 z = where(c, masked, x)
391 assert_(z.dtype is x.dtype)
392 assert_(z[3] is masked)
393 assert_(z[4] is not masked)
394 assert_(z[7] is not masked)
395 assert_(z[8] is masked)
396 assert_(z[9] is masked)
397 z = masked_where(c, x)
398 assert_(z.dtype is x.dtype)
399 assert_(z[3] is masked)
400 assert_(z[4] is not masked)
401 assert_(z[7] is not masked)
402 assert_(z[8] is masked)
403 assert_(z[9] is masked)
404 assert_(eq(x, z))
405 x = array([1., 2., 3., 4., 5.])
406 c = array([1, 1, 1, 0, 0])
407 x[2] = masked
408 z = where(c, x, -x)
409 assert_(eq(z, [1., 2., 0., -4., -5]))
410 c[0] = masked
411 z = where(c, x, -x)
412 assert_(eq(z, [1., 2., 0., -4., -5]))
413 assert_(z[0] is masked)
414 assert_(z[1] is not masked)
415 assert_(z[2] is masked)
416 assert_(eq(masked_where(greater(x, 2), x), masked_greater(x, 2)))
417 assert_(eq(masked_where(greater_equal(x, 2), x),
418 masked_greater_equal(x, 2)))
419 assert_(eq(masked_where(less(x, 2), x), masked_less(x, 2)))
420 assert_(eq(masked_where(less_equal(x, 2), x), masked_less_equal(x, 2)))
421 assert_(eq(masked_where(not_equal(x, 2), x), masked_not_equal(x, 2)))

Callers

nothing calls this directly

Calls 15

assert_Function · 0.90
whereFunction · 0.90
shapeFunction · 0.90
masked_whereFunction · 0.90
arrayFunction · 0.90
masked_greaterFunction · 0.90
masked_greater_equalFunction · 0.90
masked_lessFunction · 0.90
masked_less_equalFunction · 0.90
masked_not_equalFunction · 0.90
masked_equalFunction · 0.90
masked_insideFunction · 0.90

Tested by

no test coverage detected