[Numpy-discussion] round / set_printoptions discrepancy

Irvin Probst irvin.probst at ensta-bretagne.fr
Fri Sep 13 06:48:55 EDT 2019


Hi,
Is it expected/documented that np.round and np.set_printoptions do not 
output the same result on screen ?
I tumbled into this running this code:

import numpy as np
mes = np.array([
     [16.06, 16.13, 16.06, 16.00, 16.06, 16.00, 16.13, 16.00]
])

avg = np.mean(mes, axis=1)
print(np.round(avg, 2))
np.set_printoptions(precision=2)
print(avg)


Which outputs:

[16.06]
[16.05]

Is that worth a bug report or did I miss something ? I've been able to 
reproduce this on many windows/linux PCs with python/numpy releases from 
2017 up to last week.

Thanks.


More information about the NumPy-Discussion mailing list