FIX, MAINT: Implement 'everything follows X' and namespace checks for KNN#3127
Conversation
|
/intelci: run |
|
/azp run Nightly |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
CI failures in BasicStatistics are unrelated to the changes here and should be solved with this PR: |
|
/intelci: run |
|
/azp run Nightly |
|
Azure Pipelines successfully started running 1 pipeline(s). |
efd866f to
1507c24
Compare
|
/azp run Nightly |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
/intelci: run |
| device = getattr(y_train, "device", None) | ||
| neigh_dist = xp.asarray(neigh_dist, device=device) | ||
| neigh_ind = xp.asarray(neigh_ind, device=device) | ||
| if not _is_numpy_namespace(xp): |
There was a problem hiding this comment.
What is the logic of this if-statement? As I understand it previously it was that neigh_dist and neigh_ind originally have numpy type and we only need to convert them if y is not a numpy. Is it correct? If yes do we need the same logic after the array-api update?
There was a problem hiding this comment.
This is how it was before if you look at the changes. I guess the purpose is to have them work with the other arrays.
| device = getattr(y_train, "device", None) | ||
| neigh_dist = xp.asarray(neigh_dist, device=device) | ||
| neigh_ind = xp.asarray(neigh_ind, device=device) | ||
| if not _is_numpy_namespace(xp): |
There was a problem hiding this comment.
I think we also need some explanation about why do we need this numpy check
There was a problem hiding this comment.
It has a different codepath for numpy with operations that are not supported by array API.
|
Left a few comments mostly related to clarification about the current logic. Also PR needs to be rebased to fix some CI failures |
895535d
into
uxlfoundation:main
Description
This PR:
.fit()in order to throw informative Python exceptions instead of segfaults, the same way scikit-learn would do.Includes the changes from #3117 since they are also necessary for KNN classes.
Checklist:
Completeness and readability
Testing