[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #51059] hist3 function doesn't handle NaN inpu
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #51059] hist3 function doesn't handle NaN inputs properly |
Date: |
Thu, 18 May 2017 10:24:50 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36 |
Follow-up Comment #1, bug #51059 (project octave):
Sorry, my original submission seems to have been truncated. Hopefully the
remainder won't be.
I think the problem is on line 97:
94: if (! ismatrix (X) || columns (X) != 2)
95: error ("hist3: X must be a 2 columns matrix");
96: endif
97: X(any (isnan (X), 2)) = [];
-verbatim+
Should be:
94: if (! ismatrix (X) || columns (X) != 2)
95: error ("hist3: X must be a 2 columns matrix");
96: endif
97: X(any (isnan (X), 2), :) = [];
-verbatim+
Here's a unit test that exercises the NaN-suppression code:
%!test
%! D = [1 1; nan 2; 3 1; 3 3; 1 nan; 3 1];
%! [c, nn] = hist3 (D, {0:4, 0:4});
%! exp_c = zeros (5);
%! exp_c([7 9 19]) = [1 2 1];
%! assert (c, exp_c);
%! assert (nn, {0:4, 0:4});
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?51059>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/