On 25 Nov 2012, at 00:29, numpy-discussion-requ...@scipy.org wrote:
>
> Message: 3
> Date: Sat, 24 Nov 2012 23:23:36 +0100
> From: Da?id
> Subject: Re: [Numpy-discussion] numpy where function on different
> sized arrays
> To: Discussion of Numerical
On Sat, Nov 24, 2012 at 7:08 PM, David Warde-Farley <
d.warde.far...@gmail.com> wrote:
> I think that would lose information as to which value in B was at each
> position. I think you want:
>
>
(premature send, stupid Gmail...)
idx = {}
for i, x in enumerate(a):
for j, y in enumerate(x):
I think that would lose information as to which value in B was at each
position. I think you want:
On Sat, Nov 24, 2012 at 5:23 PM, Daπid wrote:
> A pure Python approach could be:
>
> for i, x in enumerate(a):
> for j, y in enumerate(x):
> if y in b:
>
A pure Python approach could be:
for i, x in enumerate(a):
for j, y in enumerate(x):
if y in b:
idx.append((i,j))
Of course, it is slow if the arrays are large, but it is very
readable, and probably very fast if cythonised.
David.
On Sat, Nov 24,
M = A[..., np.newaxis] == B
will give you a 40x60x20 boolean 3d-array where M[..., i] gives you a
boolean mask for all the occurrences of B[i] in A.
If you wanted all the (i, j) pairs for each value in B, you could do
something like
import numpy as np
from itertools import izip, groupby
from ope
Hi all
This must have been answered in the past but my google search capabilities are
not the best.
Given an array A say of dimension 40x60 and given another array/vector B of
dimension 20 (the values in B occur only once).
What I would like to do is the following which of course does not w