Skip to content

Commit 47fd174

Browse files
feat: improve maketerm for ArrayOp
1 parent 113a5a5 commit 47fd174

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/arrays.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,14 @@ end
6363
ConstructionBase.constructorof(s::Type{<:ArrayOp{T}}) where {T} = ArrayOp{T}
6464

6565
function SymbolicUtils.maketerm(::Type{<:ArrayOp}, f, args, m)
66+
args = map(args) do arg
67+
if iscall(arg) && operation(arg) == Ref && symbolic_type(only(arguments(arg))) == NotSymbolic()
68+
return Ref(only(arguments(arg)))
69+
else
70+
return arg
71+
end
72+
end
73+
6674
t = f(args...)
6775
t isa Symbolic && !isnothing(m) ?
6876
metadata(t, m) : t

test/arrays.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ end
8282
@test isequal(T, Symbolics.maketerm(typeof(T), operation(T), arguments(T), nothing))
8383
T2 = unwrap(3B)
8484
@test isequal(T2, Symbolics.maketerm(typeof(T), operation(T), [*, 3, unwrap(B)], nothing))
85+
T3 = unwrap(A .^ 2)
86+
@test isequal(T3, Symbolics.maketerm(typeof(T3), operation(T3), arguments(T3), nothing))
8587
end
8688

8789
getdef(v) = getmetadata(v, Symbolics.VariableDefaultValue)

0 commit comments

Comments
 (0)