Skip to content

Compute histogram bin positions beyond length 5000 #1887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/traces/histogram/calc.js
Original file line number Diff line number Diff line change
@@ -106,7 +106,7 @@ module.exports = function calc(gd, trace) {
// decrease end a little in case of rounding errors
binend = pr2c(binspec.end) + (i - Axes.tickIncrement(i, binspec.size, false, calendar)) / 1e6;

while(i < binend && pos.length < 5000) {
while(i < binend && pos.length < 1e6) {
i2 = Axes.tickIncrement(i, binspec.size, false, calendar);
pos.push((i + i2) / 2);
size.push(sizeinit);
@@ -116,6 +116,8 @@ module.exports = function calc(gd, trace) {
// nonuniform bins also need nonuniform normalization factors
if(densitynorm) inc.push(1 / (i2 - i));
if(doavg) counts.push(0);
// break to avoid infinite loops
if(i2 <= i) break;
i = i2;
}

13 changes: 13 additions & 0 deletions test/jasmine/tests/histogram_test.js
Original file line number Diff line number Diff line change
@@ -246,6 +246,19 @@ describe('Test histogram', function() {
]);
});

it('should handle very small bins', function() {
var out = _calc({
x: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
xbins: {
start: 0,
end: 10,
size: 0.001
}
});

expect(out.length).toEqual(9001);
});

describe('cumulative distribution functions', function() {
var base = {
x: [0, 5, 10, 15, 5, 10, 15, 10, 15, 15],