From e50f47af3d7c6ac624be3f6a8575651b8cebe01c Mon Sep 17 00:00:00 2001 From: Vlad Niculae Date: Sat, 10 Jun 2017 09:05:06 +0200 Subject: [PATCH 1/5] bump ci python version --- .travis.yml | 2 +- appveyor.yml | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index f4b1f32e..0d3e2e7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,8 @@ sudo: false language: python python: - "2.7" - - "3.4" - "3.5" + - "3.6" install: # We do this conditionally because it saves us some downloading if the # version is the same. diff --git a/appveyor.yml b/appveyor.yml index c25edfb7..347b7c46 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,26 +9,21 @@ environment: CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\build_tools\\appveyor\\run_with_env.cmd" matrix: - - PYTHON: "C:\\Python27" - PYTHON_VERSION: "2.7.8" + - PYTHON_VERSION: "2.7.13" PYTHON_ARCH: "32" MINICONDA: "C:\\Miniconda" - - PYTHON: "C:\\Python27-x64" - PYTHON_VERSION: "2.7.8" + - PYTHON_VERSION: "2.7.13" PYTHON_ARCH: "64" MINICONDA: "C:\\Miniconda-x64" - - PYTHON: "C:\\Python35" - PYTHON_VERSION: "3.5.0" + - PYTHON_VERSION: "3.6.0" PYTHON_ARCH: "32" - MINICONDA: "C:\\Miniconda35" + MINICONDA: "C:\\Miniconda36" - - PYTHON: "C:\\Python35-x64" - PYTHON_VERSION: "3.5.0" + - PYTHON_VERSION: "3.6.0" PYTHON_ARCH: "64" - MINICONDA: "C:\\Miniconda35-x64" - + MINICONDA: "C:\\Miniconda36-x64" install: From 652a84c53991ace4baa6f0b2cef4ea4145f732ab Mon Sep 17 00:00:00 2001 From: Vlad Niculae Date: Sat, 10 Jun 2017 09:57:23 +0200 Subject: [PATCH 2/5] try up-to-date conda-build --- appveyor.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 347b7c46..fc506afd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,9 +43,7 @@ install: # Update previous packages and install the build and runtime dependencies of the project. - conda update --all --yes - conda install --quiet --yes numpy scipy cython nose scikit-learn wheel" - # there seems to be a problem with conda-build 1.21.0 on python27 and win64, avoid this - # by using a previous version - - conda install --quiet --yes conda-build=1.21.0 + - conda install --quiet --yes conda-build - "%CMD_IN_ENV% python setup.py bdist_wheel bdist_wininst" - ps: "ls dist" From 22b96dd0d5989a54eb15033616ac1e93be9f8ebe Mon Sep 17 00:00:00 2001 From: Vlad Niculae Date: Sat, 10 Jun 2017 09:59:54 +0200 Subject: [PATCH 3/5] actually, do we even need conda-build? --- appveyor.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index fc506afd..95209eb9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -43,7 +43,6 @@ install: # Update previous packages and install the build and runtime dependencies of the project. - conda update --all --yes - conda install --quiet --yes numpy scipy cython nose scikit-learn wheel" - - conda install --quiet --yes conda-build - "%CMD_IN_ENV% python setup.py bdist_wheel bdist_wininst" - ps: "ls dist" From 9cde4bbcdcc5e4ad75af2fb6dbc00a15bad2b3cc Mon Sep 17 00:00:00 2001 From: Vlad Niculae Date: Sat, 10 Jun 2017 08:15:00 +0200 Subject: [PATCH 4/5] add failing test for #114 --- lightning/impl/tests/test_primal_cd.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lightning/impl/tests/test_primal_cd.py b/lightning/impl/tests/test_primal_cd.py index 3760586e..48197cdf 100644 --- a/lightning/impl/tests/test_primal_cd.py +++ b/lightning/impl/tests/test_primal_cd.py @@ -421,3 +421,11 @@ def test_multiclass_classes(): clf = CDClassifier() clf.fit(mult_dense, mult_target) assert_equal(list(clf.classes_), [0, 1, 2]) + + +def test_n_jobs_can_fit(): + # Check that all loss cdef classes pickle (issue #114) + for loss in ('squared', 'smooth_hinge', 'squared_hinge', 'modified_huber', + 'log'): + clf = CDClassifier(loss=loss, n_jobs=2) + clf.fit(mult_dense, mult_target) From f06f871030e8dc05656e3cf1ca72d72239721d02 Mon Sep 17 00:00:00 2001 From: Vlad Niculae Date: Sat, 10 Jun 2017 08:26:08 +0200 Subject: [PATCH 5/5] fix pickling losses in primal_cd --- lightning/impl/primal_cd_fast.pyx | 6 ++++++ lightning/impl/tests/test_primal_cd.py | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lightning/impl/primal_cd_fast.pyx b/lightning/impl/primal_cd_fast.pyx index 78ab3b6d..7ac8e6f6 100644 --- a/lightning/impl/primal_cd_fast.pyx +++ b/lightning/impl/primal_cd_fast.pyx @@ -32,6 +32,12 @@ cdef class LossFunction: cdef double beta cdef int verbose + def __getstate__(self): + return self.max_steps, self.sigma, self.beta, self.verbose + + def __setstate__(self, state): + self.max_steps, self.sigma, self.beta, self.verbose = state + # L2 regularization cdef void solve_l2(self, diff --git a/lightning/impl/tests/test_primal_cd.py b/lightning/impl/tests/test_primal_cd.py index 48197cdf..e1ff8e4f 100644 --- a/lightning/impl/tests/test_primal_cd.py +++ b/lightning/impl/tests/test_primal_cd.py @@ -178,7 +178,8 @@ def test_debiasing_l1l2(): multiclass=False, debiasing=True, warm_debiasing=warm_debiasing, - max_iter=20, C=0.01, random_state=0) + max_iter=20, C=0.01, random_state=0, + verbose=True) clf.fit(mult_csc, mult_target) assert_greater(clf.score(mult_csc, mult_target), 0.75) assert_equal(clf.n_nonzero(percentage=True), 0.08)