changeset 27228:c80681b4948d

unique.m: Fix special case of "legacy" and "rows" flag both present. * unique.m: Initialize variable isrowvec in all cases. Add BIST case to check special case.
author Rik <rik@octave.org>
date Wed, 10 Jul 2019 17:25:39 -0700
parents c90648dde5cf
children 255f2681d224
files scripts/set/unique.m
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/set/unique.m	Wed Jul 10 14:08:48 2019 -0700
+++ b/scripts/set/unique.m	Wed Jul 10 17:25:39 2019 -0700
@@ -105,6 +105,7 @@
 
   if (optrows)
     n = rows (x);
+    isrowvec = false;
   else
     n = numel (x);
     isrowvec = isrow (x);
@@ -233,6 +234,13 @@
 %! assert (i, [2,3,6,7]);
 %! assert (j, [1,1,2,3,3,3,4]);
 
+%!test
+%! A = [1,2,3; 1,2,3];
+%! [a,i,j] = unique (A, "rows", "legacy");
+%! assert (a, [1,2,3]);
+%! assert (A(i,:), a);
+%! assert (a(j,:), A);
+
 ## Test input validation
 %!error unique ()
 %!error <X must be an array or cell array of strings> unique ({1})