One way would be
```
px, py, pz, w, x, y, z = [arr[mask] for arr in px, py, pz, w, x, y, z]
```
-- Marten
___
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion
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
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"
wrote:
> Thank you so much, the solution was much simpler than I expected!
>
> On
Thank you so much, the solution was much simpler than I expected!
On Sat, 21 Oct 2017 23:04:43 +0200, Daπid wrote:
> On 21 October 2017 at 22:32, Eric Wieser
> wrote:
>
> > David, that doesn’t work, because np.cumsum(mask)[mask] is always equal
> > to np.arange(mask.sum()) + 1. Robert’s answer
On 21 October 2017 at 22:32, Eric Wieser
wrote:
> David, that doesn’t work, because np.cumsum(mask)[mask] is always equal
> to np.arange(mask.sum()) + 1. Robert’s answer is correct.
>
Of course, you are right. It makes sense in my head now.
___
NumPy-Di
David, that doesn’t work, because np.cumsum(mask)[mask] is always
equal to np.arange(mask.sum())
+ 1. Robert’s answer is correct.
Eric
On Sat, 21 Oct 2017 at 13:12 Daπid wrote:
On 21 October 2017 at 21:03, Robert Kern wrote:
>
>> Index with a boolean mask.
>>
>> mask = (tmp_px > 2)
>> px = tmp
On 21 October 2017 at 21:03, Robert Kern wrote:
> Index with a boolean mask.
>
> mask = (tmp_px > 2)
> px = tmp_px[mask]
> py = tmp_py[mask]
> # ... etc.
>
>
That isn't equivalent, note that j only increases when tmp_px > 2. I think
you can do it with something like:
mask = tmp_px > 2
j_values =
On Sat, Oct 21, 2017 at 10:45 AM, Andrei Berceanu
wrote:
>
> Hi,
>
> I am new to Numpy, and would like to start by translating a (badly
written?) piece of MATLAB code.
> What I have come up with so far is this:
>
> px = np.zeros_like(tmp_px); py = np.zeros_like(tmp_py); pz =
np.zeros_like(tmp_pz)
Can your provide representative examples for tmp_p[x|y|z]?
-paul
On Sat, Oct 21, 2017 at 10:45 AM, Andrei Berceanu
wrote:
> Hi,
>
> I am new to Numpy, and would like to start by translating a (badly
> written?) piece of MATLAB code.
> What I have come up with so far is this:
>
> px = np.zeros_li
Hi,
I am new to Numpy, and would like to start by translating a (badly written?)
piece of MATLAB code.
What I have come up with so far is this:
px = np.zeros_like(tmp_px); py = np.zeros_like(tmp_py); pz =
np.zeros_like(tmp_pz)
w = np.zeros_like(tmp_w)
x = np.zeros_like(tmp_x); y = np.zeros_lik
10 matches
Mail list logo