From 8f65c3341f4cd328c19f1cb2f3d4545eb8ef7531 Mon Sep 17 00:00:00 2001 From: Samuel GOUGEON Date: Thu, 7 Jan 2021 22:00:53 +0100 Subject: [PATCH] * Bug 16305 fixed: unwrap() failed unfolding straight segments http://bugzilla.scilab.org/16305 Change-Id: I8015da57839530a120190869663d6e35d87ed2e9 --- scilab/CHANGES.md | 1 + .../modules/elementary_functions/macros/unwrap.sci | 3 ++- .../tests/nonreg_tests/bug_16305.tst | 23 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 scilab/modules/elementary_functions/tests/nonreg_tests/bug_16305.tst diff --git a/scilab/CHANGES.md b/scilab/CHANGES.md index 13e9e30..a8eb7a4 100644 --- a/scilab/CHANGES.md +++ b/scilab/CHANGES.md @@ -365,6 +365,7 @@ Bug Fixes * [#16274](https://bugzilla.scilab.org/16274): assert_checkequal() did not considered equal matching Nan or void elements in (nested) containers. * [#16288](https://bugzilla.scilab.org/16288): An error message from `wavread` was wrong. * [#16297](https://bugzilla.scilab.org/16297): After function test(), e={}, endfunction; macr2tree(test) crashes Scilab. +* [#16305](https://bugzilla.scilab.org/16305): `unwrap()` failed unfolding curves with straight segments. * [#16337](https://bugzilla.scilab.org/16337): The 3rd output of `[U,km,ku] = unique(..)` was not implemented. * [#16340](https://bugzilla.scilab.org/16340): `setdiff("","")` produced `""` instead of `[]`. The `"c"` and `"r"` options yielded an error for string inputs. Input arguments were poorly checked. * [#16342](https://bugzilla.scilab.org/16342): `strcat()` was much slower in Scilab 6.0.2. diff --git a/scilab/modules/elementary_functions/macros/unwrap.sci b/scilab/modules/elementary_functions/macros/unwrap.sci index dea22f0..9faa852 100644 --- a/scilab/modules/elementary_functions/macros/unwrap.sci +++ b/scilab/modules/elementary_functions/macros/unwrap.sci @@ -137,7 +137,8 @@ function [retval, K] = unwrap(a, varargin) else // Local radius of curvature: calculation Rc = ((1+d(:,2:$).^2).^1.5) ./ abs(d(:,2:$)-d(:,1:$-1)) - K = find(Rc < mean(Rc)/30) // criterium to detect cusp points + // criterium to detect cusp points: + K = find(Rc < min(mean(Rc)/30, min(Rc)/(5e3*%eps))) [nR,nC] = size(Rc) // trimming edges (due to duplication of 1st & last columns): diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16305.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16305.tst new file mode 100644 index 0000000..fd8fdbe --- /dev/null +++ b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_16305.tst @@ -0,0 +1,23 @@ +// ============================================================================= +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) 2021 - Samuel GOUGEON +// +// This file is distributed under the same license as the Scilab package. +// ============================================================================= +// +// <-- CLI SHELL MODE --> +// <-- NO CHECK REF --> +// <-- Non-regression test for bug 16305 --> +// +// <-- Bugzilla URL --> +// http://bugzilla.scilab.org/16305 +// +// <-- Short Description --> +// unwrap(,"unfold") failed unfolding straight segments + +x = linspace(0,10,1000); +y = acos(cos(x)); +r = unwrap(y,'unfold'); + +Ref = [0. 1.2412412 2.4824825 3.7190723 4.9603135 6.2015547 7.436594 8.6778353 9.9051221]; +assert_checkalmostequal(r(1:124:1000), Ref, 1e-7); -- 1.7.9.5