On Sun, Nov 22, 2009 at 10:47 AM, <josef.p...@gmail.com> wrote: > On Sun, Nov 22, 2009 at 10:37 AM, <josef.p...@gmail.com> wrote: >> On Sun, Nov 22, 2009 at 10:25 AM, David Cournapeau <courn...@gmail.com> >> wrote: >>> On Mon, Nov 23, 2009 at 12:14 AM, <josef.p...@gmail.com> wrote: >>>> On Sun, Nov 22, 2009 at 10:01 AM, David Cournapeau <courn...@gmail.com> >>>> wrote: >>>>> On Sun, Nov 22, 2009 at 11:45 PM, Charles R Harris >>>>> <charlesr.har...@gmail.com> wrote: >>>>>> >>>>>> Might be nice to print out the actual values of np.spacing and >>>>>> np.nextafter >>>>>> here. >>>>>> >>>>> >>>>> Yes, I should add some utilities to print those for this kind of test. >>>>> But in this case, I know the problem: mingw gcc use 80 bits long >>>>> double but it uses the MS runtime which considers double and long >>>>> double to be the same (8 bytes). >>>>> >>>>> I think the real fix is to force npy_longdouble to be double on mingw, >>>>> but I don't want to make that change now for 1.4.0. >>>> >>>> adding the failing type in the test to the failure message would also >>>> be helpful >>> >>> Yes, you're right. I also used the nose facility for using generators >>> for complex corner cases, but with retrospect, it is not so useful, >>> because you don't get a name when you have a failure (or maybe I am >>> using it wrong). >> >> I don't know what the policy for the use of assert in numpy is, >> but if you use the function np.testing.assert_ then you can add a >> failure message with eg. repr(t) >> >> With "yield check_a_function arguments" nose prints the arguments >> in the test description, putting information into the arguments gets >> then displayed. This is also useful for arguments that the check >> function doesn't really need. > > example: > > I change the test to this, then the new test failure output is as below > > def test_spacing(): > for t in [np.float32, np.float64, np.longdouble]: > one = t(1) > eps = np.finfo(t).eps > nan = t(np.nan) > inf = t(np.inf) > assert_(np.spacing(one) == eps, repr(t)) > assert_(np.isnan(np.spacing(nan)), repr(t)) > assert_(np.isnan(np.spacing(inf)), repr(t)) > assert_(np.isnan(np.spacing(-inf)), repr(t)) > > > ====================================================================== > FAIL: test_umath.test_spacing > ---------------------------------------------------------------------- > Traceback (most recent call last): > File > "c:\programs\python25\lib\site-packages\nose-0.11.1-py2.5.egg\nose\case.p > y", line 183, in runTest > self.test(*self.arg) > File > "C:\Josef\_progs\Subversion\numpy-trunk\dist\numpy-1.4.0.dev7758.win32\Pr > ograms\Python25\Lib\site-packages\numpy\core\tests\test_umath.py", line 863, > in > test_spacing > assert_(np.spacing(one) == eps, repr(t)) > File "\Programs\Python25\Lib\site-packages\numpy\testing\utils.py", line 33, > i > n assert_ > AssertionError: <type 'numpy.float96'>
or something like this to also get the values of the failing assertion def test_spacing(): for t in [np.float32, np.float64, np.longdouble]: one = t(1) eps = np.finfo(t).eps nan = t(np.nan) inf = t(np.inf) msg = '%r %r == %r' % (t, np.spacing(one), eps) assert_(np.spacing(one) == eps, msg) #assert_(np.spacing(one) == eps, repr(t)+ repr(np.spacing(one))+repr(eps)) assert_(np.isnan(np.spacing(nan)), repr(t)+ repr(np.spacing(nan))) assert_(np.isnan(np.spacing(inf)), repr(t)+ repr(np.spacing(inf))) assert_(np.isnan(np.spacing(-inf)), repr(t)+ repr(np.spacing(-inf))) Josef > > Josef > >> Josef >> >>> >>> David >>> _______________________________________________ >>> NumPy-Discussion mailing list >>> NumPy-Discussion@scipy.org >>> http://mail.scipy.org/mailman/listinfo/numpy-discussion >>> >> > _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion