Skip to content

Commit

Permalink
NonlinearSystem: put single equation input in vector, instead of scal…
Browse files Browse the repository at this point in the history
…arizing
  • Loading branch information
hersle committed Oct 3, 2024
1 parent b669cc9 commit 5cf19a9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/systems/nonlinear/nonlinearsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,13 @@ function NonlinearSystem(eqs, unknowns, ps;
throw(ArgumentError("NonlinearSystem does not accept `continuous_events`, you provided $continuous_events"))
discrete_events === nothing || isempty(discrete_events) ||
throw(ArgumentError("NonlinearSystem does not accept `discrete_events`, you provided $discrete_events"))

name === nothing &&
throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro"))
# Move things over, but do not touch array expressions
#
# # we cannot scalarize in the loop because `eqs` itself might require
# scalarization
eqs = [x.lhs isa Union{Symbolic, Number} ? 0 ~ x.rhs - x.lhs : x
for x in scalarize(eqs)]

# Accept a single (scalar/vector) equation, but make array for consistent internal handling
if !(eqs isa AbstractArray)
eqs = [eqs]
end

if !(isempty(default_u0) && isempty(default_p))
Base.depwarn(
Expand Down

0 comments on commit 5cf19a9

Please sign in to comment.