Skip to content

Commit

Permalink
Fix broken tests for wrap_mpi2_pi2
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdulrhmnGhanem committed Jan 23, 2025
1 parent 46f9646 commit d563faf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/angle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function wrap_0_pi(θ)
end

function wrap_mpi2_pi2(θ)
n = θ / 2π
n = 2θ / π
n = trunc.(Int, n)
y = ifelse.(mod.(n, 2) .== 0, θ - n * π, n * π - θ)
return length(y) == 1 ? y[1] : y
Expand Down
12 changes: 6 additions & 6 deletions test/test-angle-test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ end
@test wrap_mpi2_pi2(0) 0
@test wrap_mpi2_pi2(-0.5 * π) -0.5 * π
@test wrap_mpi2_pi2(0.5 * π) 0.5 * π
@test_broken wrap_mpi2_pi2(0.6 * π) 0.4 * π
@test_broken wrap_mpi2_pi2(-0.6 * π) -0.4 * π
@test_broken wrap_mpi2_pi2([0, -0.5 * π, 0.5 * π, 0.6 * π, -0.6 * π])
[0, -0.5 * π, 0.5 * π, 0.4 * π, -0.4 * π]
@test wrap_mpi2_pi2(0.6 * π) 0.4 * π
@test wrap_mpi2_pi2(-0.6 * π) -0.4 * π
@test wrap_mpi2_pi2([0, -0.5 * π, 0.5 * π, 0.6 * π, -0.6 * π])
[0, -0.5 * π, 0.5 * π, 0.4 * π, -0.4 * π]
end


Expand All @@ -51,8 +51,8 @@ end
@test angle_wrap(-θ, mode = :zero22pi) wrap_0_2pi(-θ)
@test angle_wrap(θ, mode = :zero2pi) wrap_0_pi(θ)
@test angle_wrap(-θ, mode = :zero2pi) wrap_0_pi(-θ)
# @test_broken angle_wrap(θ, mode = :mpi22pi2) ≈ wrap_mpi2_pi2(θ)
# @test_broken angle_wrap(-θ, mode = :mpi22pi2) ≈ wrap_mpi2_pi2(-θ)
@test angle_wrap(θ, mode = :mpi22pi2) wrap_mpi2_pi2(θ)
@test angle_wrap(-θ, mode = :mpi22pi2) wrap_mpi2_pi2(-θ)
@test_throws ArgumentError angle_wrap(θ, mode = :foo)
end
end
Expand Down

0 comments on commit d563faf

Please sign in to comment.