n0 = 5 # number of rows
B = np.ones((n0,3))*np.arange(3)
A = np.random.randint(3,size=(n0,3))
C = B[np.arange(n0)[:,None],A]
assert (A == C).all()
A
> array([[2, 0, 1],
>[2, 0, 1],
>[2, 1, 2],
>[0, 0, 2],
>[2, 0, 0]])
C
> array([[
On Wed, Mar 17, 2010 at 9:36 AM, Miroslav Sedivy
wrote:
> josef.p...@gmail.com wrote:
>> On Wed, Mar 17, 2010 at 7:12 AM, Miroslav Sedivy wrote:
>>> There are two 2D arrays with dimensions: A[1,1000] and B[1,100].
>>> The first dimension of both arrays corresponds to a list of 1 object
josef.p...@gmail.com wrote:
> On Wed, Mar 17, 2010 at 7:12 AM, Miroslav Sedivy wrote:
>> There are two 2D arrays with dimensions: A[1,1000] and B[1,100].
>> The first dimension of both arrays corresponds to a list of 1 objects.
>>
>> The array A contains for each of 1 objects 1000 i
On Wed, Mar 17, 2010 at 7:12 AM, Miroslav Sedivy
wrote:
> Hello,
>
> being quite new to NumPy and having used previously PDL in Perl, I am
> currently migrating one of my PDL projects into NumPy.
>
> Most of the functions can be migrated without problems and there are
> functions in NumPy that all
Hello,
being quite new to NumPy and having used previously PDL in Perl, I am
currently migrating one of my PDL projects into NumPy.
Most of the functions can be migrated without problems and there are
functions in NumPy that allow me to do things in much clearer way than
in PDL. However, I hav