Search in sources :

Example 61 with Val

use of water.rapids.Val in project h2o-3 by h2oai.

the class AstSumAxisTest method testRowwisesumWithoutNaRm.

@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));
}
Also used : Val(water.rapids.Val) ValFrame(water.rapids.vals.ValFrame) ValFrame(water.rapids.vals.ValFrame) Frame(water.fvec.Frame) Test(org.junit.Test)

Example 62 with Val

use of water.rapids.Val in project h2o-3 by h2oai.

the class AstMatchTest method testMatchCatList.

@Test
public void testMatchCatList() throws Exception {
    final Frame data = makeTestFrame();
    Frame output = null;
    try {
        String rapids = "(tmp= tst (match (cols data [2]) [\"cD\",\"cC\",\"cB\"] -1 ignored))";
        Val val = Rapids.exec(rapids);
        output = val.getFrame();
        assertVecEquals(data.vec(0), output.vec(0), 0.0);
    } finally {
        data.delete();
        if (output != null) {
            output.delete();
        }
    }
}
Also used : Val(water.rapids.Val) Frame(water.fvec.Frame) Test(org.junit.Test)

Example 63 with Val

use of water.rapids.Val in project h2o-3 by h2oai.

the class AstRectangleConditionalAssignTest method testConditionalAssignUUID.

@Test
public void testConditionalAssignUUID() {
    UUID newUUID = UUID.randomUUID();
    Frame fr = makeTestFrame();
    Vec expected = uvec(new UUID(10, 1), newUUID, new UUID(30, 3), newUUID, new UUID(50, 5));
    try {
        Val val = Rapids.exec("(tmp= py_1 (:= data \"" + newUUID.toString() + "\" 2 (== (cols_py data 4) \"a\")))");
        if (val instanceof ValFrame) {
            Frame fr2 = val.getFrame();
            assertUUIDVecEquals(expected, fr2.vec(2));
            fr2.remove();
        }
    } finally {
        fr.remove();
        expected.remove();
    }
}
Also used : Val(water.rapids.Val) ValFrame(water.rapids.vals.ValFrame) ValFrame(water.rapids.vals.ValFrame) Frame(water.fvec.Frame) Vec(water.fvec.Vec) UUID(java.util.UUID) Test(org.junit.Test)

Example 64 with Val

use of water.rapids.Val in project h2o-3 by h2oai.

the class AstRectangleConditionalAssignTest method testConditionalAssignNumber.

@Test
public void testConditionalAssignNumber() {
    Frame fr = makeTestFrame();
    Vec expected = dvec(11.2, -1, 33.6, -1, 56.0);
    try {
        Val val = Rapids.exec("(tmp= py_1 (:= data -1 1 (== (cols_py data 4) \"a\")))");
        if (val instanceof ValFrame) {
            Frame fr2 = val.getFrame();
            assertVecEquals(expected, fr2.vec(1), 0.00001);
            fr2.remove();
        }
    } finally {
        fr.remove();
        expected.remove();
    }
}
Also used : Val(water.rapids.Val) ValFrame(water.rapids.vals.ValFrame) ValFrame(water.rapids.vals.ValFrame) Frame(water.fvec.Frame) Vec(water.fvec.Vec) Test(org.junit.Test)

Example 65 with Val

use of water.rapids.Val in project h2o-3 by h2oai.

the class AstRectangleConditionalAssignTest method testConditionalAssignDense.

@Test
public void testConditionalAssignDense() {
    Frame fr = makeTestFrame();
    Vec expected = ivec(-1, -1, -1, -1, -1);
    try {
        Val val = Rapids.exec("(tmp= py_1 (:= data -1 2 (> (cols_py data 0) 0)))");
        if (val instanceof ValFrame) {
            Frame fr2 = val.getFrame();
            assertVecEquals(expected, fr2.vec(2), 0.00001);
            fr2.remove();
        }
    } finally {
        fr.remove();
        expected.remove();
    }
}
Also used : Val(water.rapids.Val) ValFrame(water.rapids.vals.ValFrame) ValFrame(water.rapids.vals.ValFrame) Frame(water.fvec.Frame) Vec(water.fvec.Vec) Test(org.junit.Test)

Aggregations

Val (water.rapids.Val)76 Frame (water.fvec.Frame)65 Test (org.junit.Test)56 ValFrame (water.rapids.vals.ValFrame)52 Vec (water.fvec.Vec)14 ValRow (water.rapids.vals.ValRow)8 MRTask (water.MRTask)5 Session (water.rapids.Session)5 Chunk (water.fvec.Chunk)4 TestFrameBuilder (water.fvec.TestFrameBuilder)4 ValNum (water.rapids.vals.ValNum)4 NewChunk (water.fvec.NewChunk)2 AstParameter (water.rapids.ast.AstParameter)2 AstNumList (water.rapids.ast.params.AstNumList)2 CreateFrame (hex.CreateFrame)1 GLRMParameters (hex.glrm.GLRMModel.GLRMParameters)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1