octave-patch-tracker
[Top][All Lists]
Advanced

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

[Octave-patch-tracker] [patch #8119] Allow variable tolerance and improv


From: Rik
Subject: [Octave-patch-tracker] [patch #8119] Allow variable tolerance and improve error messages for assert.m script
Date: Wed, 07 Aug 2013 00:31:37 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:22.0) Gecko/20100101 Firefox/22.0

Follow-up Comment #11, patch #8119 (project octave):

This is getting there.  I can see a few more improvements.

1) Instead of simply saying the dimensions don't match we could actually list
them.  Sample format would be "1x3x5".  The following code will create this
format.


dimstr = sprintf ("%dx", size (cond));
dimstr(end) = []; # remove trailing 'x'


2) Absolute error uses the expression "Exceeds abs tol 0 by ..." while
relative tolerance uses "Max rel err %g exceeds tol %g".  They should both use
the same format whatever it is.

3) Multi-dimensional arrays aren't handled properly.


x = zeros (2,2,3);
y = x;
y(1,2,3) = 1;
assert (x,y)
error: ASSERT errors for:  assert (x,y)

  Location  |  Observed  |  Expected  |  Reason
   [1,6]          0            1         Exceeds abs tol 0 by 1


It's kind of lame, but I think you can use sub2ind to do this.


erridx = find (x != y);  
if (any (erridx))
  sz = size (x);
  nd = ndims (x);
  subs = cell (1, nd);
  for idx = erridx(:).'
    [subs{:}] = ind2sub (sz, idx);
    loc = ['(' sprintf("%d,", subs{:}) ];
    loc(end) = ')';
    ... print location and error ...
  endfor
endif




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/patch/?8119>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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