Rounding values in a numpy array resulting from matrix calculation

matrix, numpy, python, rounding

Solution

NumPy arrays have a round method:

In [73]: x = np.array([1.33333, 2.56, 9.99999, 16.0])

In [74]: x.round()
Out[76]: array([  1.,   3.,  10.,  16.])

Problem

I have some calculation involving two matrices both represented in `numpy` arrays. After the calculation, i obtain a vector of `floats` represented in another `numpy` array. I want to round up/down the values in this resultant vector, e.g. if the calculation gives: ``` array([1.33333, 2.56, 9.99999, 16.0]) ``` then it should be rounded to: ``` array([1, 3, 10, 16]) ``` What is the fastest way to do this?

Original source