Exemplo n.º 1
0
 private static void assertRowFrameEquals(double[] expected, Frame actual) {
   assertEquals(1, actual.numRows());
   assertEquals(expected.length, actual.numCols());
   for (int i = 0; i < expected.length; i++) {
     assertEquals("Wrong sum in column " + actual.name(i), expected[i], actual.vec(i).at(0), 1e-8);
   }
 }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
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));
 }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
  // Return permutation matrix mapping input names to adaptedFrame colnames
  public int[] mapNames(String[] names) {
    assert names.length == _adaptedFrame._names.length : "Names must be the same length!";
    int[] idx = new int[names.length];
    Arrays.fill(idx, -1);

    for (int i = 0; i < _adaptedFrame._names.length; i++) {
      for (int j = 0; j < names.length; j++) {
        if (names[j].equals(_adaptedFrame.name(i))) {
          idx[i] = j;
          break;
        }
      }
    }
    return idx;
  }