[Numpy-discussion] round / set_printoptions discrepancy
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. ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] round / set_printoptions discrepancy
On 13/09/2019 14:05, Philip Hodge wrote: Isn't that just for consistency with Python 3 round()? I agree that the discrepancy with np.set_printoptions is not necessarily expected, except possibly for backwards compatibility. I've just checked and np.set_printoptions behaves as python's round: >>> round(16.055,2) 16.05 >>> np.round(16.055,2) 16.06 I don't know why round and np.round do not behave the same, actually I would even dare to say that I don't care :-) However np.round and np.set_printoptions should provide the same output, shouldn't they ? This discrepancy is really disturbing whereas consistency with python's round looks like the icing on the cake but in no way a required feature. -- Irvin ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] round / set_printoptions discrepancy
On 13/09/2019 15:26, Eric Moore wrote: See the notes section here. https://numpy.org/devdocs/reference/generated/numpy.around.html. This note was recently added in https://github.com/numpy/numpy/pull/14392 Thanks, it indeed explains the discrepancy. ___ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion