Skip to content

Commit

Permalink
Merge pull request #47 from JuliaManifolds/mbaran/fix-fill-Julia-1.0
Browse files Browse the repository at this point in the history
fixing mid_point on Julia 1.0
  • Loading branch information
mateuszbaran authored Aug 5, 2020
2 parents f8d3046 + a7767a1 commit 7471d94
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ManifoldsBase"
uuid = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
authors = ["Seth Axen <[email protected]>", "Mateusz Baran <[email protected]>", "Ronny Bergmann <[email protected]>", "Antoine Levitt <[email protected]>"]
version = "0.9.0"
version = "0.9.1"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
15 changes: 13 additions & 2 deletions src/ManifoldsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,19 @@ Saves the result in `q`.
"""
function mid_point!(M::Manifold, q, p1, p2)
X = log(M, p1, p2)
X /= 2
return exp!(M, q, p1, X)
return exp!(M, q, p1, X / 2)
end

@static if VERSION <= v"1.1"
function mid_point!(
M::Manifold,
q::AbstractArray{T1,0},
p1::AbstractArray{T2,0},
p2::AbstractArray{T3,0},
) where {T1,T2,T3}
X = log(M, p1, p2)
return exp!(M, q, p1, fill(X / 2))
end
end

"""
Expand Down
7 changes: 7 additions & 0 deletions test/default_manifold.jl
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,11 @@ Base.size(x::MatrixVectorTransport) = (size(x.m, 2),)
end
end
end

@testset "mid_point on 0-index arrays" begin
M = ManifoldsBase.DefaultManifold(1)
p1 = fill(0.0)
p2 = fill(1.0)
@test isapprox(M, fill(0.5), mid_point(M, p1, p2))
end
end
8 changes: 5 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ using Test
using ManifoldsBase
@testset "ManifoldsBase" begin

num_ambiguities = length(Test.detect_ambiguities(ManifoldsBase))
#num_ambiguities > 0 && @warn "The number of ambiguities in ManifoldsBase is $(num_ambiguities)."
@test num_ambiguities == 0
if VERSION >= v"1.1"
num_ambiguities = length(Test.detect_ambiguities(ManifoldsBase))
#num_ambiguities > 0 && @warn "The number of ambiguities in ManifoldsBase is $(num_ambiguities)."
@test num_ambiguities == 0
end
include("allocation.jl")
include("numbers.jl")
include("bases.jl")
Expand Down

2 comments on commit 7471d94

@kellertuer
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/19030

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 v0.9.1 -m "<description of version>" 7471d948b4e5a0485cff823313233fb2397c485b
git push origin v0.9.1

Please sign in to comment.