[Numpy-discussion] rounding all element of an array with more than 1d
nwagner at iam.uni-stuttgart.de
Mon Jan 15 02:36:38 CST 2007
Giorgio Luciano wrote:
> I've posted also to scipy group but with no luck.
> At first I thought it was an easy task but...
> I've to round the numbers inside of a 2d array but nothing seems to
> work. the only message I've found in the archive is an old function
> custom made for doing that.. wouldn't be useful to have it also included
> something that do this task in numpy ?
> here's and example of the error using round
> Traceback (most recent call last):
> File "<pyshell#25>", line 1, in <module>
> TypeError: only length-1 arrays can be converted to Python scalars
> Any feedback appreciated
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
>>> a = random.rand(2,4)
array([[ 0.88084812, 0.03112202, 0.72374646, 0.76379529],
[ 0.20978501, 0.2647247 , 0.12690806, 0.78367502]])
array([[ 1., 0., 1., 1.],
[ 0., 0., 0., 1.]])
More information about the Numpy-discussion