<div dir="ltr"><div>Hello everyone,</div><div><br></div>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:<div><br></div><div>####</div><div><div>import numpy as np</div><div>from numpy.testing import assert_array_almost_equal_nulp</div><div>np.set_printoptions(precision=50)</div></div><div><br></div><div><div>x = np.array([1., 1e-10, 1e-20])</div><div>eps = np.finfo(x.dtype).eps</div><div>y = x*eps + x # y must be larger than x</div></div><div>####</div><div><br></div><div>[In]: np.abs(x-y) <= np.spacing(y)</div><div>[Out]: array([ True, False,  True], dtype=bool)</div><div><br></div><div>[In]: np.spacing(y)</div><div>[Out]: array([  2.22044604925031308084726333618164062500000000000000e-16,</div><div>         1.29246970711410574198657608135931695869658142328262e-26,</div><div>         1.50463276905252801019998276764447446760789191266827e-36])</div><div><br></div><div>[In]: np.abs(x-y)</div><div>[Out]: array([  2.22044604925031308084726333618164062500000000000000e-16,</div><div>         2.58493941422821148397315216271863391739316284656525e-26,</div><div>         1.50463276905252801019998276764447446760789191266827e-36])</div><div><br></div><div>####</div><div><br></div><div>I guess I'm a little confused about how the spacing values are calculated. My expectation is that the first logical test should give an output array where all of the results are the same. But it is also very likely that I don't have any idea what's going on. Can someone provide some clarification? </div><div><br></div><div>Thanks</div><div><br></div><div>Ryan</div><div><br></div><div><br></div></div>