@@ -906,45 +906,51 @@ def _load_solution_io(self, sim, data, unitOpId, solution_str, sensIdx=None):
906
906
split_ports_data = sim .root .input ['return' ].get ('split_ports_data' , 1 )
907
907
single_as_multi_port = sim .root .input ['return' ].get ('single_as_multi_port' , 0 )
908
908
909
- nComp = dims .index ('nComp' )
909
+ nComp_idx = dims .index ('nComp' )
910
+ nComp = out .shape [nComp_idx ]
910
911
try :
911
- nPorts = dims .index ('nPorts' )
912
+ nPort_idx = dims .index ('nPort' )
913
+ nPort = out .shape [nPort_idx ]
912
914
except ValueError :
913
- nPorts = None
915
+ nPort_idx = None
916
+ nPort = 1
914
917
915
918
if split_components_data :
916
919
if split_ports_data :
917
- if nPorts is None :
920
+ if nPort == 1 :
918
921
if single_as_multi_port :
919
- for comp in range (out . shape [ nComp ] ):
922
+ for comp in range (nComp ):
920
923
comp_out = numpy .squeeze (out [..., comp ])
921
924
solution [f'{ solution_str } _port_000_comp_{ comp :03d} ' ] = comp_out
922
925
else :
923
- for comp in range (out . shape [ nComp ] ):
926
+ for comp in range (nComp ):
924
927
comp_out = numpy .squeeze (out [..., comp ])
925
928
solution [f'{ solution_str } _comp_{ comp :03d} ' ] = comp_out
926
929
else :
927
- for port in range (out . shape [ nPorts ] ):
928
- for comp in range (out . shape [ nComp ] ):
930
+ for port in range (nPort ):
931
+ for comp in range (nComp ):
929
932
comp_out = numpy .squeeze (out [..., port , comp ])
930
933
solution [f'{ solution_str } _port_{ port :03d} _comp_{ comp :03d} ' ] = comp_out
931
934
else :
932
- for comp in range (out . shape [ nComp ] ):
935
+ for comp in range (nComp ):
933
936
comp_out = numpy .squeeze (out [..., comp ])
934
937
solution [f'{ solution_str } _comp_{ comp :03d} ' ] = comp_out
935
938
else :
936
939
if split_ports_data :
937
- if nPorts is None :
940
+ if nPort == 1 :
938
941
if single_as_multi_port :
939
942
solution [f'{ solution_str } _port_000' ] = out
940
943
else :
941
- solution [solution_str ] = out
944
+ solution [solution_str ] = numpy . squeeze ( out [..., 0 , :])
942
945
else :
943
- for port in range (out . shape [ nPorts ] ):
946
+ for port in range (nPort ):
944
947
port_out = numpy .squeeze (out [..., port , :])
945
948
solution [f'{ solution_str } _port_{ port :03d} ' ] = port_out
946
949
else :
947
- solution [solution_str ] = out
950
+ if nPort == 1 and nPort_idx is not None :
951
+ solution [solution_str ] = numpy .squeeze (out [..., 0 , :])
952
+ else :
953
+ solution [solution_str ] = out
948
954
949
955
return solution
950
956
0 commit comments