(self)
| 1110 | |
| 1111 | class 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]) |
nothing calls this directly
no test coverage detected