Skip to content

Commit 19d970c

Browse files
refactor: require complete system in dependent_parameters, parameter_dependencies
1 parent 8b5270b commit 19d970c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/systems/abstractsystem.jl

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1274,6 +1274,12 @@ function parameters(sys::AbstractSystem; initial_parameters = false)
12741274
end
12751275

12761276
function dependent_parameters(sys::AbstractSystem)
1277+
if !iscomplete(sys)
1278+
throw(ArgumentError("""
1279+
`dependent_parameters` requires that the system is marked as complete. Call
1280+
`complete` or `mtkcompile` on the system.
1281+
"""))
1282+
end
12771283
return map(eq -> eq.lhs, parameter_dependencies(sys))
12781284
end
12791285

@@ -1290,23 +1296,22 @@ function parameters_toplevel(sys::AbstractSystem)
12901296
end
12911297

12921298
"""
1293-
$(TYPEDSIGNATURES)
1294-
Get the parameter dependencies of the system `sys` and its subsystems.
1299+
$(TYPEDSIGNATURES)
12951300
1296-
See also [`defaults`](@ref) and [`ModelingToolkit.get_parameter_dependencies`](@ref).
1301+
Get the parameter dependencies of the system `sys` and its subsystems. Requires that the
1302+
system is `complete`d.
12971303
"""
12981304
function parameter_dependencies(sys::AbstractSystem)
1305+
if !iscomplete(sys)
1306+
throw(ArgumentError("""
1307+
`parameter_dependencies` requires that the system is marked as complete. Call \
1308+
`complete` or `mtkcompile` on the system.
1309+
"""))
1310+
end
12991311
if !has_parameter_dependencies(sys)
13001312
return Equation[]
13011313
end
1302-
pdeps = get_parameter_dependencies(sys)
1303-
systems = get_systems(sys)
1304-
# put pdeps after those of subsystems to maintain topological sorted order
1305-
namespaced_deps = mapreduce(
1306-
s -> map(eq -> namespace_equation(eq, s), parameter_dependencies(s)), vcat,
1307-
systems; init = Equation[])
1308-
1309-
return vcat(namespaced_deps, pdeps)
1314+
get_parameter_dependencies(sys)
13101315
end
13111316

13121317
function full_parameters(sys::AbstractSystem)

0 commit comments

Comments
 (0)