summaryrefslogtreecommitdiff
path: root/numpy/core/fromnumeric.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2006-09-04 17:06:31 +0000
committerCharles Harris <charlesr.harris@gmail.com>2006-09-04 17:06:31 +0000
commitcd71708a570b7eb770e54ba08ccbf7b414b26201 (patch)
tree32d3c4899f857f4be3dbd51b5037a16f3dd60dae /numpy/core/fromnumeric.py
parent2d72b34fb356c1f5440218123c06efd534555303 (diff)
downloadnumpy-cd71708a570b7eb770e54ba08ccbf7b414b26201.tar.gz
Add documentation to round and around to clear up confusion from numpy's choice
to round to even.
Diffstat (limited to 'numpy/core/fromnumeric.py')
-rw-r--r--numpy/core/fromnumeric.py27
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