use of de.lmu.ifi.dbs.elki.datasource.filter.cleaning.DropNaNFilter in project elki by elki-project.
the class DropNaNFilterTest method defaultParameters.
/**
* Test with default parameters.
*/
@Test
public void defaultParameters() {
String filename = UNITTEST + "nan-test-1.csv";
DropNaNFilter filter = new ELKIBuilder<>(DropNaNFilter.class).build();
MultipleObjectsBundle filteredBundle = readBundle(filename, filter);
// Load the test data again without a filter.
MultipleObjectsBundle unfilteredBundle = readBundle(filename);
// Get dimensionalities
int dimFiltered = getFieldDimensionality(filteredBundle, 0, TypeUtil.NUMBER_VECTOR_FIELD);
int dimUnfiltered = getFieldDimensionality(unfilteredBundle, 0, TypeUtil.NUMBER_VECTOR_FIELD);
// Ensure that at least a single NaN exists in the unfiltered bundle.
boolean NaNfound = false;
for (int row = 0; row < unfilteredBundle.dataLength(); row++) {
DoubleVector d = get(unfilteredBundle, row, 0, DoubleVector.class);
for (int col = 0; col < dimUnfiltered; col++) {
final double v = d.doubleValue(col);
if (Double.isNaN(v)) {
NaNfound = true;
break;
}
}
}
assertTrue("NaN expected in unfiltered data", NaNfound);
// Ensure that no single NaN exists in the filtered bundle.
for (int row = 0; row < filteredBundle.dataLength(); row++) {
DoubleVector d = get(filteredBundle, row, 0, DoubleVector.class);
for (int col = 0; col < dimFiltered; col++) {
assertFalse("NaN not expected", Double.isNaN(d.doubleValue(col)));
}
}
}
Aggregations