1

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,760
  • 7
  • 42
  • 61

1 Answers1

3

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
  • 2,118
  • 1
  • 16
  • 29