From ede7b14659531f2964a990c00d959d76fdefd24b Mon Sep 17 00:00:00 2001 From: salman Date: Mon, 6 Nov 2017 15:55:06 -0500 Subject: [PATCH 1/7] sh options for flake8 moved to setup.cfg --- build_tools/travis/flake8_diff.sh | 9 +++------ setup.cfg | 3 +++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build_tools/travis/flake8_diff.sh b/build_tools/travis/flake8_diff.sh index 84495b339a922..67db362592fd5 100755 --- a/build_tools/travis/flake8_diff.sh +++ b/build_tools/travis/flake8_diff.sh @@ -137,12 +137,9 @@ check_files() { if [[ "$MODIFIED_FILES" == "no_match" ]]; then echo "No file outside sklearn/externals and doc/sphinxext/sphinx_gallery has been modified" else - # Default ignore PEP8 violations are from flake8 3.3.0 - DEFAULT_IGNORED_PEP8=E121,E123,E126,E226,E24,E704,W503,W504 - check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)" \ - --ignore $DEFAULT_IGNORED_PEP8 + + check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)" # Examples are allowed to not have imports at top of file - check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" \ - --ignore $DEFAULT_IGNORED_PEP8 --ignore E402 + check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" --ignore E402 fi echo -e "No problem detected by flake8\n" diff --git a/setup.cfg b/setup.cfg index 378905311e17e..15110f1b90227 100644 --- a/setup.cfg +++ b/setup.cfg @@ -38,6 +38,9 @@ artifact_indexes= # https://ci.appveyor.com/project/sklearn-ci/scikit-learn/ http://windows-wheels.scikit-learn.org/ +[flake8] +ignore=E121,E123,E126,E24,E704,W503,W504 + # Uncomment the following under windows to build using: # http://sourceforge.net/projects/mingw/ From 1375079e7807eb8e41ed25fe4298245d49c01919 Mon Sep 17 00:00:00 2001 From: salman Date: Wed, 8 Nov 2017 19:17:27 -0500 Subject: [PATCH 2/7] .flake8 added to examples --- build_tools/travis/flake8_diff.sh | 9 +++++++-- examples/.flake8 | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 examples/.flake8 diff --git a/build_tools/travis/flake8_diff.sh b/build_tools/travis/flake8_diff.sh index 67db362592fd5..1af7b869fdddd 100755 --- a/build_tools/travis/flake8_diff.sh +++ b/build_tools/travis/flake8_diff.sh @@ -20,6 +20,9 @@ set -o pipefail PROJECT=scikit-learn/scikit-learn PROJECT_URL=https://github.com/$PROJECT.git +DEFAULT_FLAKE8_CONFIG=./setup.cfg +EXAMPLES_FLAKE8_CONFIG=./examples/.flake8 + # Find the remote with the project name (upstream in most cases) REMOTE=$(git remote -v | grep $PROJECT | cut -f1 | head -1 || echo '') @@ -138,8 +141,10 @@ if [[ "$MODIFIED_FILES" == "no_match" ]]; then echo "No file outside sklearn/externals and doc/sphinxext/sphinx_gallery has been modified" else - check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)" + check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)" \ + --config $DEFAULT_FLAKE8_CONFIG # Examples are allowed to not have imports at top of file - check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" --ignore E402 + check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" \ + --config $EXAMPLES_FLAKE8_CONFIG fi echo -e "No problem detected by flake8\n" diff --git a/examples/.flake8 b/examples/.flake8 new file mode 100644 index 0000000000000..5e918767b98d1 --- /dev/null +++ b/examples/.flake8 @@ -0,0 +1,4 @@ +# Examples specific flake8 configuration +# Same as project-wide with E402 (imports not at top of file) added +[flake8] +ignore = E121,E123,E126,E24,E402,E704,W503,W504 From 08b190cbeea48f192797710660283cbe6b66bedf Mon Sep 17 00:00:00 2001 From: salman Date: Wed, 8 Nov 2017 19:49:19 -0500 Subject: [PATCH 3/7] added comments to setup.cfg --- setup.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.cfg b/setup.cfg index 15110f1b90227..c4acbca53a234 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,6 +39,7 @@ artifact_indexes= http://windows-wheels.scikit-learn.org/ [flake8] +# Default flake8 ignored flags minus E226 ignore=E121,E123,E126,E24,E704,W503,W504 # Uncomment the following under windows to build using: From b931bfea13bae2c1e461b34cb8e8205f7df7a2f7 Mon Sep 17 00:00:00 2001 From: salman Date: Tue, 14 Nov 2017 01:31:07 -0500 Subject: [PATCH 4/7] e226 added back into ignore --- examples/.flake8 | 2 +- setup.cfg | 4 ++-- sklearn/linear_model/bayes.py | 6 +++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/.flake8 b/examples/.flake8 index 5e918767b98d1..361d9037ebda2 100644 --- a/examples/.flake8 +++ b/examples/.flake8 @@ -1,4 +1,4 @@ # Examples specific flake8 configuration # Same as project-wide with E402 (imports not at top of file) added [flake8] -ignore = E121,E123,E126,E24,E402,E704,W503,W504 +ignore = E121,E123,E126,E24,E402,E226,E704,W503,W504 diff --git a/setup.cfg b/setup.cfg index c4acbca53a234..d957ca59699da 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,8 +39,8 @@ artifact_indexes= http://windows-wheels.scikit-learn.org/ [flake8] -# Default flake8 ignored flags minus E226 -ignore=E121,E123,E126,E24,E704,W503,W504 +# Default flake8 ignored flags +ignore=E121,E123,E126,E24,E226,E704,W503,W504 # Uncomment the following under windows to build using: # http://sourceforge.net/projects/mingw/ diff --git a/sklearn/linear_model/bayes.py b/sklearn/linear_model/bayes.py index 64029ae5d640b..226b1c2d182e9 100644 --- a/sklearn/linear_model/bayes.py +++ b/sklearn/linear_model/bayes.py @@ -162,7 +162,11 @@ def fit(self, X, y): n_samples, n_features = X.shape # Initialization of the values of the parameters - alpha_ = 1. / np.var(y) + var_y = np.var(y) + if var_y: + alpha_ = 1. / var_y + else: + alpha_ = 0.1 lambda_ = 1. verbose = self.verbose From dbf0c99aef2bb183ad0b9f0bf2c74c1961cf110c Mon Sep 17 00:00:00 2001 From: salman Date: Tue, 14 Nov 2017 01:34:02 -0500 Subject: [PATCH 5/7] removed messed up bayes --- sklearn/linear_model/bayes.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/sklearn/linear_model/bayes.py b/sklearn/linear_model/bayes.py index 226b1c2d182e9..cef6a790bbc4b 100644 --- a/sklearn/linear_model/bayes.py +++ b/sklearn/linear_model/bayes.py @@ -162,12 +162,8 @@ def fit(self, X, y): n_samples, n_features = X.shape # Initialization of the values of the parameters - var_y = np.var(y) - if var_y: - alpha_ = 1. / var_y - else: - alpha_ = 0.1 - lambda_ = 1. + alpha_ = 1. / np.var(y) + verbose = self.verbose lambda_1 = self.lambda_1 From db4b40a0bd095eb24ff4c4458e0398c5bb3249e0 Mon Sep 17 00:00:00 2001 From: salman Date: Tue, 14 Nov 2017 01:35:54 -0500 Subject: [PATCH 6/7] removed messed up bayes --- sklearn/linear_model/bayes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sklearn/linear_model/bayes.py b/sklearn/linear_model/bayes.py index cef6a790bbc4b..64029ae5d640b 100644 --- a/sklearn/linear_model/bayes.py +++ b/sklearn/linear_model/bayes.py @@ -163,7 +163,7 @@ def fit(self, X, y): # Initialization of the values of the parameters alpha_ = 1. / np.var(y) - + lambda_ = 1. verbose = self.verbose lambda_1 = self.lambda_1 From 6e240e9cf4e81c84e61a66538599da3d30353d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Est=C3=A8ve?= Date: Tue, 14 Nov 2017 11:55:35 +0100 Subject: [PATCH 7/7] Minor tweaks --- build_tools/travis/flake8_diff.sh | 9 ++------- examples/.flake8 | 5 +++-- setup.cfg | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/build_tools/travis/flake8_diff.sh b/build_tools/travis/flake8_diff.sh index 1af7b869fdddd..9781f7e6a5cc0 100755 --- a/build_tools/travis/flake8_diff.sh +++ b/build_tools/travis/flake8_diff.sh @@ -20,9 +20,6 @@ set -o pipefail PROJECT=scikit-learn/scikit-learn PROJECT_URL=https://github.com/$PROJECT.git -DEFAULT_FLAKE8_CONFIG=./setup.cfg -EXAMPLES_FLAKE8_CONFIG=./examples/.flake8 - # Find the remote with the project name (upstream in most cases) REMOTE=$(git remote -v | grep $PROJECT | cut -f1 | head -1 || echo '') @@ -141,10 +138,8 @@ if [[ "$MODIFIED_FILES" == "no_match" ]]; then echo "No file outside sklearn/externals and doc/sphinxext/sphinx_gallery has been modified" else - check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)" \ - --config $DEFAULT_FLAKE8_CONFIG - # Examples are allowed to not have imports at top of file + check_files "$(echo "$MODIFIED_FILES" | grep -v ^examples)" check_files "$(echo "$MODIFIED_FILES" | grep ^examples)" \ - --config $EXAMPLES_FLAKE8_CONFIG + --config ./examples/.flake8 fi echo -e "No problem detected by flake8\n" diff --git a/examples/.flake8 b/examples/.flake8 index 361d9037ebda2..703bf15e79bff 100644 --- a/examples/.flake8 +++ b/examples/.flake8 @@ -1,4 +1,5 @@ # Examples specific flake8 configuration -# Same as project-wide with E402 (imports not at top of file) added + [flake8] -ignore = E121,E123,E126,E24,E402,E226,E704,W503,W504 +# Same ignore as project-wide plus E402 (imports not at top of file) +ignore=E121,E123,E126,E24,E226,E704,W503,W504,E402 diff --git a/setup.cfg b/setup.cfg index d957ca59699da..02b3015e87f2e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,8 +39,8 @@ artifact_indexes= http://windows-wheels.scikit-learn.org/ [flake8] -# Default flake8 ignored flags -ignore=E121,E123,E126,E24,E226,E704,W503,W504 +# Default flake8 3.5 ignored flags +ignore=E121,E123,E126,E226,E24,E704,W503,W504 # Uncomment the following under windows to build using: # http://sourceforge.net/projects/mingw/