use of water.rapids.Val in project h2o-3 by h2oai.
the class AstMeanTest method testRowwiseMeanOnFrameWithNonnumericColumnsOnly.
@Test
public void testRowwiseMeanOnFrameWithNonnumericColumnsOnly() {
Frame fr = register(new Frame(Key.<Frame>make(), ar("c1", "s1"), aro(vc2, vs1)));
Val val = Rapids.exec("(mean " + fr._key + " 1 1)");
assertTrue(val instanceof ValFrame);
Frame res = register(val.getFrame());
assertEquals("Unexpected column name", "mean", 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);
}
use of water.rapids.Val in project h2o-3 by h2oai.
the class AstMeanTest method testRowwiseMeanWithoutNaRm.
@Test
public void testRowwiseMeanWithoutNaRm() {
Frame fr = register(new Frame(Key.<Frame>make(), ar("i1", "d1", "d2", "d3"), aro(vi1, vd1, vd2, vd3)));
Val val = Rapids.exec("(mean " + fr._key + " 0 1)");
assertTrue(val instanceof ValFrame);
Frame res = register(val.getFrame());
assertColFrameEquals(ard(1.7 / 4, 2.9 / 4, Double.NaN, 10.3 / 4, Double.NaN), res);
assertEquals("mean", res.name(0));
}
use of water.rapids.Val in project h2o-3 by h2oai.
the class AstMeanTest method testColumnwiseMeanBinaryVec.
@Test
public void testColumnwiseMeanBinaryVec() {
assertTrue(vc1.isBinary() && !vc2.isBinary());
Frame fr = register(new Frame(Key.<Frame>make(), ar("C1", "C2"), aro(vc1, vc2)));
Val val = Rapids.exec("(mean " + 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(0.6, Double.NaN), res);
}
use of water.rapids.Val in project h2o-3 by h2oai.
the class AstMeanTest method testRowwiseMeanOnEmptyFrame.
@Test
public void testRowwiseMeanOnEmptyFrame() {
Frame fr = register(new Frame(Key.<Frame>make()));
Val val = Rapids.exec("(mean " + fr._key + " 0 1)");
assertTrue(val instanceof ValFrame);
Frame res = register(val.getFrame());
assertEquals(res.numCols(), 0);
assertEquals(res.numRows(), 0);
}
use of water.rapids.Val in project h2o-3 by h2oai.
the class AstNaCntTest method testAstNaCnt.
//--------------------------------------------------------------------------------------------------------------------
// Tests
//--------------------------------------------------------------------------------------------------------------------
@Test
public void testAstNaCnt() {
Frame f = null;
try {
f = ArrayUtils.frame(ar("A", "B"), ard(1.0, Double.NaN), ard(2.0, 23.3), ard(3.0, 3.3), ard(Double.NaN, 3.3));
String x = String.format("(naCnt %s)", f._key);
// make the call to count number of NAs in frame
Val res = Rapids.exec(x);
// get frame without any NAs
// assertEquals(f.numRows()-fNew.numRows() ,2); // 2 rows of NAs removed.
double[] naCnts = res.getNums();
double totalNacnts = 0;
for (int index = 0; index < f.numCols(); index++) {
totalNacnts += naCnts[index];
}
assertEquals((int) totalNacnts, 2);
} finally {
if (f != null)
f.delete();
}
}
Aggregations