Search in sources :

Example 1 with PointStoreSmall

use of com.amazon.randomcutforest.store.PointStoreSmall in project random-cut-forest-by-aws by aws.

the class PointStoreMapperTest method testRoundTrip.

@Test
public void testRoundTrip() {
    int dimensions = 2;
    int capacity = 4;
    PointStore store = new PointStoreSmall(dimensions, capacity);
    float[] point1 = { 1.1f, -22.2f };
    int index1 = store.add(point1, 1);
    float[] point2 = { 3.3f, -4.4f };
    int index2 = store.add(point2, 2);
    float[] point3 = { 10.1f, 100.1f };
    int index3 = store.add(point3, 3);
    PointStore store2 = mapper.toModel(mapper.toState(store));
    assertEquals(capacity, store2.getCapacity());
    assertEquals(3, store2.size());
    assertEquals(dimensions, store2.getDimensions());
    assertArrayEquals(store.getStore(), store2.getStore());
}
Also used : PointStore(com.amazon.randomcutforest.store.PointStore) PointStoreSmall(com.amazon.randomcutforest.store.PointStoreSmall) Test(org.junit.jupiter.api.Test)

Aggregations

PointStore (com.amazon.randomcutforest.store.PointStore)1 PointStoreSmall (com.amazon.randomcutforest.store.PointStoreSmall)1 Test (org.junit.jupiter.api.Test)1