1010from Orange .widgets import widget , gui
1111from Orange .widgets .utils .slidergraph import SliderGraph
1212from Orange .widgets .settings import Setting
13- from Orange .data import Table , Domain , DiscreteVariable
13+ from Orange .data import Table , DiscreteVariable
1414from Orange .data .util import get_unique_names
1515from Orange .clustering import DBSCAN
1616from Orange .widgets .utils .annotated_data import ANNOTATED_DATA_SIGNAL_NAME
@@ -197,11 +197,10 @@ def send_data(self):
197197
198198 clusters = [c if c >= 0 else np .nan for c in model .labels ]
199199 k = len (set (clusters ) - {np .nan })
200- clusters = np .array (clusters ). reshape ( len ( self . data ), 1 )
200+ clusters = np .array (clusters )
201201 core_samples = set (model .projector .core_sample_indices_ )
202202 in_core = np .array ([1 if (i in core_samples ) else 0
203203 for i in range (len (self .data ))])
204- in_core = in_core .reshape (len (self .data ), 1 )
205204
206205 domain = self .data .domain
207206 attributes , classes = domain .attributes , domain .class_vars
@@ -215,15 +214,8 @@ def send_data(self):
215214 u_in_core = get_unique_names (names + [u_clust_var ], "DBSCAN Core" )
216215 in_core_var = DiscreteVariable (u_in_core , values = ("0" , "1" ))
217216
218- x , y , metas = self .data .X , self .data .Y , self .data .metas
219-
220- meta_attrs += (clust_var , )
221- metas = np .hstack ((metas , clusters ))
222- meta_attrs += (in_core_var , )
223- metas = np .hstack ((metas , in_core ))
224-
225- domain = Domain (attributes , classes , meta_attrs )
226- new_table = Table (domain , x , y , metas , self .data .W )
217+ new_table = self .data .add_column (clust_var , clusters , to_metas = True )
218+ new_table = new_table .add_column (in_core_var , in_core , to_metas = True )
227219
228220 self ._set_output_summary (new_table )
229221 self .Outputs .annotated_data .send (new_table )
0 commit comments