Skip to content

Commit a090852

Browse files
committed
PLS: Lint
1 parent 4a742fc commit a090852

File tree

4 files changed

+18
-17
lines changed

4 files changed

+18
-17
lines changed

Orange/regression/pls.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ def __init__(self, pls_model):
2525
self.pls_model = pls_model
2626

2727
def _transform_with_numpy_output(self, X, Y):
28-
pls = self.pls_model.skl_model
2928
"""
3029
# the next command does the following
3130
x_center = X - pls._x_mean
3231
y_center = Y - pls._y_mean
3332
t = x_center @ pls.x_rotations_
3433
u = y_center @ pls.y_rotations_
3534
"""
35+
pls = self.pls_model.skl_model
3636
t, u = pls.transform(X, Y)
3737
return np.hstack((t, u))
3838

@@ -70,7 +70,7 @@ def predict(self, X):
7070
return vals
7171

7272
def __str__(self):
73-
return 'PLSModel {}'.format(self.skl_model)
73+
return f"PLSModel {self.skl_model}"
7474

7575
def _get_var_names(self, n, prefix):
7676
names = [f"{prefix}{postfix}" for postfix in range(1, n + 1)]
@@ -170,8 +170,8 @@ def incompatibility_reason(self, domain):
170170
if __name__ == '__main__':
171171
import Orange
172172

173-
data = Orange.data.Table('housing')
173+
housing = Orange.data.Table('housing')
174174
learners = [PLSRegressionLearner(n_components=2, max_iter=100)]
175-
res = Orange.evaluation.CrossValidation()(data, learners)
175+
res = Orange.evaluation.CrossValidation()(housing, learners)
176176
for learner, ca in zip(learners, Orange.evaluation.RMSE(res)):
177-
print("learner: {}\nRMSE: {}\n".format(learner, ca))
177+
print(f"learner: {learner}\nRMSE: {ca}\n")

Orange/regression/tests/test_pls.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
from Orange.regression import PLSRegressionLearner
99

1010

11-
def table(rows, attr, vars):
12-
attr_vars = [ContinuousVariable(name="Feature %i" % i) for i in
11+
def table(rows, attr, variables):
12+
attr_vars = [ContinuousVariable(name=f"Feature {i}") for i in
1313
range(attr)]
14-
class_vars = [ContinuousVariable(name="Class %i" % i) for i in range(vars)]
14+
class_vars = [ContinuousVariable(name=f"Class {i}") for i in
15+
range(variables)]
1516
domain = Domain(attr_vars, class_vars, [])
1617
X = np.random.RandomState(0).random((rows, attr))
17-
Y = np.random.RandomState(1).random((rows, vars))
18+
Y = np.random.RandomState(1).random((rows, variables))
1819
return Table.from_numpy(domain, X=X, Y=Y)
1920

2021

Orange/widgets/model/owpls.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ class Warning(OWBaseLearner.Warning):
3333
max_iter = Setting(500)
3434

3535
def add_main_layout(self):
36-
37-
self.optimization_box = gui.vBox(
36+
optimization_box = gui.vBox(
3837
self.controlArea, "Optimization Parameters")
39-
self.ncomps_spin = gui.spin(
40-
self.optimization_box, self, "n_components", 1, 50, 1,
38+
gui.spin(
39+
optimization_box, self, "n_components", 1, 50, 1,
4140
label="Components: ",
4241
alignment=Qt.AlignRight, controlWidth=100,
4342
callback=self.settings_changed)
44-
self.n_iters = gui.spin(
45-
self.optimization_box, self, "max_iter", 5, 1000000, 50,
43+
gui.spin(
44+
optimization_box, self, "max_iter", 5, 1000000, 50,
4645
label="Iteration limit: ",
4746
alignment=Qt.AlignRight, controlWidth=100,
4847
callback=self.settings_changed,

Orange/widgets/model/tests/test_owpls.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ def setUp(self):
1111
stored_settings={"auto_apply": False})
1212
self.init()
1313
self.parameters = [
14-
ParameterMapping('max_iter', self.widget.n_iters),
15-
ParameterMapping('n_components', self.widget.ncomps_spin)]
14+
ParameterMapping('max_iter', self.widget.controls.max_iter),
15+
ParameterMapping('n_components', self.widget.controls.n_components)
16+
]
1617

1718

1819
if __name__ == "__main__":

0 commit comments

Comments
 (0)