Re: [Numpy-discussion] numpy.spacing question

2014-12-04 Thread Alok Singhal
On Thu, Dec 4, 2014 at 4:25 PM, Ryan Nelson wrote: > > I guess I'm a little confused about how the spacing values are calculated. np.spacing(x) is basically the same as np.nextafter(x, np.inf) - x, i.e., it returns the minimum positive number that can be added to x to get a number that's differen

Re: [Numpy-discussion] numpy.spacing question

2014-12-04 Thread Nathaniel Smith
It looks to me like spacing is calculating the 1ulp precision for each of your numbers, while x*eps is suffering from a tidge of rounding error and giving you 1-or-2 ulp precisions. Notice that the x*eps values are either equal to or twice the values returned by spacing. -n On Fri, Dec 5, 2014 at

[Numpy-discussion] numpy.spacing question

2014-12-04 Thread Ryan Nelson
Hello everyone, I was working through the example usage for the test function `assert_array_almost_equal_nulp`, and it brought up a question regarding the function `spacing`. Here's some example code: import numpy as np from numpy.testing import assert_array_almost_equal_nulp np.set_printopt

Re: [Numpy-discussion] slicing an n-dimensional array

2014-12-04 Thread Stefan van der Walt
On 2014-12-04 03:41:35, Jaime Fernández del Río wrote: > nx = np.arange(A.shape[0])[:, np.newaxis] > ny = np.arange(A.shape[1]) > C = A[nx, ny, B] That's the correct answer--in my answer I essentially wrote C = A[B] (== A[B, :, :]) which broadcasts the shape of B against the second and third di