From 494c5caf5b5b34ef427eaec3e303fec3753df612 Mon Sep 17 00:00:00 2001 From: Adeline CARNIS Date: Wed, 12 Aug 2015 11:26:04 +0200 Subject: [PATCH] * Bug #13709 fixed - the returned position by unique function was sometimes wrong. Change-Id: I14e6df5a5e05686c986a873166461a072358b8bc --- scilab/CHANGES_6.0.X | 5 ++- .../tests/nonreg_tests/bug_13709.dia.ref | 32 +++++++++++++++++ .../tests/nonreg_tests/bug_13709.tst | 38 ++++++++++++++++++++ 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.dia.ref create mode 100644 scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.tst diff --git a/scilab/CHANGES_6.0.X b/scilab/CHANGES_6.0.X index fa87741..0f304a2 100644 --- a/scilab/CHANGES_6.0.X +++ b/scilab/CHANGES_6.0.X @@ -2,7 +2,10 @@ ================================================================= -(please remove this line when adding the first changed item...) +Scilab Bug Fixes +================ + +* Bug #13709 fixed - unique function sometimes returned wrong index values. diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.dia.ref new file mode 100644 index 0000000..ed40aca --- /dev/null +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.dia.ref @@ -0,0 +1,32 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// <-- CLI SHELL MODE --> +// <-- Non-regression test for bug 13709 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13709 +// +// <-- Short Description --> +// The position of the first of each distinct element was sometimes wrong. +// ============================================================================= +ind = [2 1 1; +2 1 1; +4 1 1; +4 2 2; +4 2 2; +5 3 3; +5 3 3; +5 4 4]; +[Uind, kindex] = unique(ind, "r"); +expUind = [2 1 1; +4 1 1; +4 2 2; +5 3 3; +5 4 4]; +expk = [1 3 4 6 8]'; +assert_checkequal(Uind, expUind); +assert_checkequal(kindex, expk); diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.tst new file mode 100644 index 0000000..9e988b2 --- /dev/null +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_13709.tst @@ -0,0 +1,38 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2015 - Scilab Enterprises - Adeline CARNIS +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= + +// <-- CLI SHELL MODE --> + +// <-- Non-regression test for bug 13709 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/show_bug.cgi?id=13709 +// +// <-- Short Description --> +// The position of the first of each distinct element was sometimes wrong. +// ============================================================================= + +ind = [2 1 1; +2 1 1; +4 1 1; +4 2 2; +4 2 2; +5 3 3; +5 3 3; +5 4 4]; + +[Uind, kindex] = unique(ind, "r"); + +expUind = [2 1 1; +4 1 1; +4 2 2; +5 3 3; +5 4 4]; + +expk = [1 3 4 6 8]'; +assert_checkequal(Uind, expUind); +assert_checkequal(kindex, expk); -- 1.7.9.5