示例#1
0
 @Test
 public void testIsEqualTo() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(1, intColumn.isEqualTo(10).size());
 }
示例#2
0
 @Test
 public void testIsLessThan() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(50, intColumn.isLessThan(50).size());
 }
示例#3
0
 @Test
 public void testIsGreaterThan() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(49, intColumn.isGreaterThan(50).size());
 }
示例#4
0
 @Test
 public void testMax() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(99, intColumn.max(), .001);
 }
示例#5
0
 @Test
 public void testMin() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(0.0, intColumn.min(), .001);
 }
示例#6
0
 @Test
 public void testSum() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(1);
   }
   assertEquals(100, intColumn.sum());
 }
示例#7
0
 @Test
 public void testPercents() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   FloatColumn floatColumn = intColumn.asRatio();
   assertEquals(1.0, floatColumn.sum(), 0.1);
 }
示例#8
0
 @Test
 public void testIsLessThanOrEqualTo() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(51, intColumn.isLessThanOrEqualTo(50).size());
   assertEquals(49, intColumn.isLessThanOrEqualTo(50).get(49));
 }
示例#9
0
 @Test
 public void testIsGreaterThanOrEqualTo() {
   for (int i = 0; i < 100; i++) {
     intColumn.add(i);
   }
   assertEquals(50, intColumn.isGreaterThanOrEqualTo(50).size());
   assertEquals(50, intColumn.isGreaterThanOrEqualTo(50).get(0));
 }
示例#10
0
  @Test
  public void testSelectIf() {

    for (int i = 0; i < 100; i++) {
      intColumn.add(i);
    }

    IntPredicate predicate = value -> value < 10;
    IntColumn column1 = intColumn.selectIf(predicate);
    assertEquals(10, column1.size());
    for (int i = 0; i < 10; i++) {
      assertTrue(column1.get(i) < 10);
    }
  }
示例#11
0
  @Test
  public void testIntIsIn() {
    int[] originalValues = new int[] {32, 42, 40, 57, 52, -2};
    int[] inValues = new int[] {10, -2, 57, -5};
    IntColumn inColumn = IntColumn.create("In", new IntArrayList(inValues));

    IntColumn initial = new IntColumn("Test", originalValues.length);
    Table t = Table.create("t", initial);

    for (int value : originalValues) {
      initial.add(value);
    }

    Filter filter = column("Test").isIn(inColumn);
    Table result = t.selectWhere(filter);
    System.out.println(result.print());
  }
示例#12
0
  @Test
  public void testDifference() {
    int[] originalValues = new int[] {32, 42, 40, 57, 52};
    int[] expectedValues = new int[] {IntColumn.MISSING_VALUE, 10, -2, 17, -5};

    IntColumn initial = new IntColumn("Test", originalValues.length);
    for (int value : originalValues) {
      initial.add(value);
    }
    IntColumn difference = initial.difference();
    assertEquals(
        "Both sets of data should be the same size.", expectedValues.length, difference.size());
    for (int index = 0; index < difference.size(); index++) {
      int actual = difference.get(index);
      assertEquals(
          "difference operation at index:" + index + " failed", expectedValues[index], actual);
    }
  }