Skip to content

Commit

Permalink
Fix bug in cdist where using cdist(a, b, false) gave wrong result
Browse files Browse the repository at this point in the history
  • Loading branch information
anowacki committed Jun 29, 2018
1 parent 7978857 commit 0118d29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/CircStats.jl
Expand Up @@ -46,7 +46,8 @@ Angles are confined to be the smaller possible angle, so are in the range
Angles are in radians, unless `degrees` == true.
"""
cdist(a, b) = mod(b - a + pi, 2π) - pi
cdist(a, b, degrees::Bool) = rad2deg(cdist(deg2rad(a), deg2rad(b)))
cdist(a, b, degrees::Bool) =
degrees ? rad2deg(cdist(deg2rad(a), deg2rad(b))) : cdist(a, b)

"""
cmean(a::Array, degrees::Bool=false) -> mean
Expand Down
1 change: 1 addition & 0 deletions test/parameters.jl
Expand Up @@ -11,6 +11,7 @@ using Base.Test
@test cdist(2.1, 2.0) -0.1
@test cdist(340.1, 0.1, true) 20.0
let (a, b) = rand(2)
@test cdist(a, b, false) == cdist(a, b)
@test cdist(a, b) deg2rad(cdist(rad2deg(a), rad2deg(b), true))
@test cdist(a, b, true) rad2deg(cdist(deg2rad(a), deg2rad(b)))
end
Expand Down

0 comments on commit 0118d29

Please sign in to comment.