MCPcopy
hub / github.com/numpy/numpy / round

Method round

numpy/ma/core.py:5570–5605  ·  view source on GitHub ↗

Return each element rounded to the given number of decimals. Refer to `numpy.around` for full documentation. See Also -------- numpy.ndarray.round : corresponding function for ndarrays numpy.around : equivalent function Examples ---

(self, decimals=0, out=None)

Source from the content-addressed store, hash-verified

5568 return dvar
5569
5570 def round(self, decimals=0, out=None):
5571 """
5572 Return each element rounded to the given number of decimals.
5573
5574 Refer to `numpy.around` for full documentation.
5575
5576 See Also
5577 --------
5578 numpy.ndarray.round : corresponding function for ndarrays
5579 numpy.around : equivalent function
5580
5581 Examples
5582 --------
5583 >>> import numpy as np
5584 >>> import numpy.ma as ma
5585 >>> x = ma.array([1.35, 2.5, 1.5, 1.75, 2.25, 2.75],
5586 ... mask=[0, 0, 0, 1, 0, 0])
5587 >>> ma.round(x)
5588 masked_array(data=[1.0, 2.0, 2.0, --, 2.0, 3.0],
5589 mask=[False, False, False, True, False, False],
5590 fill_value=1e+20)
5591
5592 """
5593 result = self._data.round(decimals=decimals, out=out).view(type(self))
5594 if result.ndim > 0:
5595 result._mask = self._mask
5596 result._update_from(self)
5597 elif self._mask:
5598 # Return masked when the scalar is masked
5599 result = masked
5600 # No explicit output: we're done
5601 if out is None:
5602 return result
5603 if isinstance(out, MaskedArray):
5604 out.__setmask__(self._mask)
5605 return out
5606
5607 def argsort(self, axis=np._NoValue, kind=None, order=None, endwith=True,
5608 fill_value=None, *, stable=False, descending=False):

Callers 15

performance.pyFile · 0.80
test_attributesMethod · 0.80
check_roundMethod · 0.80
test_round_copiesMethod · 0.80
test_roundMethod · 0.80
_round_if_neededFunction · 0.80
_as_pairsFunction · 0.80
test_scott_vs_stoneMethod · 0.80
ndarray_misc.pyFile · 0.80
roundFunction · 0.80
test_2dMethod · 0.80

Calls 3

_update_fromMethod · 0.80
__setmask__Method · 0.80
viewMethod · 0.45

Tested by 11

test_attributesMethod · 0.64
check_roundMethod · 0.64
test_round_copiesMethod · 0.64
test_roundMethod · 0.64
test_scott_vs_stoneMethod · 0.64
test_2dMethod · 0.64
test_roundMethod · 0.64