Skip to content

Commit fd02b69

Browse files
OWFeatureStatistics: pylint fixes
1 parent b496cab commit fd02b69

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

Orange/widgets/data/owfeaturestatistics.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ def set_data(self, data):
154154
self.target_var = None
155155

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

160162
self.n_attributes = len(self.variables)
@@ -349,7 +351,7 @@ def sortColumnData(self, column):
349351
var_name_indices = np.argsort(self._variable_names)
350352

351353
# Prepare vartype indices so ready when needed
352-
disc_idx, cont_idx, time_idx, str_idx = self._attr_indices(self.variables)
354+
disc_idx, _, time_idx, str_idx = self._attr_indices(self.variables)
353355

354356
# Sort by: (type)
355357
if column == self.Columns.ICON:
@@ -395,6 +397,8 @@ def sortColumnData(self, column):
395397
elif column == self.Columns.MISSING:
396398
return self._missing
397399

400+
return None
401+
398402
def _sortColumnData(self, column):
399403
"""Allow sorting with 2d arrays."""
400404
data = np.asarray(self.sortColumnData(column))
@@ -437,10 +441,16 @@ def headerData(self, section, orientation, role):
437441
if role == Qt.DisplayRole:
438442
return self.Columns.from_index(section).name
439443

444+
return None
445+
440446
def data(self, index, role):
441447
# type: (QModelIndex, Qt.ItemDataRole) -> Any
448+
# Text formatting for various data simply requires a lot of branches.
449+
# This is much better than overengineering various formatters...
450+
# pylint: disable=too-many-branches
451+
442452
if not index.isValid():
443-
return
453+
return None
444454

445455
row, column = self.mapToSourceRows(index.row()), index.column()
446456
# Make sure we're not out of range
@@ -660,6 +670,9 @@ def paint(self, painter, option, index):
660670

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

673+
# pylint complains about inconsistent return statements
674+
return None
675+
663676

664677
class OWFeatureStatistics(widget.OWWidget):
665678
name = 'Feature Statistics'
@@ -812,7 +825,11 @@ def _format_variables_string(self, variables):
812825
('time', TimeVariable),
813826
('string', StringVariable)
814827
]:
815-
var_type_list = [v for v in variables if type(v) is var_type]
828+
# Disable pylint here because a `TimeVariable` is also a
829+
# `ContinuousVariable`, and should be labelled as such. That is why
830+
# it is necessary to check the type this way instead of using
831+
# `isinstance`, which would fail in the above case
832+
var_type_list = [v for v in variables if type(v) is var_type] # pylint: disable=unidiomatic-typecheck
816833
if var_type_list:
817834
shown = var_type in self.model.HIDDEN_VAR_TYPES
818835
agg.append((

Orange/widgets/data/tests/test_owfeaturestatistics.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _wrapper(self):
187187
return _wrapper
188188

189189

190-
class TestOWFeatureStatisticsTableTypes(WidgetTest):
190+
class TestVariableTypes(WidgetTest):
191191
def setUp(self):
192192
self.widget = self.create_widget(
193193
OWFeatureStatistics, stored_settings={'auto_commit': False}

Orange/widgets/data/utils/histogram.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ class Histogram(QGraphicsWidget):
124124
def __init__(self, data, variable, parent=None, height=200,
125125
width=300, side_padding=5, top_padding=20, bar_spacing=4,
126126
border=0, border_color=None, color_attribute=None, n_bins=10):
127+
# The price of flexibility is complexity...
128+
# pylint: disable=too-many-instance-attributes
127129
super().__init__(parent)
128130
self.height, self.width = height, width
129131
self.padding = side_padding

0 commit comments

Comments
 (0)