Skip to content

Commit

Permalink
PyLint
Browse files Browse the repository at this point in the history
  • Loading branch information
nikicc committed Nov 10, 2017
1 parent 7705afb commit 1d9c77a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Orange/preprocess/discretize.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion Orange/preprocess/impute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 5 additions & 4 deletions Orange/tests/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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]))
Expand Down
1 change: 1 addition & 0 deletions Orange/tests/test_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from Orange.preprocess import Remove
from Orange.tests import test_filename


class TestRemover(unittest.TestCase):

@classmethod
Expand Down
14 changes: 7 additions & 7 deletions Orange/tests/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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.)

Expand All @@ -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
Expand All @@ -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))])
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion Orange/widgets/visualize/tests/test_owscatterplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 1d9c77a

Please sign in to comment.