Commit 82bdaf6c authored by Anze Vavpetic's avatar Anze Vavpetic
Browse files

raise exception if no threshold was selected. return None for attribute distance matrices.

parent 82b95c03
......@@ -401,7 +401,11 @@ def cforange_hierarchical_clustering_finished(postdata, input_dict, output_dict)
matrix = input_dict['dm']
linkage = int(input_dict['linkage'])
widget_pk = postdata['widget_id'][0]
selected_nodes = json.loads(postdata['selected_nodes'][0])
try:
selected_nodes = json.loads(postdata.get('selected_nodes')[0])
except:
raise Exception('Please select a threshold for determining clusters.')
if isinstance(matrix.items, orange.ExampleTable):
root = Clustering.hierarchical_clustering(linkage, matrix)
cluster_ids = set([cluster for _,_,cluster in selected_nodes])
selected_clusters = set([cluster for _,selected,cluster in selected_nodes if selected])
......@@ -433,4 +437,6 @@ def cforange_hierarchical_clustering_finished(postdata, input_dict, output_dict)
example = orange.Example(centroids.domain, ex)
example[clustVar] = clustVar("Cluster %d" % cluster)
centroids.append(example)
else: # Attribute distance
centroids, selected_table, unselected_table = None, None, None
return {'centroids' : centroids, 'selected_examples' : selected_table, 'unselected_examples' : unselected_table}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment