Adding to an old discussion thread (see below) ... an implementation
of the proposed functionality:
from numpy import rollaxis
def moveaxis(a, i, j = 0):
"""
move axis i of array a to position j
"""
n = a.ndim
i = i if i >= 0 else i + n
if j > i:
return rollaxis(a,
, 2011 at 7:46 PM, Thomas Coffee wrote:
> Somewhat new to NumPy, but I've been investigating this for over an hour
> and found nothing helpful:
>
> Can anyone explain why this works ...
>
>
> >>> import numpy
> >>> numpy.fromfunction(lambda i, j: i*j,
Somewhat new to NumPy, but I've been investigating this for over an hour
and found nothing helpful:
Can anyone explain why this works ...
>>> import numpy
>>> numpy.fromfunction(lambda i, j: i*j, (3,4))
array([[ 0., 0., 0., 0.],
[ 0., 1., 2., 3.],
[ 0., 2., 4., 6.]])
...