use of com.alibaba.alink.common.linalg.tensor.StringTensor in project Alink by alibaba.
the class ToTensorMapperTest method testStringType.
@Test
public void testStringType() throws Exception {
final Mapper mapper = new ToTensorMapper(new TableSchema(new String[] { "str" }, new TypeInformation<?>[] { Types.STRING }), new Params().set(ToTensorParams.SELECTED_COL, "str").set(ToTensorParams.TENSOR_DATA_TYPE, DataType.STRING));
Assert.assertEquals(TensorTypes.STRING_TENSOR, mapper.getOutputSchema().getFieldTypes()[0]);
final DoubleTensor tensor = DoubleTensor.of(TensorUtil.getTensor("FLOAT#6#0.0 0.1 1.0 1.1 2.0 2.1 "));
final StringTensor expect = new StringTensor(tensor.toString());
final Tensor<?> result = (Tensor<?>) mapper.map(Row.of(tensor.toString())).getField(0);
Assert.assertEquals(expect, result);
}
Aggregations