Reputation: 4968
Per the docs I set the number of digits of precision for printing a numpy float to 8 and expected to see
1.12345679
from this code but did not:
import numpy as np
np.set_printoptions(precision=8)
x = np.float_(1.123456789)
print x
Upvotes: 1
Views: 14026
Reputation: 2236
As the comments have suggested you could use numpy.around.
import numpy as np
np.set_printoptions(precision=4)
x = np.float_(1.123456789)
print x
x = np.around(x, 8)
print x
This outputs:
1.123456789
1.12345679
Upvotes: 3