From b7e502e1bb04003f4b55bd3045e252b1f973bd3c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Primo=C5=BE=20Godec?=
Date: Fri, 28 Jun 2019 10:34:03 +0200
Subject: [PATCH 1/2] Fix: Neighbours manual apply
---
Orange/widgets/data/owneighbors.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/Orange/widgets/data/owneighbors.py b/Orange/widgets/data/owneighbors.py
index 07e4aba920d..931d62d319b 100644
--- a/Orange/widgets/data/owneighbors.py
+++ b/Orange/widgets/data/owneighbors.py
@@ -77,11 +77,11 @@ def __init__(self):
callback=self.recompute)
gui.spin(
box, self, "n_neighbors", label="Number of neighbors:",
- step=1, spinType=int, minv=0, maxv=100, callback=self.apply)
+ step=1, spinType=int, minv=0, maxv=100, callback=self.commit)
gui.checkBox(
box, self, "exclude_reference",
label="Exclude rows (equal to) references",
- callback=self.apply)
+ callback=self.commit)
self.apply_button = gui.auto_commit(
self.controlArea, self, "auto_apply", "&Apply", commit=self.apply)
@@ -137,6 +137,9 @@ def compute_distances(self):
pp_reference, pp_data = pp_all_data[:n_ref], pp_all_data[n_ref:]
self.distances = metric(pp_data, pp_reference).min(axis=1)
+ def commit(self):
+ self.apply()
+
def apply(self):
indices = self._compute_indices()
if indices is None:
From 36ec1691c867c851c4de3dd03ccc8f3322aa98ea Mon Sep 17 00:00:00 2001
From: janezd
Date: Mon, 1 Jul 2019 18:53:35 +0200
Subject: [PATCH 2/2] OWNeighbours: Replace 'commit' with lambda
---
Orange/widgets/data/owneighbors.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Orange/widgets/data/owneighbors.py b/Orange/widgets/data/owneighbors.py
index 931d62d319b..7194deac51e 100644
--- a/Orange/widgets/data/owneighbors.py
+++ b/Orange/widgets/data/owneighbors.py
@@ -77,11 +77,14 @@ def __init__(self):
callback=self.recompute)
gui.spin(
box, self, "n_neighbors", label="Number of neighbors:",
- step=1, spinType=int, minv=0, maxv=100, callback=self.commit)
+ step=1, spinType=int, minv=0, maxv=100,
+ # call apply by gui.auto_commit, pylint: disable=unnecessary-lambda
+ callback=lambda: self.apply())
gui.checkBox(
box, self, "exclude_reference",
label="Exclude rows (equal to) references",
- callback=self.commit)
+ # call apply by gui.auto_commit, pylint: disable=unnecessary-lambda
+ callback=lambda: self.apply())
self.apply_button = gui.auto_commit(
self.controlArea, self, "auto_apply", "&Apply", commit=self.apply)
@@ -137,9 +140,6 @@ def compute_distances(self):
pp_reference, pp_data = pp_all_data[:n_ref], pp_all_data[n_ref:]
self.distances = metric(pp_data, pp_reference).min(axis=1)
- def commit(self):
- self.apply()
-
def apply(self):
indices = self._compute_indices()
if indices is None: