Skip to content

Commit

Permalink
Do all checks at start of NonlinearSystem()
Browse files Browse the repository at this point in the history
  • Loading branch information
hersle committed Oct 3, 2024
1 parent e9a06c5 commit 7936f98
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/systems/nonlinear/nonlinearsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,18 @@ function NonlinearSystem(eqs, unknowns, ps;
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"))
length(unique(nameof.(systems))) == length(systems) ||
throw(ArgumentError("System names must be unique."))
(isempty(default_u0) && isempty(default_p)) ||
Base.depwarn(
"`default_u0` and `default_p` are deprecated. Use `defaults` instead.",
:NonlinearSystem, force = true)

# 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(
"`default_u0` and `default_p` are deprecated. Use `defaults` instead.",
:NonlinearSystem, force = true)
end
sysnames = nameof.(systems)
if length(unique(sysnames)) != length(sysnames)
throw(ArgumentError("System names must be unique."))
end
jac = RefValue{Any}(EMPTY_JAC)
defaults = todict(defaults)
defaults = Dict{Any, Any}(value(k) => value(v)
Expand Down

0 comments on commit 7936f98

Please sign in to comment.