From 6ba0adcb8051583c892a7f1120c87276e7cf1a11 Mon Sep 17 00:00:00 2001 From: Albin Joy Date: Fri, 11 Jan 2019 17:40:47 +0530 Subject: [PATCH] Additional test on make_csv_dataset Verify the delim and NAvalue are compatible with different inputs. --- .../kernel_tests/make_csv_dataset_test.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py b/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py index 3b7b335e706..14677fa6bf4 100644 --- a/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py +++ b/tensorflow/python/data/experimental/kernel_tests/make_csv_dataset_test.py @@ -449,6 +449,29 @@ class MakeCsvDatasetTest(test_base.DatasetTestBase): header=True, ) + def testMakeCSVDataset_withNAValuesAndFieldDelim(self): + """Tests that datasets can be created from different delim and na_value. + """ + column_names = ["col%d" % i for i in range(5)] + inputs = [["0 1 2 3 4", "5 6 7 8 9"], ["10 11 12 13 14", "15 16 17 ? 19"]] + expected_output = [[0, 1, 2, 3, 4], [5, 6, 7, 8, 9], + [10, 11, 12, 13, 14], [15, 16, 17, 0, 19]] + label = "col0" + + self._test_dataset( + inputs, + expected_output=expected_output, + expected_keys=column_names, + column_names=column_names, + label_name=label, + batch_size=1, + num_epochs=1, + shuffle=False, + header=False, + na_value="?", + field_delim=" ", + ) + def testMakeCSVDataset_withSelectCols(self): record_defaults = [ constant_op.constant([], dtypes.int32),