Skip to content

Commit 567b070

Browse files
authored
Merge pull request #65 from JuliaGaussianProcesses/nothing-flatten
Add support for `nothing`
2 parents 1fdb2cb + cbc5565 commit 567b070

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ParameterHandling"
22
uuid = "2412ca09-6db7-441c-8e3a-88d5709968c5"
33
authors = ["Invenia Technical Computing Corporation"]
4-
version = "0.4.7"
4+
version = "0.4.8"
55

66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/flatten.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ function flatten end
1919

2020
flatten(x) = flatten(Float64, x)
2121

22+
function flatten(::Type{T}, ::Nothing) where {T<:Real}
23+
v = T[]
24+
unflatten_to_Nothing(::Vector{T}) = nothing
25+
return v, unflatten_to_Nothing
26+
end
27+
2228
function flatten(::Type{T}, x::Integer) where {T<:Real}
2329
v = T[]
24-
unflatten_to_Integer(v::Vector{T}) = x
30+
unflatten_to_Integer(::Vector{T}) = x
2531
return v, unflatten_to_Integer
2632
end
2733

test/flatten.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
end
99
end
1010

11+
@testset "Nothing" begin
12+
test_flatten_interface(nothing)
13+
@test isempty(first(flatten(nothing)))
14+
end
15+
1116
@testset "AbstractArrays" begin
1217
test_flatten_interface(randn(10))
1318
test_flatten_interface(randn(5, 4))

0 commit comments

Comments
 (0)