@@ -1019,12 +1019,7 @@ function Base.getproperty(
1019
1019
end
1020
1020
function getvar (sys:: AbstractSystem , name:: Symbol ; namespace = does_namespacing (sys))
1021
1021
systems = get_systems (sys)
1022
- if isdefined (sys, name)
1023
- Base. depwarn (
1024
- " `sys.name` like `sys.$name ` is deprecated. Use getters like `get_$name ` instead." ,
1025
- " sys.$name " )
1026
- return getfield (sys, name)
1027
- elseif ! isempty (systems)
1022
+ if ! isempty (systems)
1028
1023
i = findfirst (x -> nameof (x) == name, systems)
1029
1024
if i != = nothing
1030
1025
return namespace ? renamespace (sys, systems[i]) : systems[i]
@@ -1079,19 +1074,14 @@ function getvar(sys::AbstractSystem, name::Symbol; namespace = does_namespacing(
1079
1074
end
1080
1075
1081
1076
function Base. setproperty! (sys:: AbstractSystem , prop:: Symbol , val)
1082
- # We use this weird syntax because `parameters` and `unknowns` calls are
1083
- # potentially expensive.
1084
- if (params = parameters (sys);
1085
- idx = findfirst (s -> getname (s) == prop, params);
1086
- idx != = nothing )
1087
- get_defaults (sys)[params[idx]] = value (val)
1088
- elseif (sts = unknowns (sys);
1089
- idx = findfirst (s -> getname (s) == prop, sts);
1090
- idx != = nothing )
1091
- get_defaults (sys)[sts[idx]] = value (val)
1092
- else
1093
- setfield! (sys, prop, val)
1094
- end
1077
+ error ("""
1078
+ `setproperty!` on systems is invalid. Systems are immutable data structures, and \
1079
+ modifications to fields should be made by constructing a new system. This can be done \
1080
+ easily using packages such as Setfield.jl.
1081
+
1082
+ If you are looking for the old behavior of updating the default of a variable via \
1083
+ `setproperty!`, this should now be done by mutating `ModelingToolkit.get_defaults(sys)`.
1084
+ """ )
1095
1085
end
1096
1086
1097
1087
apply_to_variables (f:: F , ex) where {F} = _apply_to_variables (f, ex)
0 commit comments