Fixed minor bug in numeric bin index where if a value was infinity, the bin count went negative.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@207 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-03-05 02:10:24 +00:00
parent 37e37488ec
commit 87d20f3299

View File

@ -50,14 +50,14 @@ public class NumericBinIndex {
return; return;
} }
double diff = getMax() - getMin(); double diff = _max - _min;
_step = 1; _step = 1;
if (diff > 10) { if (diff > 10) {
while (getStep() * 100 < diff) { while (_step * 100 < diff) {
_step *= 10; _step *= 10;
} }
} else { } else {
while (getStep() * 100 > diff) { while (_step * 100 > diff) {
_step /= 10; _step /= 10;
} }
} }
@ -65,7 +65,7 @@ public class NumericBinIndex {
_min = (Math.floor(_min / _step) * _step); _min = (Math.floor(_min / _step) * _step);
_max = (Math.ceil(_max / _step) * _step); _max = (Math.ceil(_max / _step) * _step);
int binCount = 1 + (int) Math.ceil((getMax() - getMin()) / getStep()); int binCount = 1 + (int) Math.ceil((_max - _min) / _step);
if (binCount > 100) { if (binCount > 100) {
_step *= 2; _step *= 2;
binCount = Math.round((1 + binCount) / 2); binCount = Math.round((1 + binCount) / 2);
@ -95,8 +95,10 @@ public class NumericBinIndex {
} }
protected void processValue(double v, List<Double> allValues) { protected void processValue(double v, List<Double> allValues) {
_min = Math.min(getMin(), v); if (!Double.isInfinite(v)) {
_max = Math.max(getMax(), v); _min = Math.min(_min, v);
_max = Math.max(_max, v);
allValues.add(v); allValues.add(v);
} }
} }
}