Skip to content

Commit

Permalink
Merge pull request #36 from JuliaManifolds/mbaran/robust-number-eltype
Browse files Browse the repository at this point in the history
More robust number_eltype
  • Loading branch information
mateuszbaran authored Apr 22, 2020
2 parents 0f3c593 + 5bd33be commit 0dfd130
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 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.8.1"
version = "0.8.2"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
2 changes: 1 addition & 1 deletion src/ManifoldsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ Numeric element type of the a nested representation of a point or a vector.
To be used in conjuntion with [`allocate`](@ref) or [`allocate_result`](@ref).
"""
number_eltype(x) = eltype(x)
function number_eltype(x::AbstractArray{<:AbstractArray})
function number_eltype(x::AbstractArray)
T = typeof(reduce(+, one(number_eltype(eti)) for eti x))
return T
end
Expand Down
15 changes: 8 additions & 7 deletions test/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ end
@test combine_allocation_promotion_functions(complex, identity) === complex
@test combine_allocation_promotion_functions(complex, complex) === complex

@test number_eltype([2.0]) == Float64
@test number_eltype([[2.0], [3]]) == Float64
@test number_eltype([[2], [3.0]]) == Float64
@test number_eltype([[2], [3]]) == Int
@test number_eltype(([2.0], [3])) == Float64
@test number_eltype(([2], [3.0])) == Float64
@test number_eltype(([2], [3])) == Int
@test number_eltype([2.0]) === Float64
@test number_eltype([[2.0], [3]]) === Float64
@test number_eltype([[2], [3.0]]) === Float64
@test number_eltype([[2], [3]]) === Int
@test number_eltype(([2.0], [3])) === Float64
@test number_eltype(([2], [3.0])) === Float64
@test number_eltype(([2], [3])) === Int
@test number_eltype(Any[[2.0], [3.0]]) === Float64
end

2 comments on commit 0dfd130

@mateuszbaran
Copy link
Member Author

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/13466

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.8.2 -m "<description of version>" 0dfd13052d3f4a1950938fe261eaef87511e5248
git push origin v0.8.2

Please sign in to comment.