[SciPy-user] round all element of an array
nkottens at nd.edu
Fri Jan 12 09:47:55 CST 2007
Giorgio Luciano wrote:
> I've searched in the manual and find nothing
> Is it possible to round all the value of an array to fixed decimanls ?
> The option round works for scalar but not for array
> Thanks in advance for replys
> SciPy-user mailing list
> SciPy-user at scipy.org
Base Class: <type 'function'> String Form: <function round_ at
0xb7a8f454> Namespace: Interactive
Definition: scipy.round_(a, decimals=0, out=None)
Returns reference to result. Copies a and rounds to 'decimals' places.
decimals -- number of decimal places to round to (default 0).
out -- existing array to use for output (default copy of a).
Reference to out, where None specifies a copy of the original
Round to the specified number of decimals. When 'decimals' is
specifies the number of positions to the left of the decimal point. The
real and imaginary parts of complex numbers are rounded separately.
Nothing is done if the array is not of float type and 'decimals' is
than or equal to 0.
The keyword 'out' may be used to specify a different array to hold the
result rather than the default 'a'. If the type of the array
'out' differs from that of 'a', the result is cast to the new type,
otherwise the original type is kept. Floats round to floats by default.
Numpy rounds to even. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5
0.0, etc. Results may also be surprising due to the inexact
of decimal fractions in IEEE floating point and the errors introduced in
scaling the numbers when 'decimals' is something other than 0.
The function around is an alias for round_.
More information about the SciPy-user