MCPcopy Index your code
hub / github.com/numpy/numpy / round_

Function round_

numpy/ma/core.py:8154–8209  ·  view source on GitHub ↗

Return a copy of a, rounded to 'decimals' places. .. deprecated:: 2.5 `numpy.ma.round_` is deprecated. Use `numpy.ma.round` instead. When 'decimals' is negative, it specifies the number of positions to the left of the decimal point. The real and imaginary parts of com

(a, decimals=0, out=None)

Source from the content-addressed store, hash-verified

8152
8153
8154def round_(a, decimals=0, out=None):
8155 """
8156 Return a copy of a, rounded to 'decimals' places.
8157
8158 .. deprecated:: 2.5
8159 `numpy.ma.round_` is deprecated. Use `numpy.ma.round` instead.
8160
8161 When 'decimals' is negative, it specifies the number of positions
8162 to the left of the decimal point. The real and imaginary parts of
8163 complex numbers are rounded separately. Nothing is done if the
8164 array is not of float type and 'decimals' is greater than or equal
8165 to 0.
8166
8167 Parameters
8168 ----------
8169 decimals : int
8170 Number of decimals to round to. May be negative.
8171 out : array_like
8172 Existing array to use for output.
8173 If not given, returns a default copy of a.
8174
8175 Notes
8176 -----
8177 If out is given and does not have a mask attribute, the mask of a
8178 is lost!
8179
8180 Examples
8181 --------
8182 >>> import numpy as np
8183 >>> import numpy.ma as ma
8184 >>> x = [11.2, -3.973, 0.801, -1.41]
8185 >>> mask = [0, 0, 0, 1]
8186 >>> masked_x = ma.masked_array(x, mask)
8187 >>> masked_x
8188 masked_array(data=[11.2, -3.973, 0.801, --],
8189 mask=[False, False, False, True],
8190 fill_value=1e+20)
8191 >>> ma.round_(masked_x)
8192 masked_array(data=[11.0, -4.0, 1.0, --],
8193 mask=[False, False, False, True],
8194 fill_value=1e+20)
8195 >>> ma.round(masked_x, decimals=1)
8196 masked_array(data=[11.2, -4.0, 0.8, --],
8197 mask=[False, False, False, True],
8198 fill_value=1e+20)
8199 >>> ma.round_(masked_x, decimals=-1)
8200 masked_array(data=[10.0, -0.0, 0.0, --],
8201 mask=[False, False, False, True],
8202 fill_value=1e+20)
8203 """
8204 warnings.warn(
8205 "numpy.ma.round_ is deprecated. Use numpy.ma.round instead.",
8206 DeprecationWarning,
8207 stacklevel=2,
8208 )
8209 return round(a, decimals, out)
8210
8211def _mask_propagate(a, axis):

Callers

nothing calls this directly

Calls 1

roundFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…