-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
MAINT: interpolate: move an internal utility from cython to python #21539
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
The computational complexity is O(1), so there is no reason for this helper to stay in Cython or move to C++.
double[::1] wrk = np.empty(2*k+2, dtype=np.float64) | ||
|
||
# derivatives @ xval | ||
with nogil: |
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.
just for my understanding, could you explain the relationship between this with nogil
code and the Python translation?
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 code is precisely the same, modulo that in python it operates on numpy arrays and in cython it was taking typed memoryviews of arrays and operating on those.
And while it was in a with nogil
section, the is doing so little work that releasing the GIL is very unlikely to have any effect.
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.
LGTM!
# compute and fill in the derivatives @ xval | ||
for row in range(deriv_ords.shape[0]): | ||
nu = deriv_ords[row] | ||
wrk = _bspl.evaluate_all_bspl(t, k, xval, left, nu) |
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.
I did notice the use of this function instead of _deBoor_D
directly, but looks like that still gets called internally, so I don't see any obvious issues on my end either, and CI is happy.
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.
Yeah, evaluale_all_bspl
is a python-side wrapper of C-only _deBoor_D
. Both routines are non-public, so can probably unify the naming. Will think about it in the ongoing refactor of the internals (I've a branch, not PR-ready yet)
Thanks Evgeni, Lucas |
A follow-up to #21223, chipping small bits and pieces from a cython extension: move the
_handle_lhs_derivatives
helper from Cython to python. The code is basically pure numpy, and the computational complexity is O(1), so there is no reason for this helper to stay in Cython or move to C++.