[MRG+1] Dropping python 2.6 support#7890
Conversation
Some details about some slightly orthogonal changes: * Note about cheking safely for nan is likely not valid any more (commit introducing it is c80ca91) * scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of mode='economic' * Remove unnecessary libgfortran in conda create command
lesteve
left a comment
There was a problem hiding this comment.
A few comments to help the review
| # Get generalized least squares solution | ||
| Ft = linalg.solve_triangular(C, F, lower=True) | ||
| try: | ||
| Q, G = linalg.qr(Ft, econ=True) |
There was a problem hiding this comment.
econ=True removed in scipy=0.9 which matches our minimum scipy version. From
https://github.com/scipy/scipy/blob/master/doc/release/0.9.0-notes.rst#removed-features.
sklearn/metrics/classification.py
Outdated
| # the jaccard to 1: lim_{x->0} x/x = 1 | ||
| # Note with py2.6 and np 1.3: we can't check safely for nan. | ||
| score[pred_or_true == 0.0] = 1.0 | ||
| score[np.isnan(score)] = 1.0 |
There was a problem hiding this comment.
Bold move I know. The commit introducing this change is c80ca91 and no tests were added for this edge case along with the change. Does anyone remember a problem like this?
There was a problem hiding this comment.
can't we do the same thing here we do in places like StandardScaler?
There was a problem hiding this comment.
Can you elaborate on what we do in StandardScaler ?
There was a problem hiding this comment.
Modifying the denominator, so setting pred_or_true[pred_or_true == 0] = 1. Then we don't need to catch the error, either.
There was a problem hiding this comment.
Wait, sorry, we want score to be one, not zero. We should really have a standard way of dividing by zero, it comes up soo often. what's wrong with the current solution though? I find it cleaner than the change.
There was a problem hiding this comment.
Fine then I'll leave the previous solution and just remove the comment. Given the comment I thought something in an old python + numpy was preventing to just check for NaNs.
| # exact results on this toy dataset. | ||
| lsfh = LSHForest(min_hash_match=0, n_candidates=n_points).fit(X) | ||
| lsfh = LSHForest(min_hash_match=0, n_candidates=n_points, | ||
| random_state=42).fit(X) |
There was a problem hiding this comment.
I don't know why this is needed ... but it is needed without it you get an error consistently like this if you run the tests with nosetests sklearn. The error can not be reproduced only with running a single test function or the single file with nosetests sklearn/neighbors/tests/test_approximate.py and I tried in a loop 100 times. Still trying to get to the bottom of this ...
There was a problem hiding this comment.
The implication being that in removing one of the fixes you changed behaviour?
There was a problem hiding this comment.
well this should be here anyhow...
| COVERAGE=true | ||
| # This environment tests the oldest supported anaconda env | ||
| - DISTRIB="conda" PYTHON_VERSION="2.6" INSTALL_MKL="false" | ||
| - DISTRIB="conda" PYTHON_VERSION="2.7" INSTALL_MKL="false" |
There was a problem hiding this comment.
Still keeping this build to test oldest versions available through conda.
| assert_raises_regex(AttributeError, msg, check_estimator, BaseEstimator) | ||
| # check that fit does input validation | ||
| msg = "TypeError not raised by fit" | ||
| msg = "TypeError not raised" |
There was a problem hiding this comment.
Looks like the tests fail on Python 2.7 without this change ... I'll look into it in more details.
There was a problem hiding this comment.
So it looks like unittest.TestCase.assertRegexp does not print the function name in its error message if no exception is raised only with Python 2.7:
import unittest
_dummy = unittest.TestCase('__init__')
def no_raise():
return
_dummy.assertRaisesRegexp(ValueError, 'message', no_raise)With Python 2.7:
AssertionError: ValueError not raised
With Python 3:
AssertionError: ValueError not raised by no_raise
The patch we had before was applied to Python 2.7 despite the misleading comment (assertRegex vs assertRegexp). Are we good with the change then?
|
Thanks for this, @lesteve! |
amueller
left a comment
There was a problem hiding this comment.
LGTM apart from minor comments.
| if [[ "$INSTALL_MKL" == "true" ]]; then | ||
| conda create -n testenv --yes python=$PYTHON_VERSION pip nose \ | ||
| numpy=$NUMPY_VERSION scipy=$SCIPY_VERSION numpy scipy \ | ||
| libgfortran mkl flake8 \ |
There was a problem hiding this comment.
what's the reasoning with libgfortran?
There was a problem hiding this comment.
I think at one point it was needed explicitly because dependencies were not correctly defined in the conda metadata. This has long been fixed.
sklearn/metrics/classification.py
Outdated
| # the jaccard to 1: lim_{x->0} x/x = 1 | ||
| # Note with py2.6 and np 1.3: we can't check safely for nan. | ||
| score[pred_or_true == 0.0] = 1.0 | ||
| score[np.isnan(score)] = 1.0 |
There was a problem hiding this comment.
can't we do the same thing here we do in places like StandardScaler?
| # exact results on this toy dataset. | ||
| lsfh = LSHForest(min_hash_match=0, n_candidates=n_points).fit(X) | ||
| lsfh = LSHForest(min_hash_match=0, n_candidates=n_points, | ||
| random_state=42).fit(X) |
There was a problem hiding this comment.
well this should be here anyhow...
| assert_raises_regex(AttributeError, msg, check_estimator, BaseEstimator) | ||
| # check that fit does input validation | ||
| msg = "TypeError not raised by fit" | ||
| msg = "TypeError not raised" |
a2a923e to
b152872
Compare
|
Hm do you keep force-pushing? I can't find your comments :-/ |
| callable_obj.__name__)) | ||
|
|
||
| # Python 2.7 | ||
| assert_raises_regex = _dummy.assertRaisesRegexp |
There was a problem hiding this comment.
Hm or leave the old one in and not change behavior?
There was a problem hiding this comment.
I'd rather use the stdlib function rather than our backport (that was only intended for Python 2.6 btw but was kicking in for Python 2.7 too for some bad reason). The only change in behaviour is the name of the function that does not add that much value given that you can find it in the stacktrace.
Error messages from Python 2.7 assertRegexp does not contain the function name, in contrast with Python 3 assertRegex
4be9b87 to
25c474d
Compare
You can probably change it just a tiny bit and copy and paste into the console or turn it into a bookmarklet if you wish. For some reason I can't remember I never managed to get the latter to work. |
|
LGTM |
|
LGTM, thanks :) |
|
Yay!
…On 24 November 2016 at 09:11, Andreas Mueller ***@***.***> wrote:
LGTM, thanks :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#7890 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAEz66_G0bREc7kMvz29iTCrampnps26ks5rBLn-gaJpZM4Kz2fT>
.
|
* Remove Python 2.6 support Some details about some slightly orthogonal changes: * Note about cheking safely for nan is likely not valid any more (commit introducing it is c80ca91) * scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of mode='economic' * Remove unnecessary libgfortran in conda create command * Putative fix by setting the random seed * Revert unintended change * Reinstate previous logic for checking for NaNs * Reinstate change in error message Error messages from Python 2.7 assertRegexp does not contain the function name, in contrast with Python 3 assertRegex
* Remove Python 2.6 support Some details about some slightly orthogonal changes: * Note about cheking safely for nan is likely not valid any more (commit introducing it is c80ca91) * scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of mode='economic' * Remove unnecessary libgfortran in conda create command * Putative fix by setting the random seed * Revert unintended change * Reinstate previous logic for checking for NaNs * Reinstate change in error message Error messages from Python 2.7 assertRegexp does not contain the function name, in contrast with Python 3 assertRegex
* Remove Python 2.6 support Some details about some slightly orthogonal changes: * Note about cheking safely for nan is likely not valid any more (commit introducing it is c80ca91) * scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of mode='economic' * Remove unnecessary libgfortran in conda create command * Putative fix by setting the random seed * Revert unintended change * Reinstate previous logic for checking for NaNs * Reinstate change in error message Error messages from Python 2.7 assertRegexp does not contain the function name, in contrast with Python 3 assertRegex
* Remove Python 2.6 support Some details about some slightly orthogonal changes: * Note about cheking safely for nan is likely not valid any more (commit introducing it is c80ca91) * scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of mode='economic' * Remove unnecessary libgfortran in conda create command * Putative fix by setting the random seed * Revert unintended change * Reinstate previous logic for checking for NaNs * Reinstate change in error message Error messages from Python 2.7 assertRegexp does not contain the function name, in contrast with Python 3 assertRegex
* Remove Python 2.6 support Some details about some slightly orthogonal changes: * Note about cheking safely for nan is likely not valid any more (commit introducing it is c80ca91) * scipy.linalg.qr econ parameter removed since scipy 0.9 in favour of mode='economic' * Remove unnecessary libgfortran in conda create command * Putative fix by setting the random seed * Revert unintended change * Reinstate previous logic for checking for NaNs * Reinstate change in error message Error messages from Python 2.7 assertRegexp does not contain the function name, in contrast with Python 3 assertRegex
0.19 is the first release without Python 2.6 support. Related: #7522.
The
git grepI used to try to remove Python 2.6 code: