MCPcopy
hub / github.com/numpy/numpy / test_testOddFeatures

Method test_testOddFeatures

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

Source from the content-addressed store, hash-verified

424 assert_(all(take(ym, i, axis=0) == zm))
425
426 def test_testOddFeatures(self):
427 # Test of other odd features
428 x = arange(20)
429 x = x.reshape(4, 5)
430 x.flat[5] = 12
431 assert_(x[1, 0] == 12)
432 z = x + 10j * x
433 assert_(eq(z.real, x))
434 assert_(eq(z.imag, 10 * x))
435 assert_(eq((z * conjugate(z)).real, 101 * x * x))
436 z.imag[...] = 0.0
437
438 x = arange(10)
439 x[3] = masked
440 assert_(str(x[3]) == str(masked))
441 c = x >= 8
442 assert_(count(where(c, masked, masked)) == 0)
443 assert_(shape(where(c, masked, masked)) == c.shape)
444 z = where(c, x, masked)
445 assert_(z.dtype is x.dtype)
446 assert_(z[3] is masked)
447 assert_(z[4] is masked)
448 assert_(z[7] is masked)
449 assert_(z[8] is not masked)
450 assert_(z[9] is not masked)
451 assert_(eq(x, z))
452 z = where(c, masked, x)
453 assert_(z.dtype is x.dtype)
454 assert_(z[3] is masked)
455 assert_(z[4] is not masked)
456 assert_(z[7] is not masked)
457 assert_(z[8] is masked)
458 assert_(z[9] is masked)
459 z = masked_where(c, x)
460 assert_(z.dtype is x.dtype)
461 assert_(z[3] is masked)
462 assert_(z[4] is not masked)
463 assert_(z[7] is not masked)
464 assert_(z[8] is masked)
465 assert_(z[9] is masked)
466 assert_(eq(x, z))
467 x = array([1., 2., 3., 4., 5.])
468 c = array([1, 1, 1, 0, 0])
469 x[2] = masked
470 z = where(c, x, -x)
471 assert_(eq(z, [1., 2., 0., -4., -5]))
472 c[0] = masked
473 z = where(c, x, -x)
474 assert_(eq(z, [1., 2., 0., -4., -5]))
475 assert_(z[0] is masked)
476 assert_(z[1] is not masked)
477 assert_(z[2] is masked)
478 assert_(eq(masked_where(greater(x, 2), x), masked_greater(x, 2)))
479 assert_(eq(masked_where(greater_equal(x, 2), x),
480 masked_greater_equal(x, 2)))
481 assert_(eq(masked_where(less(x, 2), x), masked_less(x, 2)))
482 assert_(eq(masked_where(less_equal(x, 2), x), masked_less_equal(x, 2)))
483 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