MCPcopy
hub / github.com/numpy/numpy / test_scalar

Method test_scalar

numpy/_core/tests/test_umath_complex.py:374–392  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

372 assert_almost_equal(y, y_r)
373
374 def test_scalar(self):
375 x = np.array([1, 1j, 2, 2.5 + .37j, np.inf, np.nan])
376 y = np.array([1, 1j, -0.5 + 1.5j, -0.5 + 1.5j, 2, 3])
377 lx = list(range(len(x)))
378
379 # Hardcode the expected `builtins.complex` values,
380 # as complex exponentiation is broken as of bpo-44698
381 p_r = [
382 1 + 0j,
383 0.20787957635076193 + 0j,
384 0.35812203996480685 + 0.6097119028618724j,
385 0.12659112128185032 + 0.48847676699581527j,
386 complex(np.inf, np.nan),
387 complex(np.nan, np.nan),
388 ]
389
390 n_r = [x[i] ** y[i] for i in lx]
391 for i in lx:
392 assert_almost_equal(n_r[i], p_r[i], err_msg=f'Loop {i}\n')
393
394 def test_array(self):
395 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