(self)
| 202 | assert_(isnan(y[1:]).all()) |
| 203 | |
| 204 | def test_complex(self): |
| 205 | # Purely imaginary |
| 206 | y = geomspace(1j, 16j, num=5) |
| 207 | assert_allclose(y, [1j, 2j, 4j, 8j, 16j]) |
| 208 | assert_array_equal(y.real, 0) |
| 209 | |
| 210 | y = geomspace(-4j, -324j, num=5) |
| 211 | assert_allclose(y, [-4j, -12j, -36j, -108j, -324j]) |
| 212 | assert_array_equal(y.real, 0) |
| 213 | |
| 214 | y = geomspace(1 + 1j, 1000 + 1000j, num=4) |
| 215 | assert_allclose(y, [1 + 1j, 10 + 10j, 100 + 100j, 1000 + 1000j]) |
| 216 | |
| 217 | y = geomspace(-1 + 1j, -1000 + 1000j, num=4) |
| 218 | assert_allclose(y, [-1 + 1j, -10 + 10j, -100 + 100j, -1000 + 1000j]) |
| 219 | |
| 220 | # Logarithmic spirals |
| 221 | y = geomspace(-1, 1, num=3, dtype=complex) |
| 222 | assert_allclose(y, [-1, 1j, +1]) |
| 223 | |
| 224 | y = geomspace(0 + 3j, -3 + 0j, 3) |
| 225 | assert_allclose(y, [0 + 3j, -3 / sqrt(2) + 3j / sqrt(2), -3 + 0j]) |
| 226 | y = geomspace(0 + 3j, 3 + 0j, 3) |
| 227 | assert_allclose(y, [0 + 3j, 3 / sqrt(2) + 3j / sqrt(2), 3 + 0j]) |
| 228 | y = geomspace(-3 + 0j, 0 - 3j, 3) |
| 229 | assert_allclose(y, [-3 + 0j, -3 / sqrt(2) - 3j / sqrt(2), 0 - 3j]) |
| 230 | y = geomspace(0 + 3j, -3 + 0j, 3) |
| 231 | assert_allclose(y, [0 + 3j, -3 / sqrt(2) + 3j / sqrt(2), -3 + 0j]) |
| 232 | y = geomspace(-2 - 3j, 5 + 7j, 7) |
| 233 | assert_allclose(y, [-2 - 3j, -0.29058977 - 4.15771027j, |
| 234 | 2.08885354 - 4.34146838j, 4.58345529 - 3.16355218j, |
| 235 | 6.41401745 - 0.55233457j, 6.75707386 + 3.11795092j, |
| 236 | 5 + 7j]) |
| 237 | |
| 238 | # Type promotion should prevent the -5 from becoming a NaN |
| 239 | y = geomspace(3j, -5, 2) |
| 240 | assert_allclose(y, [3j, -5]) |
| 241 | y = geomspace(-5, 3j, 2) |
| 242 | assert_allclose(y, [-5, 3j]) |
| 243 | |
| 244 | def test_complex_shortest_path(self): |
| 245 | # test the shortest logarithmic spiral is used, see gh-25644 |
nothing calls this directly
no test coverage detected