use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class AstRectangleConditionalAssignTest method testConditionalAssignCategorical.
@Test
public void testConditionalAssignCategorical() {
Frame fr = makeTestFrame();
Vec expected = cvec(new String[] { "a", "b" }, "b", "b", "b", "b", "b");
try {
Val val = Rapids.exec("(tmp= py_1 (:= data \"b\" 4 (== (cols_py data 4) \"a\")))");
if (val instanceof ValFrame) {
Frame fr2 = val.getFrame();
assertCatVecEquals(expected, fr2.vec(4));
fr2.remove();
}
} finally {
fr.remove();
expected.remove();
}
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class AstRectangleConditionalAssignTest method testConditionalAssignString.
@Test
public void testConditionalAssignString() {
Frame fr = makeTestFrame();
Vec expected = svec("row1", "tst", "row3", "tst", "row5");
try {
Val val = Rapids.exec("(tmp= py_1 (:= data \"tst\" 3 (== (cols_py data 4) \"a\")))");
if (val instanceof ValFrame) {
Frame fr2 = val.getFrame();
assertStringVecEquals(expected, fr2.vec(3));
fr2.remove();
}
} finally {
fr.remove();
expected.remove();
}
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class AstRectangleFrameSliceAssignTest method testAssignFrameSlice.
@Test
public void testAssignFrameSlice() throws Exception {
final Frame data = parse_test_file(Key.make("data"), "smalldata/airlines/allyears2k_headers.zip");
Frame output = null;
try {
String rapids = "(tmp= tst (:= data (rows (cols data [8.0, 11.0] ) [10000.0:" + _nRows + ".0] ) [8.0, 11.0] [0.0:" + _nRows + ".0] ) )";
Val val = Rapids.exec(rapids);
if (val instanceof ValFrame) {
output = val.getFrame();
// categorical column
String[] expectedCats = catVec2array(data.vec(8));
System.arraycopy(expectedCats, 10000, expectedCats, 0, _nRows);
String[] actualCats = catVec2array(output.vec(8));
assertArrayEquals(expectedCats, actualCats);
// numerical column
double[] expected = vec2array(data.vec(11));
System.arraycopy(expected, 10000, expected, 0, _nRows);
double[] actual = vec2array(output.vec(11));
assertArrayEquals(expected, actual, 0.0001d);
}
} finally {
data.delete();
if (output != null) {
output.delete();
}
}
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class AstMeanTest method testRowwiseMeanOnFrameWithTimeColumnsOnly.
@Test
public void testRowwiseMeanOnFrameWithTimeColumnsOnly() {
Frame fr = register(new Frame(Key.<Frame>make(), ar("t1", "s", "t2"), aro(vt1, vs1, vt2)));
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_TIME, res.types()[0]);
assertColFrameEquals(ard(15000000, 15000020, 15000030, 15000040, 15000060), res);
}
use of water.rapids.vals.ValFrame 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);
}
Aggregations