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?
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.])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With