Esempio n. 1
0
  @Test
  public void testValRowArgument() {
    Frame fr =
        register(new Frame(Key.<Frame>make(), ar("i1", "d1", "d2", "d3"), aro(vi1, vd1, vd2, vd3)));
    Val val = Rapids.exec("(apply " + fr._key + " 1 {x . (sumaxis x 1)})"); // skip NAs
    assertTrue(val instanceof ValFrame);
    Frame res = register(val.getFrame());
    assertColFrameEquals(ard(1.7, 2.9, 4.1, 10.3, 10.0), res);

    Val val2 = Rapids.exec("(apply " + fr._key + " 1 {x . (sumaxis x 0)})"); // do not skip NAs
    assertTrue(val2 instanceof ValFrame);
    Frame res2 = register(val2.getFrame());
    assertColFrameEquals(ard(1.7, 2.9, Double.NaN, 10.3, Double.NaN), res2);
  }
Esempio n. 2
0
 @Test
 public void testRowwisesumOnFrameWithTimeandNumericColumn() {
   Frame fr = register(new Frame(Key.<Frame>make(), ar("t1", "i1"), aro(vt1, vi1)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 1 1)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertColFrameEquals(ard(-1, -2, 0, 2, 1), res);
 }
Esempio n. 3
0
 @Test
 public void testColumnwisesumOnEmptyFrame() {
   Frame fr = register(new Frame(Key.<Frame>make()));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 0 0)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertEquals(res.numCols(), 0);
   assertEquals(res.numRows(), 0);
 }
Esempio n. 4
0
 @Test
 public void testBadFirstArgument() {
   try {
     Rapids.exec("(sumaxis " + vi1._key + " 1 0)");
     fail();
   } catch (IllegalArgumentException ignored) {
   }
   try {
     Rapids.exec("(sum hello 1 0)");
     fail();
   } catch (IllegalArgumentException ignored) {
   }
   try {
     Rapids.exec("(sum 2 1 0)");
     fail();
   } catch (IllegalArgumentException ignored) {
   }
 }
Esempio n. 5
0
 @Test
 public void testRowwisesumOnFrameWithNonnumericColumnsOnly() {
   Frame fr = register(new Frame(Key.<Frame>make(), ar("c1", "s1"), aro(vc2, vs1)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 1 1)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertEquals("Unexpected column name", "sum", res.name(0));
   assertEquals("Unexpected column type", Vec.T_NUM, res.types()[0]);
   assertColFrameEquals(ard(Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN), res);
 }
Esempio n. 6
0
 @Test
 public void testRowwisesumOnFrameWithTimeColumnsOnly() {
   Frame fr = register(new Frame(Key.<Frame>make(), ar("t1", "s", "t2"), aro(vt1, vs1, vt2)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 1 1)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertEquals("Unexpected column name", "sum", res.name(0));
   assertEquals("Unexpected column type", Vec.T_TIME, res.types()[0]);
   assertColFrameEquals(ard(30000000, 30000040, 30000060, 30000080, 30000120), res);
 }
Esempio n. 7
0
 @Test
 public void testRowwisesumWithoutNaRm() {
   Frame fr =
       register(new Frame(Key.<Frame>make(), ar("i1", "d1", "d2", "d3"), aro(vi1, vd1, vd2, vd3)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 0 1)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertColFrameEquals(ard(1.7, 2.9, Double.NaN, 10.3, Double.NaN), res);
   assertEquals("sum", res.name(0));
 }
Esempio n. 8
0
 @Test
 public void testColumnwisesumBinaryVec() {
   assertTrue(vc1.isBinary() && !vc2.isBinary());
   Frame fr = register(new Frame(Key.<Frame>make(), ar("C1", "C2"), aro(vc1, vc2)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 1 0)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertArrayEquals(fr.names(), res.names());
   assertArrayEquals(ar(Vec.T_NUM, Vec.T_NUM), res.types());
   assertRowFrameEquals(ard(3.0, Double.NaN), res);
 }
Esempio n. 9
0
 @Test
 public void testRowwisesumWithNaRm() {
   Frame fr =
       register(
           new Frame(
               Key.<Frame>make(), ar("i1", "d1", "d2", "d3", "s1"), aro(vi1, vd1, vd2, vd3, vs1)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 1 1)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertEquals("Unexpected column name", "sum", res.name(0));
   assertEquals("Unexpected column type", Vec.T_NUM, res.types()[0]);
   assertColFrameEquals(ard(1.7, 2.9, 4.1, 10.3, 10.0), res);
 }
Esempio n. 10
0
 @Test
 public void testColumnwiseSumWithNaRm() {
   Frame fr =
       register(
           new Frame(
               Key.<Frame>make(),
               ar("I", "D", "DD", "DN", "T", "S", "C"),
               aro(vi1, vd1, vd2, vd3, vt1, vs1, vc2)));
   Val val = Rapids.exec("(sumaxis " + fr._key + " 1 0)");
   assertTrue(val instanceof ValFrame);
   Frame res = register(val.getFrame());
   assertArrayEquals(fr.names(), res.names());
   assertArrayEquals(
       ar(Vec.T_NUM, Vec.T_NUM, Vec.T_NUM, Vec.T_NUM, Vec.T_TIME, Vec.T_NUM, Vec.T_NUM),
       res.types());
   assertRowFrameEquals(ard(0.0, 20.0, 3.0, 6.0, 50000150.0, Double.NaN, Double.NaN), res);
 }