Skip to content

Commit

Permalink
restore arrays with nothing elements
Browse files Browse the repository at this point in the history
  • Loading branch information
lxvm committed Jan 17, 2024
1 parent 3087003 commit 2bf7633
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2bf7633

Please sign in to comment.