[Numpy-discussion] arbitrary number of newaxis

Andrew Corrigan acorriga at gmu.edu
Mon Jul 3 07:36:53 CDT 2006

In a function I'm writing, I multiply two arrays together: A and B.  
where A.ndim == 2 and I don't know B.ndim in advance

If I knew B.ndim == 3,   then I would write    

or if I knew that B.ndim == 1  then I would write 

but I don't know B.ndim.  Essentially I want to say something like:
A[:,:,repeat(newaxis, B.ndim)]*B[newaxis,newaxis,...]

How can I express what I mean, such that it actually works?

More information about the Numpy-discussion mailing list