Skip to content

Commit bc517bf

Browse files
refactor: unwrap AnalysisPoint inside consts where necessary
1 parent 240119d commit bc517bf

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/systems/abstractsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ function getvar(sys::AbstractSystem, name::Symbol; namespace = does_namespacing(
980980
eq isa Equation || continue
981981
lhs = value(eq.lhs)
982982
rhs = value(eq.rhs)
983-
if lhs isa AnalysisPoint
983+
if value(lhs) isa AnalysisPoint
984984
rhs = rhs::AnalysisPoint
985985
nameof(rhs) == name || continue
986986
return namespace ? renamespace(sys, rhs) : rhs

src/systems/analysis_points.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ Search for the analysis point with the given `name` in `get_eqs(sys)`.
428428
function analysis_point_index(sys::AbstractSystem, name::Symbol)
429429
name = namespace_hierarchy(name)[end]
430430
findfirst(get_eqs(sys)) do eq
431-
eq.lhs isa AnalysisPoint && nameof(eq.rhs) == name
431+
value(eq.lhs) isa AnalysisPoint && nameof(value(eq.rhs)::AnalysisPoint) == name
432432
end
433433
end
434434

@@ -540,7 +540,7 @@ function apply_transformation(tf::Break, sys::AbstractSystem)
540540
breaksys_eqs = copy(get_eqs(breaksys))
541541
@set! breaksys.eqs = breaksys_eqs
542542

543-
ap = breaksys_eqs[ap_idx].rhs
543+
ap = value(breaksys_eqs[ap_idx].rhs)::AnalysisPoint
544544
deleteat!(breaksys_eqs, ap_idx)
545545

546546
breaksys = with_analysis_point_ignored(breaksys, ap)
@@ -598,7 +598,7 @@ function apply_transformation(tf::GetInput, sys::AbstractSystem)
598598
error("Analysis point $(nameof(tf.ap)) not found in system $(nameof(sys)).")
599599
# get the analysis point
600600
ap_sys_eqs = get_eqs(ap_sys)
601-
ap = ap_sys_eqs[ap_idx].rhs
601+
ap = value(ap_sys_eqs[ap_idx].rhs)::AnalysisPoint
602602

603603
# input variable
604604
ap_ivar = ap_var(ap.input)
@@ -653,7 +653,7 @@ function apply_transformation(tf::PerturbOutput, sys::AbstractSystem)
653653
# modified equations
654654
ap_sys_eqs = copy(get_eqs(ap_sys))
655655
@set! ap_sys.eqs = ap_sys_eqs
656-
ap = ap_sys_eqs[ap_idx].rhs
656+
ap = value(ap_sys_eqs[ap_idx].rhs)::AnalysisPoint
657657
# remove analysis point
658658
deleteat!(ap_sys_eqs, ap_idx)
659659
ap_sys = with_analysis_point_ignored(ap_sys, ap)
@@ -723,7 +723,7 @@ function apply_transformation(tf::AddVariable, sys::AbstractSystem)
723723
ap_idx === nothing &&
724724
error("Analysis point $(nameof(tf.ap)) not found in system $(nameof(sys)).")
725725
ap_sys_eqs = get_eqs(ap_sys)
726-
ap = ap_sys_eqs[ap_idx].rhs
726+
ap = value(ap_sys_eqs[ap_idx].rhs)::AnalysisPoint
727727

728728
# add equations involving new variable
729729
ap_ivar = ap_var(ap.input)

0 commit comments

Comments
 (0)