Skip to content

Commit

Permalink
fix: fix handling of arrays of symbolics in linear_expansion
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Jan 22, 2025
1 parent 8841664 commit c042215
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,12 @@ function _occursin_array(sym, arrsym, arr)
if symbolic_type(el) == NotSymbolic()
return el isa AbstractArray && _occursin_array(sym, arrsym, el)
else
return occursin(sym, el) || occursin(arrsym, el)
if sym !== nothing && occursin(sym, el) || arrsym !== nothing && occursin(arrsym, el)
return true
end
end
end
return false
end

###
Expand Down
3 changes: 3 additions & 0 deletions test/linear_solver.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ a, b, islinear = Symbolics.linear_expansion(D(x) - x, x)
@variables x::Vector{Real}
a, b, islin = Symbolics.linear_expansion(x[0] - z(x[1]), z(x[1]))
@test islin && isequal(a, -1) && isequal(b, x[0])

@variables x y
@test !Symbolics.linear_expansion(x + z([x, y]), y)[3]
end

0 comments on commit c042215

Please sign in to comment.