use of com.amazon.randomcutforest.returntypes.Neighbor in project random-cut-forest-by-aws by aws.
the class NearNeighborVisitorTest method acceptLeafNearTimestampsDisabled.
@Test
public void acceptLeafNearTimestampsDisabled() {
float[] leafPoint = new float[] { 8.8f, 9.9f, -5.5f };
INodeView leafNode = mock(NodeView.class);
when(leafNode.getLiftedLeafPoint()).thenReturn(Arrays.copyOf(leafPoint, leafPoint.length));
when(leafNode.getLeafPoint()).thenReturn(Arrays.copyOf(leafPoint, leafPoint.length));
assertEquals(0, leafNode.getSequenceIndexes().size());
int depth = 12;
visitor.acceptLeaf(leafNode, depth);
Optional<Neighbor> optional = visitor.getResult();
assertTrue(optional.isPresent());
Neighbor neighbor = optional.get();
assertNotSame(leafPoint, neighbor.point);
assertArrayEquals(toDoubleArray(leafPoint), neighbor.point);
assertEquals(Math.sqrt(3 * 1.1 * 1.1), neighbor.distance, EPSILON);
assertTrue(neighbor.sequenceIndexes.isEmpty());
}