From 6894f28de201c2d0188b73d24e7e43a8b2a4340e Mon Sep 17 00:00:00 2001 From: Simone Carlo Surace <51025924+simsurace@users.noreply.github.com> Date: Mon, 5 Feb 2024 20:45:44 +0100 Subject: [PATCH] Add support for `nothing` I have been using this quite often to conditionally drop specific parameters. --- src/flatten.jl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/flatten.jl b/src/flatten.jl index 82d5b60..ce68646 100644 --- a/src/flatten.jl +++ b/src/flatten.jl @@ -19,6 +19,12 @@ function flatten end flatten(x) = flatten(Float64, x) +function ParameterHandling.flatten(::Type{T}, ::Nothing) where {T<:Real} + v = T[] + unflatten_to_Nothing(::Vector{T}) = nothing + return v, unflatten_to_Nothing +end + function flatten(::Type{T}, x::Integer) where {T<:Real} v = T[] unflatten_to_Integer(v::Vector{T}) = x