mlpack
Classes | Functions
load_save_test.cpp File Reference
#include <sstream>
#include <mlpack/core.hpp>
#include <mlpack/core/data/load_arff.hpp>
#include <mlpack/core/data/map_policies/missing_policy.hpp>
#include "catch.hpp"
#include "test_catch_tools.hpp"
Include dependency graph for load_save_test.cpp:

Classes

class  TestInner
 
class  Test
 

Functions

 TEST_CASE ("NoExtensionLoad", "[LoadSaveTest]")
 Make sure failure occurs when no extension given.
 
 TEST_CASE ("NoExtensionSave", "[LoadSaveTest]")
 Make sure failure occurs when no extension given.
 
 TEST_CASE ("NotExistLoad", "[LoadSaveTest]")
 Make sure load fails if the file does not exist.
 
 TEST_CASE ("WrongExtensionWrongLoad", "[LoadSaveTest]")
 Make sure load fails if the file extension is wrong in automatic detection mode.
 
 TEST_CASE ("WrongExtensionCorrectLoad", "[LoadSaveTest]")
 Make sure load is successful even if the file extension is wrong when file type is specified.
 
 TEST_CASE ("LoadCSVTest", "[LoadSaveTest]")
 Make sure a CSV is loaded correctly.
 
 TEST_CASE ("LoadSparseTSVTest", "[LoadSaveTest]")
 Make sure a TSV is loaded correctly to a sparse matrix.
 
 TEST_CASE ("LoadSparseTXTTest", "[LoadSaveTest]")
 Make sure a CSV in text format is loaded correctly to a sparse matrix.
 
 TEST_CASE ("LoadTSVTest", "[LoadSaveTest]")
 Make sure a TSV is loaded correctly.
 
 TEST_CASE ("LoadTSVExtensionTest", "[LoadSaveTest]")
 Test TSV loading with .tsv extension.
 
 TEST_CASE ("LoadAnyExtensionFileTest", "[LoadSaveTest]")
 Test that we can manually specify the format for loading.
 
 TEST_CASE ("SaveCSVTest", "[LoadSaveTest]")
 Make sure a CSV is saved correctly.
 
 TEST_CASE ("SaveSparseTSVTest", "[LoadSaveTest]")
 Make sure a TSV is saved correctly for a sparse matrix.
 
 TEST_CASE ("SaveSparseTXTTest", "[LoadSaveTest]")
 Make sure a TXT is saved correctly for a sparse matrix.
 
 TEST_CASE ("SaveSparseBinaryTest", "[LoadSaveTest]")
 Make sure a Sparse Matrix is saved and loaded correctly in binary format.
 
 TEST_CASE ("LoadTransposedCSVTest", "[LoadSaveTest]")
 Make sure CSVs can be loaded in transposed form.
 
 TEST_CASE ("LoadColVecCSVTest", "[LoadSaveTest]")
 Make sure ColVec can be loaded.
 
 TEST_CASE ("LoadColVecTransposedCSVTest", "[LoadSaveTest]")
 Make sure we can load a transposed column vector.
 
 TEST_CASE ("LoadQuotedStringInCSVTest", "[LoadSaveTest]")
 Make sure besides numeric data "quoted strings" or 'quoted strings' in csv files are loaded correctly.
 
 TEST_CASE ("LoadQuotedStringInTXTTest", "[LoadSaveTest]")
 Make sure besides numeric data "quoted strings" or 'quoted strings' in txt files are loaded correctly.
 
 TEST_CASE ("LoadQuotedStringInTSVTest", "[LoadSaveTest]")
 Make sure besides numeric data "quoted strings" or 'quoted strings' in tsv files are loaded correctly.
 
 TEST_CASE ("LoadMatinVec", "[LoadSaveTest]")
 Make sure Load() throws an exception when trying to load a matrix into a colvec or rowvec. More...
 
 TEST_CASE ("LoadRowVecCSVTest", "[LoadSaveTest]")
 Make sure that rowvecs can be loaded successfully.
 
 TEST_CASE ("LoadRowVecTransposedCSVTest", "[LoadSaveTest]")
 Make sure that we can load transposed row vectors.
 
 TEST_CASE ("LoadTransposedTSVTest", "[LoadSaveTest]")
 Make sure TSVs can be loaded in transposed form.
 
 TEST_CASE ("LoadTransposedTSVExtensionTest", "[LoadSaveTest]")
 Check TSV loading with .tsv extension.
 
 TEST_CASE ("LoadNonTransposedCSVTest", "[LoadSaveTest]")
 Make sure CSVs can be loaded in non-transposed form.
 
 TEST_CASE ("SaveNonTransposedCSVTest", "[LoadSaveTest]")
 Make sure CSVs can be saved in non-transposed form.
 
 TEST_CASE ("LoadArmaASCIITest", "[LoadSaveTest]")
 Make sure arma_ascii is loaded correctly.
 
 TEST_CASE ("SaveArmaASCIITest", "[LoadSaveTest]")
 Make sure a CSV is saved correctly.
 
 TEST_CASE ("LoadRawASCIITest", "[LoadSaveTest]")
 Make sure raw_ascii is loaded correctly.
 
 TEST_CASE ("LoadCSVTxtTest", "[LoadSaveTest]")
 Make sure CSV is loaded correctly as .txt.
 
 TEST_CASE ("LoadArmaBinaryTest", "[LoadSaveTest]")
 Make sure arma_binary is loaded correctly.
 
 TEST_CASE ("SaveArmaBinaryTest", "[LoadSaveTest]")
 Make sure arma_binary is saved correctly.
 
 TEST_CASE ("SaveArmaBinaryArbitraryExtensionTest", "[LoadSaveTest]")
 Make sure that we can manually specify the format.
 
 TEST_CASE ("LoadRawBinaryTest", "[LoadSaveTest]")
 Make sure raw_binary is loaded correctly.
 
 TEST_CASE ("LoadPGMBinaryTest", "[LoadSaveTest]")
 Make sure load as PGM is successful.
 
 TEST_CASE ("SavePGMBinaryTest", "[LoadSaveTest]")
 Make sure save as PGM is successful.
 
 TEST_CASE ("NormalizeLabelSmallDatasetTest", "[LoadSaveTest]")
 Test normalization of labels.
 
 TEST_CASE ("NormalizeLabelTest", "[LoadSaveTest]")
 Harder label normalization test.
 
 TEST_CASE ("LoadBinaryTest", "[LoadSaveTest]")
 Make sure we can load and save.
 
 TEST_CASE ("LoadXMLTest", "[LoadSaveTest]")
 Make sure we can load and save.
 
 TEST_CASE ("LoadJsonTest", "[LoadSaveTest]")
 Make sure we can load and save.
 
 TEST_CASE ("DatasetInfoTest", "[LoadSaveTest]")
 Test DatasetInfo by making a map for a dimension.
 
 TEST_CASE ("RegularCSVDatasetInfoLoad", "[LoadSaveTest]")
 Test loading regular CSV with DatasetInfo. More...
 
 TEST_CASE ("NontransposedCSVDatasetInfoLoad", "[LoadSaveTest]")
 Test non-transposed loading of regular CSVs with DatasetInfo. More...
 
 TEST_CASE ("CategoricalCSVLoadTest00", "[LoadSaveTest]")
 Create a file with a categorical string feature, then load it.
 
 TEST_CASE ("CategoricalCSVLoadTest01", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalCSVLoadTest02", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalCSVLoadTest03", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalCSVLoadTest04", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalNontransposedCSVLoadTest00", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalNontransposedCSVLoadTest01", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalNontransposedCSVLoadTest02", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalNontransposedCSVLoadTest03", "[LoadSaveTest]")
 
 TEST_CASE ("CategoricalNontransposedCSVLoadTest04", "[LoadSaveTest]")
 
 TEST_CASE ("HarderKeonTest", "[LoadSaveTest]")
 A harder test CSV based on the concerns in #658.
 
 TEST_CASE ("SimpleARFFTest", "[LoadSaveTest]")
 A simple ARFF load test. More...
 
 TEST_CASE ("SimpleARFFCategoricalTest", "[LoadSaveTest]")
 Another simple ARFF load test. More...
 
 TEST_CASE ("HarderARFFTest", "[LoadSaveTest]")
 A harder ARFF test, where we have each type of supported value, and some random whitespace too.
 
 TEST_CASE ("BadDatasetInfoARFFTest", "[LoadSaveTest]")
 If we pass a bad DatasetInfo, it should throw.
 
 TEST_CASE ("NonExistentFileARFFTest", "[LoadSaveTest]")
 If file is not found, it should throw.
 
 TEST_CASE ("CaseTest", "[LoadSaveTest]")
 A test to check whether the arff loader is case insensitive to declarations: , , .
 
 TEST_CASE ("CategoryCaseTest", "[LoadSaveTest]")
 Ensure that a failure happens if we set a category to use capital letters but it receives them in lowercase.
 
 TEST_CASE ("MalformedCSVTest", "[LoadSaveTest]")
 Test that a CSV with the wrong number of columns fails.
 
 TEST_CASE ("LoadCSVTSVTest", "[LoadSaveTest]")
 Test that a TSV can load with LoadCSV.
 
 TEST_CASE ("LoadCSVTXTTest", "[LoadSaveTest]")
 Test that a text file can load with LoadCSV.
 
 TEST_CASE ("MalformedNoTransposeCSVTest", "[LoadSaveTest]")
 Test that a non-transposed CSV with the wrong number of columns fails.
 
 TEST_CASE ("LoadCSVNoTransposeTSVTest", "[LoadSaveTest]")
 Test that a non-transposed TSV can load with LoadCSV.
 
 TEST_CASE ("LoadCSVNoTransposeTXTTest", "[LoadSaveTest]")
 Test that a non-transposed text file can load with LoadCSV.
 
 TEST_CASE ("DatasetMapperNonUniqueTest", "[LoadSaveTest]")
 Make sure DatasetMapper properly unmaps from non-unique strings.
 
 TEST_CASE ("LoadCSVHeaderTest", "[LoadSaveTest]")
 Make sure if we load a CSV with a header, that that header doesn't get loaded as a point.
 

Detailed Description

Author
Ryan Curtin

Tests for data::Load() and data::Save().

mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.

Function Documentation

◆ TEST_CASE() [1/5]

TEST_CASE ( "LoadMatinVec"  ,
""  [LoadSaveTest] 
)

Make sure Load() throws an exception when trying to load a matrix into a colvec or rowvec.

Log::Fatal will be called when the matrix is not of the right size.

◆ TEST_CASE() [2/5]

TEST_CASE ( "RegularCSVDatasetInfoLoad"  ,
""  [LoadSaveTest] 
)

Test loading regular CSV with DatasetInfo.

Everything should be numeric.

◆ TEST_CASE() [3/5]

TEST_CASE ( "NontransposedCSVDatasetInfoLoad"  ,
""  [LoadSaveTest] 
)

Test non-transposed loading of regular CSVs with DatasetInfo.

Everything should be numeric.

◆ TEST_CASE() [4/5]

TEST_CASE ( "SimpleARFFTest"  ,
""  [LoadSaveTest] 
)

A simple ARFF load test.

Two attributes, both numeric.

◆ TEST_CASE() [5/5]

TEST_CASE ( "SimpleARFFCategoricalTest"  ,
""  [LoadSaveTest] 
)

Another simple ARFF load test.

Three attributes, two categorical, one numeric.