Commit 0268b6ab authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Update tests this should now fixthe checkmodel issues and increase coverage

parent 9e741515
......@@ -7,4 +7,3 @@ model = ModelClassifier(
str("models/train_dim_2_model_0.dat")
)
assert model.percent_error < 1e-7
assert model.percent_test_error < 1e-7
{
"desc_dim": 2,
"n_sis_select": 5,
"n_sis_select": 21,
"max_rung": 1,
"n_residual": 5,
"data_file": "data.csv",
......@@ -11,7 +11,25 @@
"n_rung_generate": 1,
"leave_out_inds": [],
"opset": ["sq"],
"param_opset": ["cb", "abs_diff", "div"],
"param_opset": [
"add",
"sub",
"abs_diff",
"mult",
"div",
"inv",
"abs",
"exp",
"log",
"sin",
"cos",
"sq",
"cb",
"six_pow",
"sqrt",
"cbrt",
"neg_exp"
],
"fix_intercept": true,
"reparam_residual": true,
"global_param_opt": false
......
Sample,task,property (m),A (m)
# Sample,task,property (m),A (m)
a,task_1,1.0,1.0
b,task_1,4.0,2.0
c,task_2,9.0,3.0
......
......@@ -189,6 +189,7 @@ namespace
EXPECT_THROW(inputs.phi_0(), std::logic_error);
EXPECT_THROW(inputs.phi_0_copy(), std::logic_error);
EXPECT_THROW(inputs.phi_0_ptrs(), std::logic_error);
inputs.set_phi_0(_phi_0);
EXPECT_EQ(inputs.phi_0()[0].feat_ind(), _phi_0[0].feat_ind());
EXPECT_EQ(inputs.phi_0_ptrs()[0]->feat_ind(), _phi_0[0].feat_ind());
......@@ -269,10 +270,7 @@ namespace
TEST_F(InputParserTests, FileConsructor)
{
boost::property_tree::ptree propTree;
boost::property_tree::json_parser::read_json(_filename, propTree);
propTree.put("data_file", _data_file);
InputParser inputs(propTree, _filename, mpi_setup::comm);
InputParser inputs(_filename);
EXPECT_EQ(inputs.sample_ids_train()[0], _sample_ids_train[0]);
EXPECT_EQ(inputs.sample_ids_test()[0], _sample_ids_test[0]);
EXPECT_EQ(inputs.task_names()[0], _task_names[0]);
......@@ -306,12 +304,86 @@ namespace
EXPECT_EQ(inputs.n_models_store(), _n_models_store);
EXPECT_EQ(inputs.fix_intercept(), _fix_intercept);
#ifdef PARAMETERIZE
#ifdef PARAMETERIZE
EXPECT_EQ(inputs.allowed_param_ops()[0], _allowed_param_ops[0]);
EXPECT_EQ(inputs.max_param_depth(), _max_param_depth);
EXPECT_EQ(inputs.nlopt_seed(), _nlopt_seed);
EXPECT_EQ(inputs.global_param_opt(), _global_param_opt);
EXPECT_EQ(inputs.reparam_residual(), _reparam_residual);
#endif
#endif
}
TEST_F(InputParserTests, CheckSizes)
{
InputParser inputs;
inputs.clear_data();
node_value_arrs::finalize_values_arr();
inputs.set_task_sizes_train({2, 2, 2});
EXPECT_THROW(inputs.set_task_sizes_test(_task_sizes_test), std::logic_error);
EXPECT_THROW(inputs.set_task_names({"A"}), std::logic_error);
EXPECT_THROW(inputs.set_prop_train(_prop_train), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_train(_sample_ids_train), std::logic_error);
EXPECT_THROW(inputs.set_phi_0((_phi_0)), std::logic_error);
inputs.clear_data();
inputs.set_task_sizes_test({2, 2, 2});
EXPECT_THROW(inputs.set_task_sizes_train(_task_sizes_train), std::logic_error);
EXPECT_THROW(inputs.set_task_names({"A"}), std::logic_error);
EXPECT_THROW(inputs.set_prop_test(_prop_test), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_test(_sample_ids_test), std::logic_error);
EXPECT_THROW(inputs.set_leave_out_inds(_leave_out_inds), std::logic_error);
EXPECT_THROW(inputs.set_phi_0((_phi_0)), std::logic_error);
inputs.clear_data();
inputs.set_task_names({"A", "B", "C", "D"});
EXPECT_THROW(inputs.set_task_sizes_train(_task_sizes_train), std::logic_error);
EXPECT_THROW(inputs.set_task_sizes_test(_task_sizes_test), std::logic_error);
inputs.clear_data();
inputs.set_prop_train(std::vector<double>(6, 0.0));
EXPECT_THROW(inputs.set_task_sizes_train(_task_sizes_train), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_train(_sample_ids_train), std::logic_error);
EXPECT_THROW(inputs.set_phi_0(_phi_0), std::logic_error);
inputs.clear_data();
inputs.set_sample_ids_train(std::vector<std::string>(6, "A"));
EXPECT_THROW(inputs.set_task_sizes_train(_task_sizes_train), std::logic_error);
EXPECT_THROW(inputs.set_prop_train(_prop_train), std::logic_error);
EXPECT_THROW(inputs.set_phi_0(_phi_0), std::logic_error);
inputs.clear_data();
inputs.set_prop_test(std::vector<double>(6, 0.0));
EXPECT_THROW(inputs.set_task_sizes_test(_task_sizes_test), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_test(_sample_ids_test), std::logic_error);
EXPECT_THROW(inputs.set_phi_0(_phi_0), std::logic_error);
EXPECT_THROW(inputs.set_leave_out_inds(_leave_out_inds), std::logic_error);
inputs.clear_data();
inputs.set_leave_out_inds({1, 2, 3});
EXPECT_THROW(inputs.set_task_sizes_test(_task_sizes_test), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_test(_sample_ids_test), std::logic_error);
EXPECT_THROW(inputs.set_phi_0(_phi_0), std::logic_error);
EXPECT_THROW(inputs.set_prop_test(_prop_test), std::logic_error);
inputs.clear_data();
inputs.set_sample_ids_test(std::vector<std::string>(6, "A"));
EXPECT_THROW(inputs.set_task_sizes_test(_task_sizes_test), std::logic_error);
EXPECT_THROW(inputs.set_prop_test(_prop_test), std::logic_error);
EXPECT_THROW(inputs.set_phi_0(_phi_0), std::logic_error);
EXPECT_THROW(inputs.set_leave_out_inds(_leave_out_inds), std::logic_error);
inputs.clear_data();
_phi_0 = {FeatureNode(0, "feat_1", {1.0, 2.0, 3.0, 4.0}, {5.0, 6.0}, Unit("m"))};
inputs.set_phi_0(_phi_0);
EXPECT_THROW(inputs.set_prop_train(_prop_train), std::logic_error);
EXPECT_THROW(inputs.set_task_sizes_train(_task_sizes_train), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_train(_sample_ids_train), std::logic_error);
EXPECT_THROW(inputs.set_prop_test(_prop_test), std::logic_error);
EXPECT_THROW(inputs.set_task_sizes_test(_task_sizes_test), std::logic_error);
EXPECT_THROW(inputs.set_sample_ids_test(_sample_ids_test), std::logic_error);
EXPECT_THROW(inputs.set_leave_out_inds(_leave_out_inds), std::logic_error);
inputs.clear_data();
}
}
......@@ -5,7 +5,8 @@
"n_residual": 1,
"n_models_store": 1,
"n_rung_store": 1,
"data_file": "googletest/inputs/data.csv",
"data_file_relatice_to_json": true,
"data_file": "data.csv",
"property_key": "property",
"task_key": "task",
"leave_out_inds": [3],
......
......@@ -5,7 +5,8 @@
"n_residual": 1,
"n_models_store": 1,
"n_rung_store": 1,
"data_file": "googletest/inputs/data.csv",
"data_file_relatice_to_json": true,
"data_file": "data.csv",
"property_key": "property",
"task_key": "task",
"leave_out_inds": [3],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment