MCPcopy Index your code
hub / github.com/numpy/numpy / test_power_float

Method test_power_float

numpy/_core/tests/test_umath.py:1112–1137  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1110
1111class TestPower:
1112 def test_power_float(self):
1113 x = np.array([1., 2., 3.])
1114 assert_equal(x**0, [1., 1., 1.])
1115 assert_equal(x**1, x)
1116 assert_equal(x**2, [1., 4., 9.])
1117 y = x.copy()
1118 y **= 2
1119 assert_equal(y, [1., 4., 9.])
1120 assert_almost_equal(x**(-1), [1., 0.5, 1. / 3])
1121 assert_almost_equal(x**(0.5), [1., ncu.sqrt(2), ncu.sqrt(3)])
1122
1123 for out, inp, msg in _gen_alignment_data(dtype=np.float32,
1124 type='unary',
1125 max_size=11):
1126 exp = [ncu.sqrt(i) for i in inp]
1127 assert_almost_equal(inp**(0.5), exp, err_msg=msg)
1128 np.sqrt(inp, out=out)
1129 assert_equal(out, exp, err_msg=msg)
1130
1131 for out, inp, msg in _gen_alignment_data(dtype=np.float64,
1132 type='unary',
1133 max_size=7):
1134 exp = [ncu.sqrt(i) for i in inp]
1135 assert_almost_equal(inp**(0.5), exp, err_msg=msg)
1136 np.sqrt(inp, out=out)
1137 assert_equal(out, exp, err_msg=msg)
1138
1139 def test_power_complex(self):
1140 x = np.array([1 + 2j, 2 + 3j, 3 + 4j])

Callers

nothing calls this directly

Calls 4

assert_equalFunction · 0.90
assert_almost_equalFunction · 0.90
_gen_alignment_dataFunction · 0.90
copyMethod · 0.45

Tested by

no test coverage detected