Skip to content

Commit

Permalink
Fix number_eltype(Vector{Vector{Float64}}) (#179)
Browse files Browse the repository at this point in the history
* Fix number_eltype(Vector{Vector{Float64}})

* number, not real
  • Loading branch information
mateuszbaran authored Dec 15, 2023
1 parent 10d930f commit ce3f90b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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

0 comments on commit ce3f90b

Please sign in to comment.