JuliaGaussianProcesses / ParameterHandling.jl

Foundational tooling for handling collections of parameters in models
MIT License
72 stars 11 forks source link

Different behavior for Integers and Vectors of Integers when flattened #31

Closed paschermayr closed 3 years ago

paschermayr commented 3 years ago

Hi there,

I noticed a different behavior for Integers and Vectors of Integers when flattened - Integers are not flattened, but Vectors of Integers are flattened and transformed to Float64s. MWE:

using ParameterHandling
val = ( a = 1., b = 2, c = [3., 4.], d = [5, 6] )
ParameterHandling.flatten(val) # Vector{Float64} with 5 elements -> [1., 3., 4., 5., 6.]

I believe this line might cause Vector of Integers to flatten as well:

flatten(::Type{T}, x::Vector{R}) where {T<:Real, R<:Real} = (Vector{T}(x), Vector{R})