Fixed "off by one bucket" bug in range facet's binning algorithm.
git-svn-id: http://google-refine.googlecode.com/svn/trunk@336 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
19ba207d27
commit
f5d270e35a
@ -73,7 +73,7 @@ public class ExpressionNumericRowBinner implements RowVisitor {
|
||||
|
||||
double d = ((Number) value).doubleValue();
|
||||
|
||||
int bin = (int) Math.round((d - _index.getMin()) / _index.getStep());
|
||||
int bin = (int) Math.floor((d - _index.getMin()) / _index.getStep());
|
||||
|
||||
bins[bin]++;
|
||||
} else {
|
||||
|
@ -62,12 +62,16 @@ public class NumericBinIndex {
|
||||
}
|
||||
|
||||
if (_min >= _max) {
|
||||
_step = 0;
|
||||
_step = 1;
|
||||
_min = 0;
|
||||
_max = _step;
|
||||
_bins = new int[1];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
double diff = _max - _min;
|
||||
|
||||
_step = 1;
|
||||
if (diff > 10) {
|
||||
while (_step * 100 < diff) {
|
||||
@ -79,18 +83,24 @@ public class NumericBinIndex {
|
||||
}
|
||||
}
|
||||
|
||||
double originalMax = _max;
|
||||
_min = (Math.floor(_min / _step) * _step);
|
||||
_max = (Math.ceil(_max / _step) * _step);
|
||||
|
||||
int binCount = 1 + (int) Math.ceil((_max - _min) / _step);
|
||||
int binCount = (int) ((_max - _min) / _step);
|
||||
if (binCount > 100) {
|
||||
_step *= 2;
|
||||
binCount = Math.round((1 + binCount) / 2);
|
||||
}
|
||||
|
||||
if (_max <= originalMax) {
|
||||
_max += _step;
|
||||
binCount++;
|
||||
}
|
||||
|
||||
_bins = new int[binCount];
|
||||
for (double d : allValues) {
|
||||
int bin = (int) Math.round((d - _min) / _step);
|
||||
int bin = (int) Math.floor((d - _min) / _step);
|
||||
_bins[bin]++;
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public class RangeFacet implements Facet {
|
||||
_eval, _cellIndex, _selectNumeric, _selectNonNumeric, _selectBlank, _selectError) {
|
||||
|
||||
protected boolean checkValue(double d) {
|
||||
return d <= _to;
|
||||
return d < _to;
|
||||
};
|
||||
};
|
||||
} else {
|
||||
@ -180,7 +180,7 @@ public class RangeFacet implements Facet {
|
||||
_eval, _cellIndex, _selectNumeric, _selectNonNumeric, _selectBlank, _selectError) {
|
||||
|
||||
protected boolean checkValue(double d) {
|
||||
return d >= _from && d <= _to;
|
||||
return d >= _from && d < _to;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ img {
|
||||
.ui-widget-content a.ui-state-default.ui-slider-handle:last-child {
|
||||
background: url(../images/slider-right-bracket.png) no-repeat bottom right;
|
||||
border: none;
|
||||
margin-left: -3px;
|
||||
margin-left: -2px;
|
||||
top: -10px;
|
||||
}
|
||||
.ui-slider .ui-slider-handle {
|
||||
|
Loading…
Reference in New Issue
Block a user