# HG changeset patch # User Rik # Date 1454992600 28800 # Node ID f6aab24ed82e5603df6e369ecb151db5d345caeb # Parent 6a73d6e3664701016c9cd9b1ce3c0ae8335aab47# Parent 732ec49d1ec5c5dd5332f8d2364f010514b4c5c2 maint: Periodic merge of stable to default. diff -r 6a73d6e36647 -r f6aab24ed82e scripts/geometry/inpolygon.m --- 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 inpolygon (1i, 1, [3, 4], [5, 6]) -%!error inpolygon (1, {1}, [3, 4], [5, 6]) +%!error inpolygon (1i, 1, [3, 4], [5, 6]) +%!error inpolygon (1, {1}, [3, 4], [5, 6]) %!error inpolygon (1, [1,2], [3, 4], [5, 6]) +%!error inpolygon (1, ones (1,1,2), [3, 4], [5, 6]) %!error inpolygon (1, 1, [3i, 4], [5, 6]) %!error inpolygon (1, 1, [3, 4], {5, 6}) %!error inpolygon ([1,2], [3, 4], [5, 6], 1) diff -r 6a73d6e36647 -r f6aab24ed82e scripts/image/gray2ind.m --- 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 gray2ind ({1}) %!error gray2ind ([1+i]) %!error gray2ind (sparse ([1])) +%!error gray2ind (ones (2,2,3)) %!error gray2ind (1, ones (2,2)) %!error gray2ind (1, 0) %!error gray2ind (1, 65537) diff -r 6a73d6e36647 -r f6aab24ed82e scripts/plot/draw/private/__stem__.m --- 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)) diff -r 6a73d6e36647 -r f6aab24ed82e scripts/plot/draw/stem.m --- 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 stem (1,2,3) -%!error stem ({1}) -%!error stem (1, {1}) -%!error stem (1:2, 1:3) -%!error stem (1:2, ones (3,3)) -%!error stem (ones (2,2), ones (3,3)) -%!error 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 stem (1,2,3) +%!error stem (ones (2,2,2)) +%!error stem ({1}) +%!error stem (1, {1}) +%!error stem (1:2, 1:3) +%!error stem (1:2, ones (3,3)) +%!error stem (ones (2,2), ones (3,3)) +%!error stem (1, "FOO") +