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

Method test_signed_zeros

numpy/core/tests/test_scalarmath.py:420–443  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

418 assert_(np.isnan(b/a))
419
420 def test_signed_zeros(self):
421 with np.errstate(all="ignore"):
422 for t in [np.complex64, np.complex128]:
423 # tupled (numerator, denominator, expected)
424 # for testing as expected == numerator/denominator
425 data = (
426 (( 0.0,-1.0), ( 0.0, 1.0), (-1.0,-0.0)),
427 (( 0.0,-1.0), ( 0.0,-1.0), ( 1.0,-0.0)),
428 (( 0.0,-1.0), (-0.0,-1.0), ( 1.0, 0.0)),
429 (( 0.0,-1.0), (-0.0, 1.0), (-1.0, 0.0)),
430 (( 0.0, 1.0), ( 0.0,-1.0), (-1.0, 0.0)),
431 (( 0.0,-1.0), ( 0.0,-1.0), ( 1.0,-0.0)),
432 ((-0.0,-1.0), ( 0.0,-1.0), ( 1.0,-0.0)),
433 ((-0.0, 1.0), ( 0.0,-1.0), (-1.0,-0.0))
434 )
435 for cases in data:
436 n = cases[0]
437 d = cases[1]
438 ex = cases[2]
439 result = t(complex(n[0], n[1])) / t(complex(d[0], d[1]))
440 # check real and imag parts separately to avoid comparison
441 # in array context, which does not account for signed zeros
442 assert_equal(result.real, ex[0])
443 assert_equal(result.imag, ex[1])
444
445 def test_branches(self):
446 with np.errstate(all="ignore"):

Callers

nothing calls this directly

Calls 2

assert_equalFunction · 0.90
tFunction · 0.85

Tested by

no test coverage detected