Mercurial > octave
changeset 21402:8cfc50637511
accumarray: fix default output size for empty list of subscripts (bug #47287)
author | Carnë Draug <carandraug@octave.org> |
---|---|
date | Sun, 28 Feb 2016 18:22:39 +0000 |
parents | 2f402f7c1a0b |
children | 0daaca299102 |
files | scripts/general/accumarray.m |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/accumarray.m Sun Feb 28 18:21:07 2016 +0000 +++ b/scripts/general/accumarray.m Sun Feb 28 18:22:39 2016 +0000 @@ -351,7 +351,8 @@ if (isempty (sz)) sz = max (subs); - if (length (sz) == 1) + ## If subs is empty, sz will be too, and length will be 0, hence "<= 1" + if (length (sz) <= 1) sz(2) = 1; endif endif @@ -438,6 +439,7 @@ %! for idx = 1:numel (funcs) %! assert (accumarray (zeros (0, 1), [], [0 1] , funcs{idx}), zeros (0, 1)) %! assert (accumarray (zeros (0, 1), [], [1 0] , funcs{idx}), zeros (1, 0)) +%! assert (accumarray (zeros (0, 1), [], [] , funcs{idx}), zeros (0, 1)) %! endfor ## Matlab returns an array of doubles even though FUNC returns cells. In