Skip to content

Commit

Permalink
OWFeatureStatistics: pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pavlin-policar committed Nov 8, 2018
1 parent b496cab commit 3370cc8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions Orange/widgets/data/owfeaturestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def set_data(self, data):
self.target_var = None

self.__attributes = self.__filter_attributes(domain.attributes, self.table.X)
self.__class_vars = self.__filter_attributes(domain.class_vars, self.table._Y)
# We disable pylint warning because the `Y` property squeezes vectors,
# while we need a 2d array, which `_Y` provides
self.__class_vars = self.__filter_attributes(domain.class_vars, self.table._Y) # pylint: disable=protected-access
self.__metas = self.__filter_attributes(domain.metas, self.table.metas)

self.n_attributes = len(self.variables)
Expand Down Expand Up @@ -349,7 +351,7 @@ def sortColumnData(self, column):
var_name_indices = np.argsort(self._variable_names)

# Prepare vartype indices so ready when needed
disc_idx, cont_idx, time_idx, str_idx = self._attr_indices(self.variables)
disc_idx, _, time_idx, str_idx = self._attr_indices(self.variables)

# Sort by: (type)
if column == self.Columns.ICON:
Expand Down Expand Up @@ -395,6 +397,8 @@ def sortColumnData(self, column):
elif column == self.Columns.MISSING:
return self._missing

return None

def _sortColumnData(self, column):
"""Allow sorting with 2d arrays."""
data = np.asarray(self.sortColumnData(column))
Expand Down Expand Up @@ -440,7 +444,7 @@ def headerData(self, section, orientation, role):
def data(self, index, role):
# type: (QModelIndex, Qt.ItemDataRole) -> Any
if not index.isValid():
return
return None

row, column = self.mapToSourceRows(index.row()), index.column()
# Make sure we're not out of range
Expand Down Expand Up @@ -660,6 +664,9 @@ def paint(self, painter, option, index):

scene.render(painter, target=QRectF(option.rect), mode=Qt.IgnoreAspectRatio)

# pylint complains about inconsistent return statements
return None


class OWFeatureStatistics(widget.OWWidget):
name = 'Feature Statistics'
Expand Down Expand Up @@ -812,7 +819,11 @@ def _format_variables_string(self, variables):
('time', TimeVariable),
('string', StringVariable)
]:
var_type_list = [v for v in variables if type(v) is var_type]
# Disable pylint here because a `TimeVariable` is also a
# `ContinuousVariable`, and should be labelled as such. That is why
# it is necessary to check the type this way instead of using
# `isinstance`, which would fail in the above case
var_type_list = [v for v in variables if type(v) is var_type] # pylint: disable=unidiomatic-typecheck
if var_type_list:
shown = var_type in self.model.HIDDEN_VAR_TYPES
agg.append((
Expand Down
2 changes: 1 addition & 1 deletion Orange/widgets/data/tests/test_owfeaturestatistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def _wrapper(self):
return _wrapper


class TestOWFeatureStatisticsTableTypes(WidgetTest):
class TestVariableTypes(WidgetTest):
def setUp(self):
self.widget = self.create_widget(
OWFeatureStatistics, stored_settings={'auto_commit': False}
Expand Down

0 comments on commit 3370cc8

Please sign in to comment.