[Numpy-discussion] Changes to generalized ufunc core dimension checking

Nathaniel Smith njs at pobox.com
Thu Mar 17 17:21:21 EDT 2016

On Thu, Mar 17, 2016 at 2:04 PM, Feng Yu <rainwoodman at gmail.com> wrote:
> Hi,
> ang2pix is used in astronomy to pixelize coordinate in forms of
> (theta, phi). healpy is a binding of healpix
> (http://healpix.sourceforge.net/, introduction there too), plus a lot
> of more extra features or bloat (and I am not particular fond of this
> aspect of healpy). It gets the work done.
> You can think of the function ang2pix as nump.digitize for angular input.
> 'nside' and 'nest' controls the number of pixels and the ordering of
> pixels (since it is 2d to linear index).
> The important thing here is ang2pix is a pure function from (nside,
> nest, theta, phi) to pixelid, so in principle it can be written as a
> ufunc to extend the functionality to generate pixel ids for different
> nside and nest settings in the same function call.

Thanks for the details!

>From what you're saying, it sounds like ang2pix actually wouldn't care
either way about the gufunc broadcasting changes we're talking about.
When we talk about *g*eneralized ufuncs, we're referring to ufuncs
where the "core" minimal operation that gets looped over is already
intrinsically something that operates on arrays, not just scalars --
so operations like matrix multiply, sum, mean, mode, sort, etc., which
you might want to apply simultaneously to a whole bunch of arrays, and
the question is about how to handle these "inner" dimensions. In this
case it sounds like (nside, nest, theta, phi) are 4 scalars, right? So
this would just be a regular ufunc, and the whole issue doesn't arise.
Broadcast all you like :-)


Nathaniel J. Smith -- https://vorpus.org

More information about the NumPy-Discussion mailing list