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..95209eb9 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: @@ -48,9 +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" - # 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 - "%CMD_IN_ENV% python setup.py bdist_wheel bdist_wininst" - ps: "ls dist" 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 3760586e..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) @@ -421,3 +422,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)