Mercurial > octave
diff scripts/set/setxor.m @ 27296:538468f901dd
Clean up BIST tests in set functions.
* intersect.m: Re-order BIST tests to follow order in other files.
* setdiff.m: Rename variable "tmp" to "csort" for clarity. sortrows ([c; b]);
Re-order BIST tests to follow order in other files.
* setxor.m: Use keyword "end" rather than variable 'n' in indexing
to match other files. Re-order BIST tests to follow order in other files.
* union.m: Add BIST tests for orientation of output.
* unique.m: Rewrite BIST tests to use semicolons for column vectors rather
than transpose of row vector. Add comments describing each BIST test block.
author | Rik <rik@octave.org> |
---|---|
date | Sun, 28 Jul 2019 17:56:28 -0700 |
parents | aa4147476138 |
children | b442ec6dda5c |
line wrap: on
line diff
--- a/scripts/set/setxor.m Sun Jul 28 07:54:21 2019 -0700 +++ b/scripts/set/setxor.m Sun Jul 28 17:56:28 2019 -0700 @@ -106,11 +106,10 @@ else na = numel (a); nb = numel (b); [c, i] = sort ([a(:); b(:)]); - n = numel (c); if (iscell (c)) - idx = find (strcmp (c(1:n-1), c(2:n))); + idx = find (strcmp (c(1:end-1), c(2:end))); else - idx = find (c(1:n-1) == c(2:n)); + idx = find (c(1:end-1) == c(2:end)); endif if (optsorted) if (! isempty (idx)) @@ -158,6 +157,13 @@ %! assert (ia, [5]); %! assert (ib, [2]); +## Test multi-dimensional arrays +%!test +%! a = rand (3,3,3); +%! b = a; +%! b(1,1,1) = 2; +%! assert (intersect (a, b), sort (a(2:end)')); + ## Test "rows" input %!test %! a = [1 2; 4 5; 1 3]; @@ -223,13 +229,6 @@ %!assert (size (setxor (x, y')), [3 1]) %!assert (size (setxor (x', y')), [3 1]) -## Test multi-dimensional arrays -%!test -%! a = rand (3,3,3); -%! b = a; -%! b(1,1,1) = 2; -%! assert (intersect (a, b), sort (a(2:end)')); - ## Test "legacy" input %!test %! a = [5 1 3 3 3];