You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / ma / core / round_

function

numpy.ma.core:round_

source: /numpy/ma/core.py :8081

Signature

def   round_ ( a decimals = 0 out = None )

Summary

Return a copy of a, rounded to 'decimals' places.

Extended Summary

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 and 'decimals' is greater than or equal to 0.

Parameters

decimals : int

Number of decimals to round to. May be negative.

out : array_like

Existing array to use for output. If not given, returns a default copy of a.

Notes

If out is given and does not have a mask attribute, the mask of a is lost!

Examples

import numpy as np
import numpy.ma as ma
x = [11.2, -3.973, 0.801, -1.41]
mask = [0, 0, 0, 1]
masked_x = ma.masked_array(x, mask)
masked_x
ma.round_(masked_x)
ma.round(masked_x, decimals=1)
ma.round_(masked_x, decimals=-1)

Aliases

  • numpy.ma.round