package water.util;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import water.DKV;
import water.TestUtil;
import water.fvec.Frame;
/**
* Test VecUtils interface.
*/
public class VecUtilsTest extends TestUtil {
@BeforeClass
static public void setup() { stall_till_cloudsize(1); }
@Test
public void testStringVec2Categorical() {
Frame f = parse_test_file("smalldata/junit/iris.csv");
try {
Assert.assertTrue(f.vec(4).isCategorical());
int categoricalCnt = f.vec(4).cardinality();
f.replace(4, f.vec(4).toStringVec()).remove();
DKV.put(f);
Assert.assertTrue(f.vec(4).isString());
f.replace(4, f.vec(4).toCategoricalVec()).remove();
DKV.put(f);
Assert.assertTrue(f.vec(4).isCategorical());
Assert.assertEquals(categoricalCnt, f.vec(4).cardinality());
} finally {
f.delete();
}
}
}