[SciPy-user] round all element of an array
Nicholas Kottenstette
nkottens at nd.edu
Fri Jan 12 10:47:55 EST 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
> Giorgio
>
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
>
?scipy.round_
Base Class: <type 'function'> String Form: <function round_ at
0xb7a8f454> Namespace: Interactive
File:
/usr/local/neclab_tools/lib/python2.4/site-packages/numpy/core/fromnumeric.py
Definition: scipy.round_(a, decimals=0, out=None)
Docstring:
Returns reference to result. Copies a and rounds to 'decimals' places.
Keyword arguments:
decimals -- number of decimal places to round to (default 0).
out -- existing array to use for output (default copy of a).
Returns:
Reference to out, where None specifies a copy of the original
array a.
Round to the specified number of decimals. When 'decimals' is
negative it
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
greater
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
specified by
'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
round to
0.0, etc. Results may also be surprising due to the inexact
representation
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_.
Sincerely,
Nicholas Kottenstette
More information about the SciPy-User
mailing list