use of de.lmu.ifi.dbs.elki.database.ids.DBIDRef in project elki by elki-project.
the class AbstractOutlierAlgorithmTest method testSingleScore.
/**
* Test the outlier score of a single object.
*
* @param result Result object to use
* @param id Object ID
* @param expected expected value
*/
protected void testSingleScore(OutlierResult result, int id, double expected) {
assertNotNull("No outlier result", result);
assertNotNull("No score result.", result.getScores());
DBIDs ids = result.getScores().getDBIDs();
assertTrue("IDs must be array-based", ids instanceof ArrayDBIDs);
// Translate offset. We used to use 1-indexed
DBIDRef dbid = ((ArrayDBIDs) ids).iter().seek(id - 1);
assertNotNull("No result for ID " + id, result.getScores().doubleValue(dbid));
double actual = result.getScores().doubleValue(dbid);
assertEquals("Outlier score of object " + id + " doesn't match.", expected, actual, 0.0001);
}
Aggregations