octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: failing tests in tip


From: Jaroslav Hajek
Subject: Re: failing tests in tip
Date: Fri, 13 Mar 2009 16:50:07 +0100

On Fri, Mar 13, 2009 at 3:41 PM, John W. Eaton <address@hidden> wrote:
> On 13-Mar-2009, Jaroslav Hajek wrote:
>
> | my recent changes ("more indexing improvements") introduced a number
> | of failing tests in tip. These are caused by the fact that ones(1,n)
> | will now produce a range rather than matrix, thus giving an error when
> | compared against an equivalent matrix value by "assert".
> | Fixing the tests to use full(ones(..)) is trivial; however, maybe it's
> | time to loosen the testing in assert a little? I recall there were
> | similar problems with diagonal matrices. For instance, if both
> | arguments are numeric and neither of them is sparse, full() can be
> | first applied to them. There is, of course, the danger that such a
> | change may let escape something unintended.
> |
> | Opinions?
>
> I think the original intent was for assert to test exact equality,
> including object types.  But maybe we should only be doing that
> explicitly with something like assert (isequalwithequaltypes (a, b))
> (yeah, maybe it's not the best name to use for this function, but at
> least it is descriptive).  OTOH, it's not clear to me how many tests
> there are where we do want to require equal values and types.
>
> You can also force conversion to a matrix by doing [ones(1,n)], at
> least until you decide to optimize this too...  :-)
>
> jwe
>

I fixed those tests using "full". Still, my comment is valid - there
is no good way to test for
exact numeric equality. What about the following small patch? It seems
that this was the intention
after all, judging by the surrounding code.

cheers

-- 
RNDr. Jaroslav Hajek
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


# HG changeset patch
# User Jaroslav Hajek <address@hidden>
# Date 1236959387 -3600
# Node ID d4aa946efab7a9705cb78dd5175b56bc4e334b0b
# Parent  2e9af33636694e611a08e4f00c70c13491d180b7
have zero tolerance force numeric assert

diff --git a/scripts/testfun/assert.m b/scripts/testfun/assert.m
--- a/scripts/testfun/assert.m
+++ b/scripts/testfun/assert.m
@@ -141,7 +141,7 @@
       iserror = 1;
       coda = "Dimensions don't match";

-    elseif (tol == 0 && ! strcmp (typeinfo (cond), typeinfo (expected)))
+    elseif (nargin < 3 && ! strcmp (typeinfo (cond), typeinfo (expected)))
       iserror = 1;
       coda = cstrcat ("Type ", typeinfo (cond), " != ", typeinfo (expected));



reply via email to

[Prev in Thread] Current Thread [Next in Thread]