use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class AstTokenizeTest method testTokenize.
@Test
public void testTokenize() {
Frame fr = makeTestFrame();
Vec expected = svec("Foot", "on", "the", "pedal", "Never", "ever", "false", "metal", null, "Engine", "running", "hotter", "than", "a", "boiling", "kettle", "My", "job", "ain't", "a", "job", null, "It's", "a", "damn", "good", "time", "City", "to", "city", "I'm", "running", "my", "rhymes", null);
Frame res = null;
try {
ValFrame val = (ValFrame) Rapids.exec("(tmp= py_1 (tokenize data \"\\\\s\"))");
res = val.getFrame();
Vec actual = res.anyVec();
assertStringVecEquals(expected, actual);
} finally {
fr.remove();
expected.remove();
if (res != null)
res.remove();
}
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class RapidsTest method testProstate_assign_frame_scalar.
@Test
public void testProstate_assign_frame_scalar() {
Frame fr = parse_test_file(Key.make("prostate.hex"), "smalldata/logreg/prostate.csv");
try {
Val val = Rapids.exec("(tmp= py_1 (:= prostate.hex -1 1 (== (cols_py prostate.hex 1) 0)))");
if (val instanceof ValFrame) {
Frame fr2 = val.getFrame();
System.out.println(fr2.vec(0));
fr2.remove();
}
} finally {
fr.delete();
}
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class RapidsTest method testCombo.
@Test
public void testCombo() {
Frame fr = parse_test_file(Key.make("a.hex"), "smalldata/iris/iris_wheader.csv");
String tree = "(tmp= py_2 (:= (tmp= py_1 (cbind a.hex (== (cols_py a.hex 4.0 ) \"Iris-setosa\" ) ) ) (as.factor (cols_py py_1 5.0 ) ) 5.0 [] ) )";
//String tree = "(:= (tmp= py_1 a.hex) (h2o.runif a.hex -1) 4 [])";
Val val = Rapids.exec(tree);
if (val instanceof ValFrame) {
Frame fr2 = val.getFrame();
System.out.println(fr2.vec(0));
fr2.remove();
}
fr.delete();
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class SortTest method testBasicSortRapids.
@Test
public void testBasicSortRapids() {
Frame fr = null, res = null;
// Stable sort columns 1 and 2
String tree = "(sort hex [1 2])";
try {
// Build a frame which is unsorted on small-count categoricals in columns
// 0 and 1, and completely sorted on a record-number based column 2.
// Sort will be on columns 0 and 1, in that order, and is expected stable.
fr = buildFrame(1000, 10);
fr.insertVec(0, "row", fr.remove(2));
//
Val val = Rapids.exec(tree);
assertTrue(val instanceof ValFrame);
res = val.getFrame();
res.add("row", res.remove(0));
new CheckSort().doAll(res);
} finally {
if (fr != null)
fr.delete();
if (res != null)
res.delete();
}
}
use of water.rapids.vals.ValFrame in project h2o-3 by h2oai.
the class AstCumuTest method testCumuSimple.
@Test
public void testCumuSimple() {
Scope.enter();
try {
Session sess = new Session();
new TestFrameBuilder().withName("$fr", sess).withColNames("c1", "c2", "c3", "c4").withDataForCol(0, ard(1, 1)).withDataForCol(1, ard(2, 2)).withDataForCol(2, ard(3, 3)).withDataForCol(3, ard(4, 4)).build();
Val val = Rapids.exec("(cumsum $fr 1)", sess);
Assert.assertTrue(val instanceof ValFrame);
Frame res = Scope.track(val.getFrame());
Assert.assertEquals(res.vec(0).at8(0L), 1);
Assert.assertEquals(res.vec(1).at8(0L), 3);
Assert.assertEquals(res.vec(2).at8(0L), 6);
Assert.assertEquals(res.vec(3).at8(0L), 10);
val = Rapids.exec("(cumsum $fr 0)", sess);
Assert.assertTrue(val instanceof ValFrame);
res = Scope.track(val.getFrame());
Assert.assertEquals(res.vec(0).at8(1L), 2);
Assert.assertEquals(res.vec(1).at8(1L), 4);
Assert.assertEquals(res.vec(2).at8(1L), 6);
Assert.assertEquals(res.vec(3).at8(1L), 8);
val = Rapids.exec("(cummax $fr 1)", sess);
Assert.assertTrue(val instanceof ValFrame);
res = Scope.track(val.getFrame());
Assert.assertEquals(res.vec(0).at8(0L), 1);
Assert.assertEquals(res.vec(1).at8(0L), 2);
Assert.assertEquals(res.vec(2).at8(0L), 3);
Assert.assertEquals(res.vec(3).at8(0L), 4);
} finally {
Scope.exit();
}
}
Aggregations