diff --git a/Orange/preprocess/discretize.py b/Orange/preprocess/discretize.py index 0878ba11f7e..30e827c3e73 100644 --- a/Orange/preprocess/discretize.py +++ b/Orange/preprocess/discretize.py @@ -1,7 +1,7 @@ import numpy as np import scipy.sparse as sp -from Orange.data import DiscreteVariable, Domain, Table +from Orange.data import DiscreteVariable, Domain from Orange.data.sql.table import SqlTable from Orange.preprocess.util import _RefuseDataInConstructor from Orange.statistics import distribution, contingency diff --git a/Orange/preprocess/impute.py b/Orange/preprocess/impute.py index a37568e02ea..68f968891a2 100644 --- a/Orange/preprocess/impute.py +++ b/Orange/preprocess/impute.py @@ -157,7 +157,7 @@ def __call__(self, data): column = np.array([float(data[self.variable])]) else: column = np.array(data.get_column_view(self.variable)[0], - copy=True) + copy=True) mask = np.isnan(column) if not np.any(mask): diff --git a/Orange/tests/test_domain.py b/Orange/tests/test_domain.py index 1207b54a894..9deef63176c 100644 --- a/Orange/tests/test_domain.py +++ b/Orange/tests/test_domain.py @@ -11,7 +11,7 @@ from numpy.testing import assert_array_equal from Orange.data import ( - ContinuousVariable, DiscreteVariable, StringVariable, TimeVariable, + ContinuousVariable, DiscreteVariable, StringVariable, TimeVariable, Variable, Domain, Table, DomainConversion) from Orange.data.domain import filter_visible from Orange.preprocess import Continuize, Impute @@ -165,7 +165,8 @@ def test_from_numpy_values(self): (0, 2, DiscreteVariable), (18, 23, ContinuousVariable)]: n_rows, n_cols, = aran_max - aran_min, 1 - d = Domain.from_numpy(np.zeros((1, 1)), np.arange(aran_min, aran_max).reshape(n_rows, n_cols)) + d = Domain.from_numpy(np.zeros((1, 1)), + np.arange(aran_min, aran_max).reshape(n_rows, n_cols)) self.assertTrue(d.anonymous) self.assertIsInstance(d.class_var, vartype) if isinstance(vartype, DiscreteVariable): @@ -402,14 +403,14 @@ def test_conversion(self): assert_array_equal(y, np.array([0])) metas_exp = [gender.Unknown, education.Unknown, ssn.Unknown] - def eq(a, b): + def equal(a, b): if isinstance(a, Real) and isinstance(b, Real) and \ np.isnan(a) and np.isnan(b): return True else: return a == b - self.assertTrue(all(starmap(eq, zip(metas, metas_exp)))) + self.assertTrue(all(starmap(equal, zip(metas, metas_exp)))) x, y, metas = domain.convert([42, 13, "White", "M", "HS", "1234567"]) assert_array_equal(x, np.array([42, 13])) diff --git a/Orange/tests/test_remove.py b/Orange/tests/test_remove.py index 29dab16932e..3b70931062a 100644 --- a/Orange/tests/test_remove.py +++ b/Orange/tests/test_remove.py @@ -9,6 +9,7 @@ from Orange.preprocess import Remove from Orange.tests import test_filename + class TestRemover(unittest.TestCase): @classmethod diff --git a/Orange/tests/test_table.py b/Orange/tests/test_table.py index 6b33ca89822..aca641b1d67 100644 --- a/Orange/tests/test_table.py +++ b/Orange/tests/test_table.py @@ -1777,7 +1777,7 @@ def test_can_filter_row_with_slice(self): new_table, self.table, rows=slice_) def test_can_use_attributes_as_new_columns(self): - a, c, m = column_sizes(self.table) + a, _, _ = column_sizes(self.table) order = [random.randrange(a) for _ in self.domain.attributes] new_attributes = [self.domain.attributes[i] for i in order] new_domain = self.create_domain( @@ -1788,7 +1788,7 @@ def test_can_use_attributes_as_new_columns(self): new_table, self.table, xcols=order, ycols=order, mcols=order) def test_can_use_class_vars_as_new_columns(self): - a, c, m = column_sizes(self.table) + a, c, _ = column_sizes(self.table) order = [random.randrange(a, a + c) for _ in self.domain.class_vars] new_classes = [self.domain.class_vars[i - a] for i in order] new_domain = self.create_domain(new_classes, new_classes, new_classes) @@ -1798,7 +1798,7 @@ def test_can_use_class_vars_as_new_columns(self): new_table, self.table, xcols=order, ycols=order, mcols=order) def test_can_use_metas_as_new_columns(self): - a, c, m = column_sizes(self.table) + _, _, m = column_sizes(self.table) order = [random.randrange(-m + 1, 0) for _ in self.domain.metas] new_metas = [self.domain.metas[::-1][i] for i in order] new_domain = self.create_domain(new_metas, new_metas, new_metas) @@ -2049,7 +2049,7 @@ def test_can_assign_values(self): self.assertAlmostEqual(self.table.X[0, 0], 42.) def test_can_assign_values_to_classes(self): - a, c, m = column_sizes(self.table) + a, _, _ = column_sizes(self.table) self.table[0, a] = 42. self.assertAlmostEqual(self.table.Y[0], 42.) @@ -2067,7 +2067,7 @@ def test_can_assign_rows_to_rows(self): self.table.metas[0], self.table.metas[1]) def test_can_assign_lists(self): - a, c, m = column_sizes(self.table) + a, _, _ = column_sizes(self.table) new_example = [float(i) for i in range(len(self.attributes + self.class_vars))] self.table[0] = new_example @@ -2077,7 +2077,7 @@ def test_can_assign_lists(self): self.table.Y[0], np.array(new_example[a:])) def test_can_assign_np_array(self): - a, c, m = column_sizes(self.table) + a, _, _ = column_sizes(self.table) new_example = \ np.array([float(i) for i in range(len(self.attributes + self.class_vars))]) @@ -2199,7 +2199,7 @@ def test_delete_rows(self): def test_clear(self): self.table.clear() self.assertEqual(len(self.table), 0) - for i in self.table: + for _ in self.table: self.fail("Table should not contain any rows.") def test_subclasses(self): diff --git a/Orange/widgets/visualize/tests/test_owscatterplot.py b/Orange/widgets/visualize/tests/test_owscatterplot.py index 3ccb56aacd8..dd129d0f6e4 100644 --- a/Orange/widgets/visualize/tests/test_owscatterplot.py +++ b/Orange/widgets/visualize/tests/test_owscatterplot.py @@ -2,7 +2,6 @@ # pylint: disable=missing-docstring from unittest.mock import MagicMock import numpy as np -import scipy.sparse as sp from AnyQt.QtCore import QRectF, Qt