[Numpy-discussion] MATLAB to Numpy

Robert Kern robert.kern at gmail.com
Fri Oct 27 12:26:06 EDT 2017


On Fri, Oct 27, 2017 at 9:16 AM, Benjamin Root <ben.v.root at gmail.com> wrote:
>
> In what way does it not work? Does it error out at the `arr = arr[mask]`
step? Or is it that something unexpected happens?
>
> I am guessing that you are trying to mutate the px, py, pz, w, x, y, z
arrays? If so, that for-loop won't do it. In python, a plain simple
assignment merely makes the variable point to a different object. It
doesn't mutate the object itself.

More specifically, it makes the name on the left-hand side point to the
object that's evaluated by the right-hand side. So this for loop is just
re-assigning objects to the name "arr". The names "px", "py", etc. are not
being reassigned. Here is a good article on how Python assignment works:

https://nedbatchelder.com/text/names.html

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20171027/67216f00/attachment.html>


More information about the NumPy-Discussion mailing list