Skip to content

Commit 4047242

Browse files
authored
Merge pull request #265 from janezd/nxexplorer-exact-match
Network Explorer: Add exact match by label
2 parents b16e48a + 33d7402 commit 4047242

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

orangecontrib/network/widgets/OWNxExplorer.py

+5
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,10 @@ def _mark_by_labels(marker):
354354
return None
355355
return marker(np.char.array(labels), txt)
356356

357+
def mark_label_equals():
358+
return _mark_by_labels(
359+
lambda labels, txt: np.flatnonzero(labels.lower() == txt))
360+
357361
def mark_label_starts():
358362
return _mark_by_labels(
359363
lambda labels, txt: np.flatnonzero(labels.lower().startswith(txt)))
@@ -426,6 +430,7 @@ def mark_more_than_average_neighbour():
426430

427431
self.mark_criteria = [
428432
("(Select criteria for marking)", None, lambda: np.zeros((0,))),
433+
("Mark node labelled as", text_line(), mark_label_equals),
429434
("Mark nodes whose label starts with", text_line(), mark_label_starts),
430435
("Mark nodes whose label contains", text_line(), mark_label_contains),
431436
("Mark nodes whose data that contains", text_line(), mark_text),

orangecontrib/network/widgets/tests/test_OWNxExplorer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ def test_edge_weights(self):
8686

8787
# Mark nodes with many connections (multiple): should show the weights for edges between marked nodes only
8888
self.widget.mark_min_conn = 8
89-
self.widget.set_mark_mode(8)
89+
self.widget.set_mark_mode(9)
9090
self.assertEqual(len(self.widget.graph.edge_labels), 12)
9191

9292
# Reset to default (no selection) and check that the labels disappear
9393
self.widget.set_mark_mode(0)
9494
self.assertEqual(len(self.widget.graph.edge_labels), 0)
9595

9696
# Mark nodes with most connections (single): should show all its edges' weights
97-
self.widget.set_mark_mode(9)
97+
self.widget.set_mark_mode(10)
9898
self.assertEqual(len(self.widget.graph.edge_labels), 14)
9999

100100
def test_input_subset(self):

0 commit comments

Comments
 (0)