Mercurial > octave-libtiff
changeset 20590:45759620a9a5 stable
quantile.m: Fix operation along a singleton dimension (bug #45455).
* quantile.m: Add isempty() to input validation.
* quantile.m (__quantile__): Sort x explicitly along dimension 1.
author | Lachlan Andrew <lachlanbis@gmail.com> |
---|---|
date | Fri, 09 Oct 2015 19:14:20 -0700 |
parents | db3286201347 |
children | 5fc798a9b32c 7890893a0e69 |
files | scripts/statistics/base/quantile.m |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/statistics/base/quantile.m Wed Oct 07 14:52:01 2015 -0700 +++ b/scripts/statistics/base/quantile.m Fri Oct 09 19:14:20 2015 -0700 @@ -113,8 +113,8 @@ print_usage (); endif - if (! (isnumeric (x) || islogical (x))) - error ("quantile: X must be a numeric vector or matrix"); + if (! (isnumeric (x) || islogical (x)) || isempty (x)) + error ("quantile: X must be a non-empty numeric vector or matrix"); endif if (isempty (p)) @@ -321,6 +321,9 @@ %! yexp = median (x, dim); %! assert (yobs, yexp); +## Bug #45455 +%!assert (quantile ([1 3 2], 0.5, 1), [1 3 2]) + ## Test input validation %!error quantile () %!error quantile (1, 2, 3, 4, 5) @@ -358,8 +361,7 @@ p = p(:); ## Save length and set shape of samples. - ## FIXME: does sort guarantee that NaN's come at the end? - x = sort (x); + x = sort (x, 1); m = sum (! isnan (x)); [xr, xc] = size (x); @@ -431,7 +433,7 @@ endswitch ## Duplicate single values. - imm1 = (mm == 1); + imm1 = (mm(1,:) == 1); x(2,imm1) = x(1,imm1); ## Interval indices.