-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
ENH: Translate sph_harm
Cython->C++, add sph_harm_all
gufunc
#20438
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
Not related to this PR but I think we must address this folder and file naming scheme before it is too late and before it starts to require massive amount of work to iron out. I am already completely lost in terms of what is in which file just to review things. Let's do it after this PR if possible. |
Totally agree on this. I think our general plan is to group functions by family (e.g. |
I think two steps we can take are:
This will help us get away from the confusing |
We can at least get the top level files in order, by what they do. Currently everything is We can use things like
and so on, in other words call them by what they are doing. Also under special/special the header file names are identical to the library header only files |
I think having a name for the C++ library will help with that, so that if the library is called Also, I don’t think anyone likes things Restructuring things sounds like a good next step. I completely agree that things are a bit of a mess now. |
Right, I've added one more thing to this PR. A gufunc called More generally, a lot of the special functions in SciPy actually need to compute a sequence or table of values to return the result. Examples include the Legendre functions, the spherical harmonics, the Bessel functions, and so on. In many cases, what is wanted is the whole set of values, not just a single selection. For instance, this issue #19079 (comment) has asked for exactly this for the Bessel functions. Sometimes, though, a selection is desired too. We are now in a position where we can provide these things relatively easily by exposing them as generalised ufuncs. This PR only intends to do so for I've used the subscript Other subscript options besides |
This PR is actually done. But there needs to be a bit of discussion about how to name things above. And there needs to be a bit of implementation thought on what to do about functions like Edit: There's also a question of whether |
I am one of them. Though we could also have done this
Can the current |
Unfortunately, no, I don't think so. The current I think the behaviour of the existing |
The shapes are not that important, the number of output args and their type is essential so that we don't break anything. Also |
Right, I've updated this PR so |
Just to be clear, what I was wondering is whether this |
It could be done by adding an appropriate keyword to Edit. A potential downside of this is that the existing |
sph_harm
Cython->C++, add sph_harm_all
gufunc
Ah yes, good point. Then a single signature is even more important to keep the API surface small. |
OK, this actually is used. I even found a comment where I referred to it, demonstrating that I was once aware of its purpose. The wrappers in
but on
I think we can't just drop the |
Right, but we just need that behaviour? I can make that happen in the extension module. |
Yes, you just need to raise the |
@izaid, once the from scipy.special._gufuncs import _sph_harm_all and it gets a docstring which says "Private function. This may be removed or modified at any time.") |
All done. It has become |
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'm happy with this now and feel it's safe to merge since nothing has been added to the public API. Let's start a discussion for establishing a consistent convention for gufunc versions of existing functions like this.
This PR translates
sph_harm
from Cython to C++. It was reasonably straightforward.As usual, I discovered some unexpected things going on. For instance, we still support passing
double
m
andn
which then get casted to integers. I maintained this behaviour.Something else I found is
sph_harmonic_unsafe
in_legacy.pxd
, see https://github.com/scipy/scipy/blob/main/scipy/special/_legacy.pxd#L39. This isn't public facing or part of any API, so can we just delete it?cc @steppi