package ai.h2o.automl.transforms;

import ai.h2o.automl.TestUtil;
import org.junit.BeforeClass;
import org.junit.Test;
import water.Key;
import water.MRTask;
import water.fvec.Chunk;
import water.fvec.Frame;
import water.fvec.TransformWrappedVec;

public class TransformTest extends TestUtil {

  @BeforeClass public static void setup() { stall_till_cloudsize(1); }

  @Test public void testTransformReflection() {
    Transform.printOps();
  }

  @Test public void testExpr() {
    Frame fr=null;
    try {
      fr = parse_test_file(Key.make("a.hex"), "smalldata/iris.csv");

      Expr x = Expr.unOp("log", fr.vec(0));
      System.out.println(x.toRapids());

      TransformWrappedVec twv = x.toWrappedVec();
      System.out.println(twv.at(0));
      twv.remove();

      x.bop("-", x, 1);
      System.out.println(x.toRapids());
      System.out.println((twv = x.toWrappedVec()).at(0));
      twv.remove();

      x.bop("+", fr.vec(0), x);
      System.out.println(x.toRapids());
      System.out.println((twv=x.toWrappedVec()).at(0));
      twv.remove();

      x.bop("*", fr.vec(2), x);
      System.out.println(x.toRapids());
      System.out.println((twv=x.toWrappedVec()).at(0));
      twv.remove();

      x.uop("sqrt");
      System.out.println(x.toRapids());
      System.out.println((twv=x.toWrappedVec()).at(0));
      twv.remove();

      new MRTask() {
        @Override public void map(Chunk[] c) {
          // TODO: fill in
        }
      }.doAll(x.toWrappedVec(), fr.vec(0), fr.vec(2));

    } finally {
      if( null!=fr ) fr.delete();
    }

  }
}

@@ -134,54 +134,8 @@
 ey;%0A
-import water.MRTask;%0Aimport water.fvec.Chunk;%0A
 impo
@@ -1293,24 +1293,26 @@
 .remove();%0A%0A
+//
       new MR
@@ -1316,24 +1316,26 @@
  MRTask() %7B%0A
+//
         @Ove
@@ -1365,24 +1365,26 @@
 hunk%5B%5D c) %7B%0A
+//
           //
@@ -1384,11 +1384,8 @@
     
- //
  TOD
@@ -1395,16 +1395,18 @@
 fill in%0A
+//
         
@@ -1407,16 +1407,18 @@
       %7D%0A
+//
       %7D.

comment out empty mrtask