Skip to content

Commit

Permalink
Added to Base in JuliaLang/julia#38449
Browse files Browse the repository at this point in the history
I added tests that cover both methods in Base:
```julia
julia> methods(cispi)
[1] cispi(theta::Real) in Base at complex.jl:544
[2] cispi(z::Complex) in Base at complex.jl:563
```
(both of the doc tests and then a couple more examples of real inputs).
  • Loading branch information
jmert committed Nov 30, 2020
1 parent aca5c27 commit 72595dc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Compat"
uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
version = "3.23.0"
version = "3.24.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
10 changes: 10 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,16 @@ if VERSION < v"1.6.0-DEV.292" # 6cd329c371c1db3d9876bc337e82e274e50420e8
sincospi(x) = (sinpi(x), cospi(x))
end

# https://github.com/JuliaLang/julia/pull/38449
if VERSION < v"1.6.0-DEV.1591" # 96d59f957e4c0413e2876592072c0f08a7482cf2
export cispi
cispi(theta::Real) = Complex(reverse(sincospi(theta))...)
function cispi(z::Complex)
sipi, copi = sincospi(z)
return complex(real(copi) - imag(sipi), imag(copi) + real(sipi))
end
end

include("iterators.jl")
include("deprecated.jl")

Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,14 @@ end
@test sincospi(0.13im) == (sinpi(0.13im), cospi(0.13im))
end

# https://github.com/JuliaLang/julia/pull/38449
@testset "cispi(x)" begin
@test cispi(true) == -1 + 0im
@test cispi(1) == -1.0 + 0.0im
@test cispi(2.0) == 1.0 + 0.0im
@test cispi(0.25 + 1im) cis/4 + π*im)
end

include("iterators.jl")

# Import renaming, https://github.com/JuliaLang/julia/pull/37396,
Expand Down

0 comments on commit 72595dc

Please sign in to comment.