@@ -55,7 +55,7 @@ class SolutionAnalysis(DictMixin):
5555 global_ispta_mWcm2 : float | None = None
5656 param_constraints : Dict [str , ParameterConstraint ] = field (default_factory = dict )
5757
58- def to_table (self , constraints :Dict [str ,ParameterConstraint ]| None = None ) -> pd .DataFrame :
58+ def to_table (self , constraints :Dict [str ,ParameterConstraint ]| None = None , focus_index = None ) -> pd .DataFrame :
5959 records = []
6060 if constraints is None :
6161 constraints = self .param_constraints
@@ -64,28 +64,38 @@ def to_table(self, constraints:Dict[str,ParameterConstraint]|None=None) -> pd.Da
6464 raise ValueError (f"Unknown parameter constraint for '{ p } '. Must be one of: { list (PARAM_FORMATS .keys ())} " )
6565 for param , fmt in PARAM_FORMATS .items ():
6666 if fmt [0 ] is None :
67- pval = self .__dict__ [param ]
67+ value_by_focus = None
68+ agg_value = self .__dict__ [param ]
6869 elif fmt [0 ] == "max" :
69- pval = max (self .__dict__ [param ])
70+ value_by_focus = self .__dict__ [param ]
71+ agg_value = max (value_by_focus )
7072 elif fmt [0 ] == "mean" :
71- pval = np .mean (self .__dict__ [param ])
72- if pval is not None :
73+ value_by_focus = self .__dict__ [param ]
74+ agg_value = np .mean (value_by_focus )
75+ if agg_value is not None :
7376 record = {"id" : param ,
7477 "Param" : fmt [3 ],
7578 "Value" : "" ,
7679 "Units" : fmt [2 ],
7780 "Status" : "" ,
78- "_value" : pval ,
81+ "_value" : agg_value ,
82+ "_value_by_focus" : value_by_focus ,
7983 "_warning" : False ,
8084 "_error" : False }
81- if np .isnan (pval ):
85+ if np .isnan (agg_value ):
8286 record ["Value" ] = "NaN"
8387 else :
84- record ["Value" ] = f"{ pval :{fmt [1 ]}} "
88+ if focus_index is None :
89+ record ["Value" ] = f"{ agg_value :{fmt [1 ]}} "
90+ elif value_by_focus is None :
91+ record ["Value" ] = "N/A"
92+ else :
93+ value = value_by_focus [focus_index ]
94+ record ["Value" ] = f"{ value :{fmt [1 ]}} "
8595 if param in constraints :
86- record ['_warning' ] = constraints [param ].is_warning (pval )
87- record ['_error' ] = constraints [param ].is_error (pval )
88- record ["Status" ] = PARAM_STATUS_SYMBOLS [constraints [param ].get_status (pval )]
96+ record ['_warning' ] = constraints [param ].is_warning (agg_value )
97+ record ['_error' ] = constraints [param ].is_error (agg_value )
98+ record ["Status" ] = PARAM_STATUS_SYMBOLS [constraints [param ].get_status (agg_value )]
8999 records .append (record )
90100 return pd .DataFrame .from_records (records )
91101
0 commit comments