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

Method test_scalar

numpy/core/tests/test_umath_complex.py:369–387  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

367 assert_almost_equal(y, y_r)
368
369 def test_scalar(self):
370 x = np.array([1, 1j, 2, 2.5+.37j, np.inf, np.nan])
371 y = np.array([1, 1j, -0.5+1.5j, -0.5+1.5j, 2, 3])
372 lx = list(range(len(x)))
373
374 # Hardcode the expected `builtins.complex` values,
375 # as complex exponentiation is broken as of bpo-44698
376 p_r = [
377 1+0j,
378 0.20787957635076193+0j,
379 0.35812203996480685+0.6097119028618724j,
380 0.12659112128185032+0.48847676699581527j,
381 complex(np.inf, np.nan),
382 complex(np.nan, np.nan),
383 ]
384
385 n_r = [x[i] ** y[i] for i in lx]
386 for i in lx:
387 assert_almost_equal(n_r[i], p_r[i], err_msg='Loop %d\n' % i)
388
389 def test_array(self):
390 x = np.array([1, 1j, 2, 2.5+.37j, np.inf, np.nan])

Callers

nothing calls this directly

Calls 1

assert_almost_equalFunction · 0.90

Tested by

no test coverage detected