Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Explorer: Add exact match by label #265

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions orangecontrib/network/widgets/OWNxExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def _mark_by_labels(marker):
return None
return marker(np.char.array(labels), txt)

def mark_label_equals():
return _mark_by_labels(
lambda labels, txt: np.flatnonzero(labels.lower() == txt))

def mark_label_starts():
return _mark_by_labels(
lambda labels, txt: np.flatnonzero(labels.lower().startswith(txt)))
Expand Down Expand Up @@ -268,6 +272,7 @@ def mark_more_than_average_neighbour():

self.mark_criteria = [
("(Select criteria for marking)", None, lambda: np.zeros((0,))),
("Mark node labelled as", text_line(), mark_label_equals),
("Mark nodes whose label starts with", text_line(), mark_label_starts),
("Mark nodes whose label contains", text_line(), mark_label_contains),
("Mark nodes whose data that contains", text_line(), mark_text),
Expand Down
4 changes: 2 additions & 2 deletions orangecontrib/network/widgets/tests/test_OWNxExplorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ def test_edge_weights(self):

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

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

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

def test_input_subset(self):
Expand Down