[SciPy-dev] Numpy example for arctan2 perhaps wrong/misleading/confusing?

David Huard david.huard at gmail.com
Mon Jun 9 09:56:02 EDT 2008


Hi Samuel,

One thing that you should know is that all "ufunc" (universal functions) are
defined as functions operating on scalars. Numpy then wraps these functions
such that they can process ndarrays of any shape element by element. This is
what is explained in the help(arctan2) documentation.

As for the example, maybe a way to avoid confusion would be to give an
example with scalar arguments first to show the basic behavior, and then an
example using ndarray broadcasting.

HTH,

David




2008/6/9 Samuel John <scipy at samueljohn.de>:

> Hi all,
>
> the page
>
>
> http://www.scipy.org/Numpy_Example_List_With_Doc#head-ad8dc60988f26f59ebe565e4af24dc95fcb8a7e9
>
> describes the numpy.arctan2 function and gives an example:
>
> > arctan2(array([0, 1]), array([1, 0]))
>
> However in the example there are used two arrays as arguments to
> arctan2, where it should probably be the x and y component of a single
> 2D vector. What arctan2(x,y) returns is the angle between the 2D
> vector (x,y) and the x axis. The example made me assume that it can
> compute the angle between two vectors, which it does obviously not.
>
> Wikipedia has a nice article on atan2. I think arctan2 works the same, or?
> http://en.wikipedia.org/wiki/Atan2
>
> What could be the reason of using arrays in arctan2? Could someone
> update the documentation?
> Also help(numpy.arctan2) is not very helpful, to be honest.
>
> cheers,
>  Samuel
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20080609/c7f37fc8/attachment.html>


More information about the SciPy-Dev mailing list