Skip to content

Commit 2fdca11

Browse files
committed
fix expand for expressions with array indexing
1 parent 686f765 commit 2fdca11

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/polyform.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ function PolyForm(x,
160160
recurse=false,
161161
metadata=metadata(x))
162162

163+
if !(symtype(x) <: Number)
164+
return x
165+
end
166+
163167
# Polyize and return a PolyForm
164168
p = polyize(x, pvar2sym, sym2term, vtype, pow, Fs, recurse)
165169
PolyForm{symtype(x)}(p, pvar2sym, sym2term, metadata)

test/polyform.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ end
3232
#@test expand(Term{Number}(zero, 0)) == 0
3333
#@test expand(identity(a * b) - b * a) == 0
3434
@test expand(a * b - b * a) == 0
35+
36+
@syms A::Vector{Real}
37+
# test that the following works
38+
expand(Term{Real}(getindex, [A, 3]) - 3)
3539
end
3640

3741
@testset "simplify_fractions with quick-cancel" begin

0 commit comments

Comments
 (0)