Mercurial > hg > octave-nkf
changeset 19578:ef649fe230f5 stable
interp1.m: Fix shape of output matrix when there are extrapolated values (bug #43745).
* interp1.m: reshape interpolated values to original shape before outlier
processing. Add BIST tests to check behavior.
author | Nir Krakauer <nkrakauer@ccny.cuny.edu> |
---|---|
date | Fri, 05 Dec 2014 11:07:36 -0800 |
parents | 7759e4d62f04 |
children | 7d272300a880 |
files | scripts/general/interp1.m |
diffstat | 1 files changed, 4 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/interp1.m +++ b/scripts/general/interp1.m @@ -329,6 +329,7 @@ minx = min (x(1), x(nx)); maxx = max (x(1), x(nx)); + xi = reshape (xi, szx); outliers = xi < minx | ! (xi <= maxx); # this even catches NaNs if (size_equal (outliers, yi)) yi(outliers) = extrap; @@ -338,6 +339,7 @@ else yi(outliers.') = extrap; endif + endif endfunction @@ -612,6 +614,8 @@ ## test extrapolation (linear) %!assert (interp1 ([1:5],[3:2:11],[0,6],"linear","extrap"), [1, 13], eps) %!assert (interp1 (xp, yp, [-1, max(xp)+1],"linear",5), [5, 5]) +%!assert (interp1 ([0,1],[1,0],[0.1,0.9;0.2,1.1]), [0.9 0.1; 0.8 NA], eps) +%!assert (interp1 ([0,1],[1,0],[0.1,0.9;0.2,1]), [0.9 0.1; 0.8 0], eps) ## Basic sanity checks %!assert (interp1 (1:2,1:2,1.4,"nearest"), 1)