-
-
Notifications
You must be signed in to change notification settings - Fork 11k
MANT: refactor unravel_index for code repetition #13446
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
Conversation
npy_intp tmp = val / unravel_dims[idx]; | ||
coords[idx] = val % unravel_dims[idx]; | ||
val = tmp; | ||
idx += idx_step; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The diff looks a big, but the actual changes really seem very small. Just checked and the tests seem OK here, can only find some style nitpicks right now.
Would merge in a bit, unless someone wants to have another glance or wants me to look closer again.
Co-Authored-By: mattip <[email protected]>
Co-Authored-By: mattip <[email protected]>
I used the "accept suggested changes" feature but now the PR has 3 commits, some with strange messages. Probably need to squash-merge |
Hmmm, so the feature is not perfect ;) (but there is not much it can do I guess, except possibly auto-squash multiple suggestions)... Will have another quick pass after lunch and wait |
Thanks Matti, and of course also Jaime! |
* master: (25 commits) BUG: fix unravel_index when dimension is greater than 'intp' MANT: refactor unravel_index for code repetition (numpy#13446) BLD, TST: implicit func errors DOC: document existance of linalg backends BLD: streamlined library names in site.cfg sections (numpy#13157) MAINT: fixed typo 'wtihout' from numpy/core/shape_base.py BUG: fixing bugs in AVX exp/log while handling special value floats (numpy#13415) update sequence Add analysis check BUG: blindly add TypeError to accepted exceptions MAINT: fixed several PYTHONOPTIMIZE=2 failures BUG: fixed PYTHONOPTIMIZE run MAINT: fixed typo 'Mismacth' from numpy.core.setup_common.py MAINT: fixed last issues and questions according to numpy#13132 MAINT: improve efficiency of pad by avoiding use of apply_along_axis DOC: dimension sizes are non-negative, not positive BUILD, BUG: fix from review, fix bug in git_version MAINT: mention 'make dist' in error messsage BUILD: allow version-check to pass if GITVER is Unknown (sdist build) BUILD: fail documentation build if numpy version does not match ...
Replaces #6219 which opened with the comment
"Adding a little bit of extra accounting in the inner loop allows joining the two specialized branches into a single one. The performance loss, if any, is within the measurement error."
Additional comments were integrated into this PR, including a nice little compiler optimization for getting the quotient and remainder with a single divide (thanks godbolt )
@seberg asked for a better error to be raised, which was already implemented.
I made a new PR since I could not push the rebase to @jaimefrio 's repo. Of course we only need one of these, @jaimefrio if you wish to move forward on it feel free to close this one.