Jon Harrop wrote: > Filip Wasilewski wrote: >> from numpy import ones, arange, reshape, int32 >> a = ones((2,3,4,5)) >> b = ones(a.shape, dtype=int32) >> c = ones((3,4,5)) >> d = 2*a + 2.5*(3*b + 3.3) >> d[0] = d[0] + 5 >> d[1] *= c * (2+3*1.2) >> d[:,2,...] = reshape(arange(d[:,2,...].size), d[:,2,...].shape) >> print d[...,1] > > I can't get that to work in Python. What do I need to do? > >>>> import numpy >>>> a = ones((2,3,4,5)) > Traceback (most recent call last): > File "<stdin>", line 1, in ? > NameError: name 'ones' is not defined
Use the code that Filip wrote: from numpy import ones, arange, reshape, int32 -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list