[Numpy-discussion] NumPy Feature Request: Function to wrap angles to range [ 0, 2*pi] or [ -pi, pi ]

Eric Moore ewm at redtetrahedron.org
Wed Nov 25 00:33:47 EST 2020


On Tue, Nov 24, 2020 at 6:38 AM Daniele Nicolodi <daniele at grinta.net> wrote:

> On 24/11/2020 10:25, Thomas wrote:
> > Like Nathaniel said, it would not improve much when compared to the
> > modulo operator.
> >
> > It could handle the edge cases better, but really the biggest benefit
> > would be that it is more convenient.
>
> Which edge cases? Better how?
>
> > And as the "unwrap" function already exists,
>
> The unwrap() function exists because it is not as trivial.
>
> > people would expect that
> > and look for a function for the inverse operation (at least I did).
>
> What is your use of a wrap() function? I cannot think of any.
>
> Cheers,
> Dan
>


For what it’s worth, this kind of range reduction  can be extremely
nontrivial depending on the needs of your application.   Look at the
efforts needed to ensure that the trigonometric functions give good
results. This is discussed in this paper:
https://www.csee.umbc.edu/~phatak/645/supl/Ng-ArgReduction.pdf.

I don’t think that this belongs in Numpy, but it certainly isn’t a one
liner.

Best,

Eric



>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/numpy-discussion/attachments/20201125/4589593b/attachment-0001.html>


More information about the NumPy-Discussion mailing list