Skip to content

Commit 0776122

Browse files
committed
Fix flake8
1 parent c50565c commit 0776122

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

sklearn_pandas/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
from .dataframe_mapper import DataFrameMapper # NOQA
44
from .cross_validation import cross_val_score, GridSearchCV, RandomizedSearchCV # NOQA
5-
from .categorical_imputer import CategoricalImputer
5+
from .categorical_imputer import CategoricalImputer # NOQA

sklearn_pandas/categorical_imputer.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
3-
Impute missing values from a categorical/string np.ndarray or pd.Series with the most frequent value on the training data.
3+
Impute missing values from a categorical/string np.ndarray or pd.Series with
4+
the most frequent value on the training data.
45
56
"""
67

@@ -52,7 +53,8 @@ def transform(self, X):
5253

5354
"""
5455
55-
Replaces null values in the input data with the most frequent value of the training data.
56+
Replaces null values in the input data with the most frequent value
57+
of the training data.
5658
5759
Parameters
5860
----------

sklearn_pandas/cross_validation.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
try:
33
from sklearn.model_selection import cross_val_score as sk_cross_val_score
44
from sklearn.model_selection import GridSearchCV as SKGridSearchCV
5-
from sklearn.model_selection import RandomizedSearchCV as SKRandomizedSearchCV
5+
from sklearn.model_selection import RandomizedSearchCV as \
6+
SKRandomizedSearchCV
67
except ImportError:
78
from sklearn.cross_validation import cross_val_score as sk_cross_val_score
89
from sklearn.grid_search import GridSearchCV as SKGridSearchCV
@@ -21,33 +22,40 @@ def cross_val_score(model, X, *args, **kwargs):
2122

2223

2324
class GridSearchCV(SKGridSearchCV):
25+
2426
def __init__(self, *args, **kwargs):
2527
warnings.warn(DEPRECATION_MSG, DeprecationWarning)
2628
super(GridSearchCV, self).__init__(*args, **kwargs)
2729

2830
def fit(self, X, *params, **kwparams):
29-
return super(GridSearchCV, self).fit(DataWrapper(X), *params, **kwparams)
31+
return super(GridSearchCV, self).fit(
32+
DataWrapper(X), *params, **kwparams)
3033

3134
def predict(self, X, *params, **kwparams):
32-
return super(GridSearchCV, self).predict(DataWrapper(X), *params, **kwparams)
35+
return super(GridSearchCV, self).predict(
36+
DataWrapper(X), *params, **kwparams)
3337

3438

3539
try:
3640
class RandomizedSearchCV(SKRandomizedSearchCV):
41+
3742
def __init__(self, *args, **kwargs):
3843
warnings.warn(DEPRECATION_MSG, DeprecationWarning)
3944
super(RandomizedSearchCV, self).__init__(*args, **kwargs)
4045

4146
def fit(self, X, *params, **kwparams):
42-
return super(RandomizedSearchCV, self).fit(DataWrapper(X), *params, **kwparams)
47+
return super(RandomizedSearchCV, self).fit(
48+
DataWrapper(X), *params, **kwparams)
4349

4450
def predict(self, X, *params, **kwparams):
45-
return super(RandomizedSearchCV, self).predict(DataWrapper(X), *params, **kwparams)
51+
return super(RandomizedSearchCV, self).predict(
52+
DataWrapper(X), *params, **kwparams)
4653
except AttributeError:
4754
pass
4855

4956

5057
class DataWrapper(object):
58+
5159
def __init__(self, df):
5260
self.df = df
5361

sklearn_pandas/dataframe_mapper.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .pipeline import make_transformer_pipeline, _call_fit
99

1010
# load in the correct stringtype: str for py3, basestring for py2
11-
string_types = str if sys.version_info >= (3, 0) else basestring
11+
string_types = str if sys.version_info >= (3, 0) else basestring # NOQA
1212

1313

1414
def _handle_feature(fea):
@@ -171,7 +171,6 @@ def fit(self, X, y=None):
171171
self._get_col_subset(X, self._unselected_columns(X)), y)
172172
return self
173173

174-
175174
def get_names(self, c, t, x):
176175
"""
177176
Return verbose names for the transformed columns.
@@ -194,7 +193,6 @@ def get_names(self, c, t, x):
194193
else:
195194
return [c]
196195

197-
198196
def transform(self, X):
199197
"""
200198
Transform the given data. Assumes that fit has already been called.
@@ -212,7 +210,8 @@ def transform(self, X):
212210
Xt = transformers.transform(Xt)
213211
extracted.append(_handle_feature(Xt))
214212

215-
self.transformed_names_ += self.get_names(columns, transformers, Xt)
213+
self.transformed_names_ += self.get_names(
214+
columns, transformers, Xt)
216215

217216
# handle features not explicitly selected
218217
if self.default is not False:
@@ -221,7 +220,8 @@ def transform(self, X):
221220
if self.default is not None:
222221
Xt = self.default.transform(Xt)
223222
extracted.append(_handle_feature(Xt))
224-
self.transformed_names_ += self.get_names(unsel_cols, self.default, Xt)
223+
self.transformed_names_ += self.get_names(
224+
unsel_cols, self.default, Xt)
225225

226226
# combine the feature outputs into one array.
227227
# at this point we lose track of which features

sklearn_pandas/pipeline.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ def _call_fit(fit_method, X, y=None, **kwargs):
2929

3030
class TransformerPipeline(Pipeline):
3131
"""
32-
Pipeline that expects all steps to be transformers taking a single X argument,
33-
an optional y argument,
34-
and having fit and transform methods.
32+
Pipeline that expects all steps to be transformers taking a single X
33+
argument, an optional y argument, and having fit and transform methods.
3534
3635
Code is copied from sklearn's Pipeline
3736
"""
37+
3838
def __init__(self, steps):
3939
names, estimators = zip(*steps)
4040
if len(dict(steps)) != len(steps):
41-
raise ValueError("Provided step names are not unique: %s" % (names,))
41+
raise ValueError(
42+
"Provided step names are not unique: %s" % (names,))
4243

4344
# shallow copy of steps
4445
self.steps = tosequence(steps)

tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ deps =
1515
py27: mock==1.3.0
1616

1717
commands =
18-
flake8 tests
18+
flake8 --exclude build
1919
py.test

0 commit comments

Comments
 (0)