[Numpy-discussion] MATLAB to Numpy
ben.v.root at gmail.com
Fri Oct 27 12:16:44 EDT 2017
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.
On Fri, Oct 27, 2017 at 11:43 AM, Andrei Berceanu <berceanu at runbox.com>
> Hmm, so how come this doesn't work now?
> mask = ((px > 2.) & ((py**2 + pz**2) / px**2 < 1.))
> for arr in (px, py, pz, w, x, y, z):
> arr = arr[mask]
> On Mon, 23 Oct 2017 15:05:26 +0200 (CEST), "Andrei Berceanu" <
> berceanu at runbox.com> wrote:
> > Thank you so much, the solution was much simpler than I expected!
> > On Sat, 21 Oct 2017 23:04:43 +0200, Daπid <davidmenhur at gmail.com> wrote:
> > > On 21 October 2017 at 22:32, Eric Wieser <wieser.eric+numpy at gmail.com>
> > > wrote:
> > >
> > > > David, that doesn’t work, because np.cumsum(mask)[mask] is always
> > > > to np.arange(mask.sum()) + 1. Robert’s answer is correct.
> > > >
> > > Of course, you are right. It makes sense in my head now.
> > > _______________________________________________
> > > NumPy-Discussion mailing list
> > > NumPy-Discussion at python.org
> > > https://mail.python.org/mailman/listinfo/numpy-discussion
> > _______________________________________________
> > NumPy-Discussion mailing list
> > NumPy-Discussion at python.org
> > https://mail.python.org/mailman/listinfo/numpy-discussion
> NumPy-Discussion mailing list
> NumPy-Discussion at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion