Skip to content

[MRG+1] Disable cython checks in _centers_sparse #6677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2016

Conversation

MechCoder
Copy link
Member

@MechCoder MechCoder commented Apr 19, 2016

  • Check that negative indices, out of bound checks or division by zero cannot happen anywhere in the Cython code.

@jnothman
Copy link
Member

Bounds checks and wraparound checks can be removed ONLY IF the code will otherwise never try to take advantage of those Python indexing features (i.e. boundscheck: x[i] for i > len(x) triggers IndexError; wraparound: x[i] for -len(x) <= i < 0 returns x[len(i) - i]). So you have to look through when indexing is performed in the code, assess what the indices are (where they get their values) and if for expression x[i], i can ever be <0 or >=len(x) for any data that may be passed to the function in question.

You can, for instance, perform more validation outside this function if necessary to avoid those possibilities.

Have you made this check?

@MechCoder
Copy link
Member Author

I am perfectly aware of that hence added it to the Todo yesterday

@MechCoder
Copy link
Member Author

MechCoder commented Apr 19, 2016

I think I have commented that I have added the cython checks without elaborating on whether or not I did the "index checking" which I believe that is the source of confusion. Apologies.

@MechCoder
Copy link
Member Author

Ok, I went through the code and I'm convinced that the things in the TODO can never happen, assuming that _centers_sparse is not used directly by anyone, giving labels as a non encoded array.

@MechCoder
Copy link
Member Author

@ogrisel @TomDLT Quick look?

@MechCoder MechCoder changed the title Disable cython checks in _centers_sparse [MRG] Disable cython checks in _centers_sparse Apr 26, 2016
@jnothman
Copy link
Member

I agree this looks safe. +1

@jnothman jnothman changed the title [MRG] Disable cython checks in _centers_sparse [MRG+1] Disable cython checks in _centers_sparse Apr 27, 2016
@amueller
Copy link
Member

amueller commented May 7, 2016

LGTM.

@amueller amueller merged commit 294ee9d into scikit-learn:master May 7, 2016
@MechCoder MechCoder deleted the remove_checks_sparse branch May 8, 2016 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants