Skip to content

Commit

Permalink
Preserve metadata when scalarizing getindex
Browse files Browse the repository at this point in the history
  • Loading branch information
contradict committed Nov 12, 2023
1 parent fb92fd1 commit c056057
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,12 @@ function scalarize(arr)
end
elseif istree(arr) && operation(arr) == getindex
args = arguments(arr)
scalarize(args[1], (args[2:end]...,))
scalarized = scalarize(args[1], (args[2:end]...,))
if isnothing(metadata(arr))
scalarized
else
metadata(scalarized, metadata(arr))
end
elseif arr isa Num
wrap(scalarize(unwrap(arr)))
elseif istree(arr) && symtype(arr) <: Number
Expand Down

0 comments on commit c056057

Please sign in to comment.