cf.CellMeasure.round

CellMeasure.round(*args, **kwargs)[source]

Round the data to the given number of decimals.

Values exactly halfway between rounded decimal values are rounded 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. Results may also be surprising due to the inexact representation of decimal fractions in the IEEE floating point standard and errors introduced when scaling by powers of ten.

New in version 1.1.4.

See also

ceil, floor, rint, trunc

Parameters
decimals: int, optional

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

inplace: bool, optional

If True then do the operation in-place and return None.

i: deprecated at version 3.0.0

Use the inplace parameter instead.

Returns
CellMeasure or None

The construct with rounded data. If the operation was in-place then None is returned.

Examples

>>> print(f.array)
[-1.81, -1.41, -1.01, -0.91,  0.09,  1.09,  1.19,  1.59,  1.99])
>>> print(f.round().array)
[-2., -1., -1., -1.,  0.,  1.,  1.,  2.,  2.]
>>> print(f.round(1).array)
[-1.8, -1.4, -1. , -0.9,  0.1,  1.1,  1.2,  1.6,  2. ]
>>> print(f.round(-1).array)
[-0., -0., -0., -0.,  0.,  0.,  0.,  0.,  0.]