From 2bf76338dfff5e8c6e09fbe68182ef961c814819 Mon Sep 17 00:00:00 2001 From: lxvm Date: Wed, 17 Jan 2024 14:04:57 -0500 Subject: [PATCH] restore arrays with nothing elements --- src/lib/array.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/array.jl b/src/lib/array.jl index 695039f3e..b152d06d6 100644 --- a/src/lib/array.jl +++ b/src/lib/array.jl @@ -171,6 +171,7 @@ _reverse(x::Symmetric) = Symmetric(_reverse(x.data), x.uplo == 'U' ? :L : :U) _tryaxes(x) = axes(x) _tryaxes(x::Tuple) = Val(length(x)) _tryaxes(::Number) = Val(-1) +_restore(dx::AbstractArray{Nothing}, ax::Tuple) = similar(dx, ax) _restore(dx, ax::Tuple) = axes(dx) == ax ? dx : reshape(vcat(dx, falses(prod(map(length, ax)) - length(dx))), ax) _restore(dx, ::Val{N}) where {N} = ntuple(i -> get(dx,i,nothing), N) _restore(dx, ::Val{-1}) = only(dx)