[MRG] Fix tests on numpy master#8355
Conversation
5bf780c to
8fb95cb
Compare
Codecov Report
@@ Coverage Diff @@
## master #8355 +/- ##
=======================================
Coverage 94.75% 94.75%
=======================================
Files 342 342
Lines 60801 60801
=======================================
Hits 57609 57609
Misses 3192 3192
Continue to review full report at Codecov.
|
|
The Travis build on this PR with numpy master is green as you can see from: |
sklearn/gaussian_process/kernels.py
Outdated
| """ | ||
| # We have to fall back to slow way of computing diagonal | ||
| return np.apply_along_axis(self, 1, X)[:, 0] | ||
| return np.apply_along_axis(lambda arr: self(arr).ravel(), 1, X)[:, 0] |
There was a problem hiding this comment.
I think this is written in a confusing way, if self(arr) is returning an array of shape (1,1).
Shouldn't either of the following do the same?
np.apply_along_axis(lambda arr: self(arr)[0, 0], 1, X)
np.apply_along_axis(self, 1, X).ravel()There was a problem hiding this comment.
I think this is written in a confusing way, if self(arr) is returning an array of shape (1,1).
Yeah I was not sure what was the best way to write it. Would you rather have
np.apply_along_axis(lambda arr: self(arr)[0, 0], 1, X)Shouldn't either of the following do the same?
It does in numpy 1.12 but not in numpy master as I tried to highlight in the description.
There was a problem hiding this comment.
Actually my bad you need to use:the following in numpy master:
np.apply_along_axis(lambda arr: self(arr)[0], 1, X)8fb95cb to
e9777a1
Compare
|
Ravelling the output doesn't wok without the lambda?
…On 15 February 2017 at 17:49, Loïc Estève ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In sklearn/gaussian_process/kernels.py
<#8355>:
> @@ -1852,7 +1852,7 @@ def diag(self, X):
Diagonal of kernel k(X, X)
"""
# We have to fall back to slow way of computing diagonal
- return np.apply_along_axis(self, 1, X)[:, 0]
+ return np.apply_along_axis(lambda arr: self(arr).ravel(), 1, X)[:, 0]
Actually my bad you need to use:the following in numpy master:
np.apply_along_axis(lambda arr: self(arr)[0], 1, X)
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#8355>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAEz67UlTmgNOoezB-kMR_G3f53yW-0xks5rcp_dgaJpZM4MAfSB>
.
|
Ah sorry I read your comment too quickly above, this does work in numpy master indeed: np.apply_along_axis(self, 1, X).ravel() |
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
e9777a1 to
3578d4b
Compare
|
LGTM |
|
Thanks! |
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
* Fix tests on numpy master (#7946) Until now we were in a edge case on assert_array_equal * Fix tests on numpy master (#8355) numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array * [MRG] Updated plot_stock_market.py to use Google Finance (#9010) * DOC updated plot_stock_market.py to use Google Finance The implementations is intentionally very basic not to distract the users from the example. Specifically unlike ``quotes_historical_yahoo_ochl`` it does not cache downloaded data. I also had to remove some symbols because the have no data on Google for the specified date interval. These are WBA, LMT, KFT and MTU. Closes #8899 * DOC removed plot_stock_market.py from expected failing examples * Addressed review comments * Addressed another pass of review comments * [MRG] Remove DeprecationWarnings in examples due to using floats instead of ints (#8040)
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
numpy.apply_along_axis has changed behaviour when the function passed in returns a 2d array
numpy.apply_along_axishas changed behaviour when the function passedin returns a 2d array. Very likely related to numpy/numpy#8441.
The first build in master I could find with the failure on numpy dev (from 2 days ago):
https://travis-ci.org/scikit-learn/scikit-learn/builds/200889357
outputs
(3, 1, 1)on numpy master and(3, 1)on numpy 1.12.A scikit-learn snippet closely related to the test failure:
outputs
(3, 1)on numpy master and(3,)on numpy 1.12.