diff options
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r-- | numpy/core/fromnumeric.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 6cdf4e638..8fb9b6192 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -546,11 +546,30 @@ def size (a, axis=None): return asarray(a).shape[axis] def round_(a, decimals=0, out=None): - """Round 'a' to the given number of decimal places. Rounding - behaviour is equivalent to Python. + """Returns reference to result. Copies a and rounds to 'decimals' places. + + Keyword arguments: + decimals -- number of decimals to round to (default 0). May be negative. + out -- existing array to use for output (default copy of a). + + Return: + 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. + + The keyword 'out' may be used to specify a different array to hold the + result rather than the default copy of 'a'. If the type of the array + specified by 'out' differs from that of 'a', the result is cast to the new + type. + + Numpy rounds to even. Thus 1.5 and 2.5 round to 2, -0.5 and 0.5 round to 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. - Return 'a' if the array is not floating point. Round both the real - and imaginary parts separately if the array is complex. """ try: round = a.round |