Skip to content

Commit 7936f98

Browse files
committed
Do all checks at start of NonlinearSystem()
1 parent e9a06c5 commit 7936f98

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/systems/nonlinear/nonlinearsystem.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,21 +128,18 @@ function NonlinearSystem(eqs, unknowns, ps;
128128
throw(ArgumentError("NonlinearSystem does not accept `discrete_events`, you provided $discrete_events"))
129129
name === nothing &&
130130
throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro"))
131+
length(unique(nameof.(systems))) == length(systems) ||
132+
throw(ArgumentError("System names must be unique."))
133+
(isempty(default_u0) && isempty(default_p)) ||
134+
Base.depwarn(
135+
"`default_u0` and `default_p` are deprecated. Use `defaults` instead.",
136+
:NonlinearSystem, force = true)
131137

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

137-
if !(isempty(default_u0) && isempty(default_p))
138-
Base.depwarn(
139-
"`default_u0` and `default_p` are deprecated. Use `defaults` instead.",
140-
:NonlinearSystem, force = true)
141-
end
142-
sysnames = nameof.(systems)
143-
if length(unique(sysnames)) != length(sysnames)
144-
throw(ArgumentError("System names must be unique."))
145-
end
146143
jac = RefValue{Any}(EMPTY_JAC)
147144
defaults = todict(defaults)
148145
defaults = Dict{Any, Any}(value(k) => value(v)

0 commit comments

Comments
 (0)