cf.AuxiliaryCoordinate.round¶

AuxiliaryCoordinate.
round
(*args, **kwargs)[source]¶ Round the data to the given number of decimals.
Data elements are evenly rounded to the given number of decimals.
Note
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.
 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.
 bounds:
bool
, optional If False then do not alter any bounds. By default any bounds are also altered.
 inplace:
bool
, optional If True then do the operation inplace and return
None
. i: deprecated at version 3.0.0
Use the inplace parameter instead.
 decimals:
 Returns
AuxiliaryCoordinate
orNone
The construct with rounded data. If the operation was inplace 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.]