2222 DomainContextHandler , ContextSetting , Setting
2323from Orange .widgets .utils .itemmodels import DomainModel
2424from Orange .widgets .utils .widgetpreview import WidgetPreview
25+ from Orange .widgets .utils .state_summary import format_summary_details
2526from Orange .widgets .utils .annotated_data import \
2627 create_annotated_table , create_groups_table , ANNOTATED_DATA_SIGNAL_NAME
2728from Orange .widgets .utils .colorpalettes import \
@@ -229,6 +230,9 @@ def __init__(self):
229230 self .selection = None
230231 self .colors = self .thresholds = self .bin_labels = None
231232
233+ self ._set_input_summary (None )
234+ self ._set_output_summary (None )
235+
232236 box = gui .vBox (self .controlArea , box = "SOM" )
233237 shape = gui .comboBox (
234238 box , self , "" , items = ("Hexagonal grid" , "Square grid" ))
@@ -353,25 +357,18 @@ def set_warnings():
353357 self .set_color_bins ()
354358 self .create_legend ()
355359 self .recompute_dimensions ()
356- self ._set_input_summary (data and len ( data ) )
360+ self ._set_input_summary (data )
357361 self .start_som ()
358362
359- def _set_input_summary (self , n_tot ):
360- if self .data is None :
361- self .info .set_input_summary (self .info .NoInput )
362- return
363-
364- n = len (self .data )
365- inst = str (n )
366- nvars = f"{ self .cont_x .shape [1 ]} numeric variables"
367- if n < n_tot :
368- inst += f" ({ n_tot } )"
369- details = f"{ n_tot - n } out of { n_tot } instances ignored " \
370- f"because of missing values;\n { nvars } "
371- else :
372- details = f"{ n } instances; { nvars } "
363+ def _set_input_summary (self , data ):
364+ summary = len (data ) if data else self .info .NoInput
365+ details = format_summary_details (data ) if data else ""
366+ self .info .set_input_summary (summary , details )
373367
374- self .info .set_input_summary (inst , details )
368+ def _set_output_summary (self , output ):
369+ summary = len (output ) if output else self .info .NoOutput
370+ details = format_summary_details (output ) if output else ""
371+ self .info .set_output_summary (summary , details )
375372
376373 def clear (self ):
377374 self .data = self .cont_x = None
@@ -807,7 +804,7 @@ def update_output(self):
807804 if self .data is None :
808805 self .Outputs .selected_data .send (None )
809806 self .Outputs .annotated_data .send (None )
810- self .info . set_output_summary ( self . info . NoOutput )
807+ self ._set_output_summary ( None )
811808 return
812809
813810 indices = np .zeros (len (self .data ), dtype = int )
@@ -820,10 +817,10 @@ def update_output(self):
820817 if np .any (indices ):
821818 sel_data = create_groups_table (self .data , indices , False , "Group" )
822819 self .Outputs .selected_data .send (sel_data )
823- self .info . set_output_summary ( str ( len ( sel_data )) )
820+ self ._set_output_summary ( sel_data )
824821 else :
825822 self .Outputs .selected_data .send (None )
826- self .info . set_output_summary ( self . info . NoOutput )
823+ self ._set_output_summary ( None )
827824
828825 if np .max (indices ) > 1 :
829826 annotated = create_groups_table (self .data , indices )
0 commit comments