dask 2021.10.0

NotesParametersReturnsBackRef
around(x, decimals=0)

This docstring was copied from numpy.around.

Some inconsistencies with the Dask version may exist.

Notes

For values exactly halfway between rounded decimal values, NumPy rounds to the nearest even value. Thus 1.5 and 2.5 round to 2.0, -0.5 and 0.5 round to 0.0, etc.

np.around uses a fast but sometimes inexact algorithm to round floating-point datatypes. For positive :None:None:`decimals` it is equivalent to np.true_divide(np.rint(a * 10**decimals), 10**decimals) , which has error due to the inexact representation of decimal fractions in the IEEE floating point standard and errors introduced when scaling by powers of ten. For instance, note the extra "1" in the following:

>>> np.round(56294995342131.5, 3)  # doctest: +SKIP
56294995342131.51

If your goal is to print such values with a fixed number of decimals, it is preferable to use numpy's float printing routines to limit the number of printed decimals:

>>> np.format_float_positional(56294995342131.5, precision=3)  # doctest: +SKIP
'56294995342131.5'

The float printing routines use an accurate but much more computationally demanding algorithm to compute the number of digits after the decimal point.

Alternatively, Python's builtin round function uses a more accurate but slower algorithm for 64-bit floating point values:

>>> round(56294995342131.5, 3)  # doctest: +SKIP
56294995342131.5
>>> np.round(16.055, 2), round(16.055, 2)  # equals 16.0549999999999997  # doctest: +SKIP
(16.06, 16.05)

Parameters

a : array_like (Not supported in Dask)

Input data.

decimals : int, optional

Number of decimal places to round to (default: 0). If decimals is negative, it specifies the number of positions to the left of the decimal point.

out : ndarray, optional (Not supported in Dask)

Alternative output array in which to place the result. It must have the same shape as the expected output, but the type of the output values will be cast if necessary. See ufuncs-output-type for more details.

Returns

rounded_array : ndarray

An array of the same type as a, containing the rounded values. Unless :None:None:`out` was specified, a new array is created. A reference to the result is returned.

The real and imaginary parts of complex numbers are rounded separately. The result of rounding a float is a float.

Evenly round to the given number of decimals.

See Also

ceil
fix
floor
ndarray.round

equivalent method

rint
trunc

Examples

This example is valid syntax, but we were not able to check execution
>>> np.around([0.37, 1.64])  # doctest: +SKIP
array([0., 2.])
This example is valid syntax, but we were not able to check execution
>>> np.around([0.37, 1.64], decimals=1)  # doctest: +SKIP
array([0.4, 1.6])
This example is valid syntax, but we were not able to check execution
>>> np.around([.5, 1.5, 2.5, 3.5, 4.5]) # rounds to nearest even value  # doctest: +SKIP
array([0., 2., 2., 4., 4.])
This example is valid syntax, but we were not able to check execution
>>> np.around([1,2,3,11], decimals=1) # ndarray of ints is returned  # doctest: +SKIP
array([ 1,  2,  3, 11])
This example is valid syntax, but we were not able to check execution
>>> np.around([1,2,3,11], decimals=-1)  # doctest: +SKIP
array([ 0,  0,  0, 10])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

dask.array.routines.round

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/routines.py#1935
type: <class 'function'>
Commit: