def test_valency(self):
data = ('11|12,"this is a ,text",categorical_value|other_value,1|3,89.0|'
'91.0,12.0|15.0,False')
feature_spec = self._INPUT_SCHEMA.as_feature_spec().copy()
feature_spec['numeric1'] = tf.FixedLenFeature(shape=[2], dtype=tf.int64)
schema = dataset_schema.from_feature_spec(feature_spec)
multivalent_columns = ['numeric1', 'numeric2', 'y']
coder = csv_coder.CsvCoder(self._COLUMNS, schema,
delimiter=',', secondary_delimiter='|',
multivalent_columns=multivalent_columns)
expected_decoded = {'category1': ['categorical_value|other_value'],
'numeric1': [11, 12],
'numeric2': [89.0, 91.0],
'boolean1': [False],
'text1': 'this is a ,text',
'y': ([1, 3], [12.0, 15.0])}
self._assert_encode_decode(coder, data, expected_decoded)
# Test successful decoding with a single column.
评论列表
文章目录