File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
Orange/widgets/unsupervised Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,8 @@ class Outputs:
6868 class Error (widget .OWWidget .Error ):
6969 not_enough_instances = Msg ("Not enough unique data instances. "
7070 "At least two are required." )
71+ no_features = Msg ("The data does not contain any features." )
72+
7173
7274 METRICS = [
7375 ("Euclidean" , "euclidean" ),
@@ -175,15 +177,15 @@ def set_data(self, data):
175177 self .Error .clear ()
176178 if not self .check_data_size (data ):
177179 data = None
180+ if data and data .X .shape [1 ] == 0 :
181+ data = None
182+ self .Error .no_features ()
178183 self .data = self .data_normalized = data
179184 if self .data is None :
180185 self .Outputs .annotated_data .send (None )
181186 self .plot .clear_plot ()
182187 return
183188
184- if self .data is None :
185- return
186-
187189 self ._preprocess_data ()
188190
189191 self ._compute_and_plot ()
Original file line number Diff line number Diff line change 44import numpy as np
55from scipy .sparse import csr_matrix , csc_matrix
66
7- from Orange .data import Table
7+ from Orange .data import Table , Domain
88from Orange .clustering import DBSCAN
99from Orange .preprocess import Normalize , Continuize , SklImpute
1010from Orange .widgets .tests .base import WidgetTest
@@ -56,6 +56,16 @@ def test_bad_input(self):
5656 self .send_signal (w .Inputs .data , self .iris )
5757 self .assertFalse (w .Error .not_enough_instances .is_shown ())
5858
59+ new_domain = Domain ([], self .iris .domain .class_vars ,
60+ metas = self .iris .domain .attributes )
61+ iris_all_metas = self .iris .transform (new_domain )
62+ self .send_signal (w .Inputs .data , iris_all_metas )
63+ self .assertTrue (w .Error .no_features .is_shown ())
64+
65+ self .send_signal (w .Inputs .data , self .iris )
66+ self .assertFalse (w .Error .no_features .is_shown ())
67+
68+
5969 def test_data_none (self ):
6070 w = self .widget
6171
You can’t perform that action at this time.
0 commit comments