Skip to content

Commit 9b6899e

Browse files
committed
Preprocess: Add missing __repr__methods
1 parent 7fa6a32 commit 9b6899e

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Orange/widgets/data/owpreprocess.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
from Orange.preprocess import Continuize, ProjectPCA, RemoveNaNRows, \
2828
ProjectCUR, Scale as _Scale, Randomize as _Randomize, RemoveSparse
2929
from Orange.widgets import widget, gui
30+
from Orange.widgets.utils.localization import pl
3031
from Orange.widgets.settings import Setting
3132
from Orange.widgets.utils.overlay import OverlayWidget
3233
from Orange.widgets.utils.sql import check_sql_input
@@ -255,7 +256,7 @@ def __repr__(self):
255256

256257
class RemoveSparseEditor(BaseEditor):
257258

258-
options = ["missing", "zeros"]
259+
options = ["missing values", "zeros"]
259260

260261
def __init__(self, parent=None, **kwargs):
261262
super().__init__(parent, **kwargs)
@@ -266,11 +267,9 @@ def __init__(self, parent=None, **kwargs):
266267
self.setLayout(QVBoxLayout())
267268

268269
self.layout().addWidget(QLabel("Remove features with too many"))
269-
options = ["missing values",
270-
"zeros"]
271270
self.filter_buttons = QButtonGroup(exclusive=True)
272271
self.filter_buttons.buttonClicked.connect(self.filterByClicked)
273-
for idx, option, in enumerate(options):
272+
for idx, option, in enumerate(self.options):
274273
btn = QRadioButton(self, text=option, checked=idx == 0)
275274
self.filter_buttons.addButton(btn, id=idx)
276275
self.layout().addWidget(btn)
@@ -354,6 +353,15 @@ def createinstance(params):
354353
threshold = params.pop('percThresh', 5) / 100
355354
return RemoveSparse(threshold, filter0)
356355

356+
def __repr__(self):
357+
desc = f"remove features with too many {self.options[self.filter0]}, threshold: "
358+
if self.useFixedThreshold:
359+
desc += f"{self.fixedThresh} {pl(self.fixedThresh, 'instance')}"
360+
else:
361+
desc += f"{self.percThresh} %"
362+
return desc
363+
364+
357365
class ImputeEditor(BaseEditor):
358366
(NoImputation, Constant, Average,
359367
Model, Random, DropRows, DropColumns) = 0, 1, 2, 3, 4, 5, 6
@@ -727,6 +735,12 @@ def createinstance(params):
727735
# further implementations
728736
raise NotImplementedError
729737

738+
def __repr__(self):
739+
if self.__strategy == self.Fixed:
740+
return f"select {self.__k} {pl(self.__k,'feature')}"
741+
else:
742+
return f"select {self.__p} % features"
743+
730744

731745
def index_to_enum(enum, i):
732746
"""Enums, by default, are not int-comparable, so use an ad-hoc mapping of

0 commit comments

Comments
 (0)