File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed
Orange/widgets/unsupervised Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -187,6 +187,8 @@ class Warning(OWWidget.Warning):
187187 ignoring_disc_variables = Msg ("SOM ignores discrete variables." )
188188 missing_colors = \
189189 Msg ("Some data instances have undefined value of '{}'." )
190+ missing_values = \
191+ Msg ("{} data instance{} with undefined value(s) {} not shown." )
190192
191193 class Error (OWWidget .Error ):
192194 no_numeric_variables = Msg ("Data contains no numeric columns." )
@@ -311,6 +313,12 @@ def set_data(self, data):
311313 self .controls .attr_color .model ().set_domain (data .domain )
312314 self .attr_color = data .domain .class_var
313315
316+ missing = len (data ) - len (self .data )
317+ if missing == 1 :
318+ self .Warning .missing_values (1 , "" , "is" )
319+ elif missing > 1 :
320+ self .Warning .missing_values (missing , "s" , "are" )
321+
314322 self .openContext (self .data )
315323 self .set_color_bins ()
316324 self .create_legend ()
Original file line number Diff line number Diff line change @@ -89,10 +89,25 @@ def test_missing_some_data(self):
8989
9090 self .send_signal (widget .Inputs .data , self .iris )
9191 self .assertFalse (widget .Error .no_defined_rows .is_shown ())
92+ self .assertTrue (widget .Warning .missing_values .is_shown ())
9293 np .testing .assert_almost_equal (
9394 widget .data .Y .flatten (), [1 ] * 50 + [2 ] * 50 )
9495 self .assertEqual (widget .cont_x .shape , (100 , 4 ))
9596
97+ self .send_signal (widget .Inputs .data , None )
98+ self .assertFalse (widget .Warning .missing_values .is_shown ())
99+
100+ def test_missing_one_row_data (self ):
101+ widget = self .widget
102+ self .iris .X [5 , 0 ] = np .nan
103+
104+ self .send_signal (widget .Inputs .data , self .iris )
105+ self .assertFalse (widget .Error .no_defined_rows .is_shown ())
106+ self .assertTrue (widget .Warning .missing_values .is_shown ())
107+
108+ self .send_signal (widget .Inputs .data , None )
109+ self .assertFalse (widget .Warning .missing_values .is_shown ())
110+
96111 def test_sparse_data (self ):
97112 widget = self .widget
98113 self .iris .X = sp .csc_matrix (self .iris .X )
You can’t perform that action at this time.
0 commit comments