changeset 21223:f6aab24ed82e

maint: Periodic merge of stable to default.
author Rik <rik@octave.org>
date Mon, 08 Feb 2016 20:36:40 -0800
parents 6a73d6e36647 (current diff) 732ec49d1ec5 (diff)
children 2e64b5899d1f
files scripts/geometry/inpolygon.m scripts/image/gray2ind.m scripts/plot/draw/private/__stem__.m scripts/plot/draw/stem.m
diffstat 4 files changed, 38 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/geometry/inpolygon.m	Mon Feb 08 17:10:30 2016 -0800
+++ b/scripts/geometry/inpolygon.m	Mon Feb 08 20:36:40 2016 -0800
@@ -1,4 +1,4 @@
-## Copyright (C) 2006-2015 Frederick (Rick) A Niles
+## Copyright (C) 2006-2016 Frederick (Rick) A Niles
 ##               and Søren Hauberg
 ##
 ## This file is part of Octave.
@@ -48,9 +48,9 @@
     print_usage ();
   endif
 
-  if (! (isreal (x) && isreal (y) && ismatrix (y) && ismatrix (y)
+  if (! (isreal (x) && isreal (y) && isnumeric (x) && isnumeric (y)
          && size_equal (x, y)))
-    error ("inpolygon: X and Y must be real matrices of the same size");
+    error ("inpolygon: X and Y must be real arrays of the same size");
   elseif (! (isreal (xv) && isreal (yv) && isvector (xv) && isvector (yv)
              && size_equal (xv, yv)))
     error ("inpolygon: XV and YV must be real vectors of the same size");
@@ -140,14 +140,31 @@
 %! assert (in, [true, true, false]);
 %! assert (on, [true, false, false]);
 
+## 3D array input
+%!test
+%! x = zeros (2, 2, 2);
+%! x(1, 1, 1) = 1;
+%! x(2, 2, 2) = 2;
+%! y = zeros (2, 2, 2);
+%! y(1, 1, 1) = 1;
+%! y(2, 2, 2) = -1;
+%! [in, on] = inpolygon (x, y, [-1, -1, 1, 1], [-1, 1, 1, -1]);
+%! IN = true (2, 2, 2);
+%! IN(2, 2, 2) = false;
+%! ON = false (2, 2, 2);
+%! ON(1, 1, 1) = true;
+%! assert (in, IN);
+%! assert (on, ON);
+
 ## Test input validation
 %!error inpolygon ()
 %!error inpolygon (1, 2)
 %!error inpolygon (1, 2, 3)
 %!error inpolygon (1, 2, 3, 4, 5)
-%!error <X and Y must be real matrices> inpolygon (1i, 1, [3, 4], [5, 6])
-%!error <X and Y must be real matrices> inpolygon (1, {1}, [3, 4], [5, 6])
+%!error <X and Y must be real> inpolygon (1i, 1, [3, 4], [5, 6])
+%!error <X and Y must be real> inpolygon (1, {1}, [3, 4], [5, 6])
 %!error <X and Y must be .* the same size> inpolygon (1, [1,2], [3, 4], [5, 6])
+%!error <X and Y must be .* the same size> inpolygon (1, ones (1,1,2), [3, 4], [5, 6])
 %!error <XV and YV must be real vectors> inpolygon (1, 1, [3i, 4], [5, 6])
 %!error <XV and YV must be real vectors> inpolygon (1, 1, [3, 4], {5, 6})
 %!error <XV and YV must .* the same size> inpolygon ([1,2], [3, 4], [5, 6], 1)
--- a/scripts/image/gray2ind.m	Mon Feb 08 17:10:30 2016 -0800
+++ b/scripts/image/gray2ind.m	Mon Feb 08 20:36:40 2016 -0800
@@ -1,4 +1,4 @@
-## Copyright (C) 1994-2015 John W. Eaton
+## Copyright (C) 1994-2016 John W. Eaton
 ##
 ## This file is part of Octave.
 ##
@@ -41,12 +41,10 @@
 
   if (nargin < 1 || nargin > 2)
     print_usage ();
-  elseif (! isreal (I) || issparse (I))
+  elseif (! isreal (I) || issparse (I) || ! ismatrix(I))
     error ("gray2ind: I must be a grayscale or binary image");
   elseif (! isscalar (n) || n < 1 || n > 65536)
     error ("gray2ind: N must be a positive integer in the range [1, 65536]");
-  elseif (! ismatrix (I) || ndims (I) < 2)
-    error ("gray2ind: I must be a grayscale or binary image");
   endif
 
   ## default n is different if image is logical
@@ -110,6 +108,7 @@
 %!error <I must be a grayscale or binary image> gray2ind ({1})
 %!error <I must be a grayscale or binary image> gray2ind ([1+i])
 %!error <I must be a grayscale or binary image> gray2ind (sparse ([1]))
+%!error <I must be a grayscale or binary image> gray2ind (ones (2,2,3))
 %!error <N must be a positive integer> gray2ind (1, ones (2,2))
 %!error <N must be a positive integer> gray2ind (1, 0)
 %!error <N must be a positive integer> gray2ind (1, 65537)
--- a/scripts/plot/draw/private/__stem__.m	Mon Feb 08 17:10:30 2016 -0800
+++ b/scripts/plot/draw/private/__stem__.m	Mon Feb 08 20:36:40 2016 -0800
@@ -250,6 +250,8 @@
         x = 1:length (y);
       elseif (ismatrix (y))
         x = 1:rows (y);
+      else
+        error ("stem: Y must be a vector or 2-D array");
       endif
     endif
     if (! (isnumeric (x) || islogical (x))
--- a/scripts/plot/draw/stem.m	Mon Feb 08 17:10:30 2016 -0800
+++ b/scripts/plot/draw/stem.m	Mon Feb 08 20:36:40 2016 -0800
@@ -204,15 +204,6 @@
 %!   pause (0.2);
 %! end
 
-%!error stem ()
-%!error <can not define Z for 2-D stem plot> stem (1,2,3)
-%!error <X and Y must be numeric> stem ({1})
-%!error <X and Y must be numeric> stem (1, {1})
-%!error <inconsistent sizes for X and Y> stem (1:2, 1:3)
-%!error <inconsistent sizes for X and Y> stem (1:2, ones (3,3))
-%!error <inconsistent sizes for X and Y> stem (ones (2,2), ones (3,3))
-%!error <No value specified for property "FOO"> stem (1, "FOO")
-
 %!test
 %! ## stemseries share the same baseline and basevalue
 %! hf = figure ("visible", "off");
@@ -228,3 +219,14 @@
 %!   close (hf);
 %! end_unwind_protect
 
+## Test input validation
+%!error stem ()
+%!error <can not define Z for 2-D stem plot> stem (1,2,3)
+%!error <Y must be a vector or 2-D array> stem (ones (2,2,2))
+%!error <X and Y must be numeric> stem ({1})
+%!error <X and Y must be numeric> stem (1, {1})
+%!error <inconsistent sizes for X and Y> stem (1:2, 1:3)
+%!error <inconsistent sizes for X and Y> stem (1:2, ones (3,3))
+%!error <inconsistent sizes for X and Y> stem (ones (2,2), ones (3,3))
+%!error <No value specified for property "FOO"> stem (1, "FOO")
+