Skip to content

bug in _fix_comp_path for internal_param_conns #689

@corakingdon

Description

@corakingdon

There seems to be a bug (on master) in the way that the component paths in subcomponents' internal_param_conns get updated, but the bug only arises after three levels of composites. Here is an example:

using Mimi

@defcomp A begin
    v1 = Variable()
end

@defcomp B begin
    p1 = Parameter()
end

@defcomposite C begin
    Component(A)
    Component(B)
    connect(B.p1, A.v1)   # make an internal connection in comp C
end

@defcomposite D begin
    Component(C)
end

@defcomposite E begin
    Component(D)
end

This displays the correct src_comp_path and dst_comp_path:

julia> C.internal_param_conns
1-element Array{Mimi.InternalParameterConnection,1}:
 Mimi.InternalParameterConnection
  src_comp_path: ComponentPath(:C, :A)
  src_var_name: :v1
  dst_comp_path: ComponentPath(:C, :B)
  dst_par_name: :p1
  ignoreunits: false
  backup: nothing
  offset: 0

This one is also right:

julia> D[:C].internal_param_conns
1-element Array{Mimi.InternalParameterConnection,1}:
 Mimi.InternalParameterConnection
  src_comp_path: ComponentPath(:D, :C, :A)
  src_var_name: :v1
  dst_comp_path: ComponentPath(:D, :C, :B)
  dst_par_name: :p1
  ignoreunits: false
  backup: nothing
  offset: 0

But this one is messed up:


julia> E[:D][:C].internal_param_conns
1-element Array{Mimi.InternalParameterConnection,1}:
 Mimi.InternalParameterConnection
  src_comp_path: ComponentPath(:E, :D, :C, :C, :A)
  src_var_name: :v1
  dst_comp_path: ComponentPath(:E, :D, :C, :C, :B)
  dst_par_name: :p1
  ignoreunits: false
  backup: nothing
  offset: 0

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions