Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Allan Haldane
On 9/13/19 9:26 AM, 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 > > Eric Hmm, but this example with 16.055 shows the note still isn't quite right

Re: [Numpy-discussion] Code review for adding axis argument to permutation and shuffle function

2019-09-13 Thread Warren Weckesser
On 7/4/19, Kexuan Sun wrote: > Hi, > > I would like to request a code review. The random.permutation and > random.shuffle functions now can only shuffle along the first axis of a > multi-dimensional array. I propose to add an axis argument for the > functions and allow them to shuffle along a give

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Stefano Miccoli
In my opinion the problem is that numpy floats break the Liskov substitution principle, >>> pyfloat = 16.055 >>> npfloat = np.float64(pyfloat) >>> isinstance(npfloat, float) True >>> round(pyfloat, 2) 16.05 >>> round(npfloat, 2) 16.06 Since numpy.float64 is a subclass of builtins.float I would e

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Irvin Probst
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. _

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Eric Moore
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 Eric On Fri, Sep 13, 2019 at 9:20 AM Andras Deak wrote: > On Fri, Sep 13, 2019 at 2:59 PM Philip Hodge wrote: > > > > On 9/13/

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Andras Deak
On Fri, Sep 13, 2019 at 2:59 PM Philip Hodge wrote: > > On 9/13/19 8:45 AM, Irvin Probst wrote: > > 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, > >

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Philip Hodge
On 9/13/19 8:45 AM, Irvin Probst wrote: 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 n

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Irvin Probst
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 ro

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Philip Hodge
On 9/13/19 7:23 AM, Andras Deak wrote: I just want to add that you can use literal 16.055 to reproduce this: import numpy as np np.set_printoptions(precision=2) np.array([16.055]).round(2) array([16.06]) np.array([16.055]) array([16.05]) I would think it has to do with "round to nearest eve

Re: [Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Andras Deak
On Fri, Sep 13, 2019 at 12:58 PM Irvin Probst wrote: > > 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, 1

[Numpy-discussion] round / set_printoptions discrepancy

2019-09-13 Thread Irvin Probst
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

Re: [Numpy-discussion] Code review for adding axis argument to permutation and shuffle function

2019-09-13 Thread Matthew Brett
Hi, Thanks - yes - I agree, an axis argument seems like a very sensible idea. Cheers, Matthew On Fri, Sep 13, 2019 at 7:48 AM Juan Nunez-Iglesias wrote: > > I don’t understand why the proposal would be controversial in any way. It’s > very natural to have `axis=` keyword arguments in NumPy, a