Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix number_eltype(Vector{Vector{Float64}}) #179

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.15.6] 15/12/2023

### Fixed

* `number_eltype` correctly returns scalar type for nested array types like `number_eltype(Vector{Vector{Float64}})`.

## [0.15.5] 13/12/2023

### Added
Expand Down
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.15.5"
version = "0.15.6"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
6 changes: 6 additions & 0 deletions src/ManifoldsBase.jl
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,12 @@ number_eltype(x) = eltype(x)
return typeof(mapreduce(eti -> one(number_eltype(eti)), +, x))
end
@inline number_eltype(::AbstractArray{T}) where {T<:Number} = T
@inline function number_eltype(::Type{<:AbstractArray{T}}) where {T}
return number_eltype(T)
end
@inline function number_eltype(::Type{<:AbstractArray{T}}) where {T<:Number}
return T
end
@inline function number_eltype(x::Tuple)
@inline eti_to_one(eti) = one(number_eltype(eti))
return typeof(sum(map(eti_to_one, x)))
Expand Down
1 change: 1 addition & 0 deletions test/allocation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ ManifoldsBase.representation_size(::AllocManifold3) = (2, 3)
@test number_eltype(([2], [3.0])) === Float64
@test number_eltype(([2], [3])) === Int
@test number_eltype(Any[[2.0], [3.0]]) === Float64
@test number_eltype(typeof([[1.0, 2.0]])) === Float64

alloc2 = ManifoldsBase.allocate_result(AllocManifold2(), rand)
@test alloc2 isa Matrix{Float64}
Expand Down