0

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
Terrence Brannon
  • 4,388
  • 6
  • 36
  • 61

1 Answers1

1

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
axwr
  • 1,856
  • 13
  • 27