Made numeric range index handle value.log() properly when value is 0 or negative.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@436 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-04-09 05:24:46 +00:00
parent a0d8c385f9
commit dff870519e
3 changed files with 16 additions and 8 deletions

View File

@ -71,13 +71,16 @@ public class ExpressionNumericRowBinner implements RowVisitor {
errorCount++;
} else if (ExpressionUtils.isNonBlankData(value)) {
if (value instanceof Number) {
numericCount++;
double d = ((Number) value).doubleValue();
int bin = (int) Math.floor((d - _index.getMin()) / _index.getStep());
bins[bin]++;
if (!Double.isInfinite(d) && !Double.isNaN(d)) {
numericCount++;
int bin = (int) Math.floor((d - _index.getMin()) / _index.getStep());
bins[bin]++;
} else {
errorCount++;
}
} else {
nonNumericCount++;
}

View File

@ -122,7 +122,7 @@ public class NumericBinIndex {
}
protected void processValue(double v, List<Double> allValues) {
if (!Double.isInfinite(v)) {
if (!Double.isInfinite(v) && !Double.isNaN(v)) {
_min = Math.min(_min, v);
_max = Math.max(_max, v);
allValues.add(v);

View File

@ -76,7 +76,12 @@ abstract public class ExpressionNumberComparisonRowFilter implements RowFilter {
return _selectError;
} else if (ExpressionUtils.isNonBlankData(v)) {
if (v instanceof Number) {
return _selectNumeric && checkValue(((Number) v).doubleValue());
double d = ((Number) v).doubleValue();
if (Double.isInfinite(d) || Double.isNaN(d)) {
return _selectError;
} else {
return _selectNumeric && checkValue(d);
}
} else {
return _selectNonNumeric;
}