Mercurial > hg > octave-lyh
changeset 17136:f72ffae1fcc3
delaunay.m: Fixed matlab compatibility and input check for single matrix (bug #39644)
* scripts/geometry/delaunay.m: check for equal size of X and Y, check for 2 column single matrix input, added 2 tests for these two changes
author | Andreas Weber <andreas.weber@hs-offenburg.de> |
---|---|
date | Thu, 01 Aug 2013 15:16:14 +0200 |
parents | ea19ea629a09 |
children | 04c3d56e007a |
files | scripts/geometry/delaunay.m |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/geometry/delaunay.m +++ b/scripts/geometry/delaunay.m @@ -75,7 +75,7 @@ switch (nargin) case 1 - if (! ismatrix (varargin{1}) && columns (varargin{1}) != 2) + if (! ismatrix (varargin{1}) || columns (varargin{1}) != 2) error ("delaunay: X must be a matrix with 2 columns"); else x = varargin{1}(:,1); @@ -109,7 +109,7 @@ endswitch - if (! (isvector (x) && isvector (y) && length (x) == length (y))) + if (! (isequal(size(x),size(y)))) error ("delaunay: X and Y must be the same size"); endif @@ -156,5 +156,13 @@ %! y = [0, 1, 0, -1, 0]; %! assert (sortrows (sort (delaunay (x, y), 2)), [1,2,5;1,4,5;2,3,5;3,4,5]); +%!testif HAVE_QHULL +%! x = [-1, 0; 0, 1; 1, 0; 0, -1; 0, 0]; +%! assert (sortrows (sort (delaunay (x), 2)), [1,2,5;1,4,5;2,3,5;3,4,5]); + +%!testif HAVE_QHULL +%! x = [1 5 2; 5 6 7]; +%! y = [5 7 8; 1 2 3]; +%! assert (sortrows (sort (delaunay (x, y), 2)), [1,2,4;1,3,4;1,3,5;3,4,6]); + %% FIXME: Need input validation tests -