use of water.Key in project h2o-3 by h2oai.
the class ParserTestARFF method testReal.
@Test
public void testReal() {
String data = "@RELATION type\n" + "\n" + "@ATTRIBUTE num ReAl\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
double[][] exp = new double[][] { ard(0), ard(1.324e-13), ard(-2) };
Key k = ParserTest.makeByteVec(data);
ParserTest.testParsed(ParseDataset.parse(Key.make(), k), exp, 3);
}
use of water.Key in project h2o-3 by h2oai.
the class ParserTestARFF method testStringSplit.
@Test
public void testStringSplit() {
String data1 = "@RELATION type\n" + "\n" + "@ATTRIBUTE num STRING\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
String data2 = "4\n" + "5234234234\n" + "6\n";
Key k1 = ParserTest.makeByteVec(data1);
Key k2 = ParserTest.makeByteVec(data2);
Key[] k = new Key[] { k1, k2 };
Frame fr = ParseDataset.parse(Key.make(), k);
Assert.assertTrue(fr.anyVec().isString());
Assert.assertFalse(fr.anyVec().isCategorical());
Assert.assertFalse(fr.anyVec().isInt());
BufferedString tmpStr = new BufferedString();
Assert.assertTrue(fr.anyVec().atStr(tmpStr, 3).toString().equals("4"));
Assert.assertTrue(fr.anyVec().atStr(tmpStr, 4).toString().equals("5234234234"));
Assert.assertTrue(fr.anyVec().atStr(tmpStr, 5).toString().equals("6"));
fr.delete();
}
use of water.Key in project h2o-3 by h2oai.
the class ParserTestARFF method testMultipleFilesNum.
@Test
public void testMultipleFilesNum() {
String data1 = "@RELATION type\n" + "\n" + "@ATTRIBUTE num numeric\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
Key k1 = ParserTest.makeByteVec(data1);
Key k2 = ParserTest.makeByteVec(data1);
Key[] k = new Key[] { k1, k2 };
Frame fr = ParseDataset.parse(Key.make(), k);
Assert.assertFalse(fr.anyVec().isString());
Assert.assertFalse(fr.anyVec().isCategorical());
Assert.assertFalse(fr.anyVec().isInt());
Assert.assertFalse(fr.anyVec().isUUID());
Assert.assertTrue(fr.anyVec().at(0) == 0);
Assert.assertTrue(fr.anyVec().at(1) == 1.324e-13);
Assert.assertTrue(fr.anyVec().at(2) == -2);
Assert.assertTrue(fr.anyVec().at(3) == 0);
Assert.assertTrue(fr.anyVec().at(4) == 1.324e-13);
Assert.assertTrue(fr.anyVec().at(5) == -2);
fr.delete();
}
use of water.Key in project h2o-3 by h2oai.
the class ParserTestARFF method testInt.
@Test
public void testInt() {
String data = "@RELATION type\n" + "\n" + "@ATTRIBUTE num INT\n" + "\n" + "@DATA\n" + "0\n" + "1.324e-13\n" + "-2\n";
double[][] exp = new double[][] { ard(0), ard(1.324e-13), ard(-2) };
Key k = ParserTest.makeByteVec(data);
ParserTest.testParsed(ParseDataset.parse(Key.make(), k), exp, 3);
}
use of water.Key in project h2o-3 by h2oai.
the class VecDataInputStreamTest method makeRandomByteVec.
private static Vec makeRandomByteVec(Vec blueprint) {
final Vec v0 = new Vec(blueprint.group().addVec(), blueprint._rowLayout, null, Vec.T_NUM);
final int nchunks = v0.nChunks();
new MRTask() {
@Override
protected void setupLocal() {
for (int i = 0; i < nchunks; i++) {
Key k = v0.chunkKey(i);
if (k.home()) {
int len = (int) (v0.espc()[i + 1] - v0.espc()[i]);
byte[] bytes = new byte[len];
new Random(i).nextBytes(bytes);
DKV.put(k, new C1NChunk(bytes), _fs);
}
}
}
}.doAllNodes();
DKV.put(v0._key, v0);
return v0;
}
Aggregations