Skip to content

Commit

Permalink
Add cispi(x) (#732)
Browse files Browse the repository at this point in the history
Added to Base in JuliaLang/julia#38449

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 authored Dec 13, 2020
1 parent c93f3dc commit 12eec81
Show file tree
Hide file tree
Showing 4 changed files with 23 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.24.0"
version = "3.25.0"

[deps]
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ without incrementing the major version of Compat.jl if necessary to match
changes in `julia`.

## Supported features

* `cispi(x)` for accurately calculating `cis(pi * x)` ([#38449]) (since Compat 3.25)

* `startswith(s, r::Regex)` and `endswith(s, r::Regex)` ([#29790]) (since Compat 3.24)

* `sincospi(x)` for calculating the tuple `(sinpi(x), cospi(x))` ([#35816]) (since Compat 3.23)
Expand Down Expand Up @@ -232,3 +235,4 @@ Note that you should specify the correct minimum version for `Compat` in the
[#37391]: https://github.com/JuliaLang/julia/pull/37391
[#35816]: https://github.com/JuliaLang/julia/pull/35816
[#29790]: https://github.com/JuliaLang/julia/pull/29790
[#38449]: https://github.com/JuliaLang/julia/pull/38449
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

# https://github.com/JuliaLang/julia/pull/29790
if VERSION < v"1.2.0-DEV.246"
using Base.PCRE
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

2 comments on commit 12eec81

@simeonschaub
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/26322

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v3.25.0 -m "<description of version>" 12eec814f7bdb17ab63c45f69b0b97354756f51c
git push origin v3.25.0

Please sign in to comment.