Skip to content
Snippets Groups Projects
Commit 85621f27 authored by Martin Beseda's avatar Martin Beseda
Browse files

ENH: Added data check before creating a new DataSet - prevents SEGFAULTs...

ENH: Added data check before creating a new DataSet - prevents SEGFAULTs occuring when read() method was not called beforehand.
parent ffa62c92
No related branches found
No related tags found
No related merge requests found
......@@ -80,10 +80,15 @@ namespace lib4neuro {
std::vector<std::pair<std::vector<double>, std::vector<double>>> data_set_contents;
for(auto line : *this->data) {
if(this->data->empty()) {
THROW_LOGIC_ERROR("DataSet can not be created as there were no data read beforehand! Did you forget to call "
"the method 'read()'?");
}
for (auto line : *this->data) {
//TODO check empty values in data
std::vector<double> input;
for(auto ind : *input_col_indices) {
for (auto ind : *input_col_indices) {
std::string s;
try {
......@@ -102,16 +107,17 @@ namespace lib4neuro {
/* Add loaded number to the vector of inputs */
input.push_back(tmp);
} catch(const std::out_of_range& e) {
} catch (const std::out_of_range& e) {
THROW_OUT_OF_RANGE_ERROR("Non-existing index specified (" + std::to_string(ind) + ")!");
} catch (const boost::bad_lexical_cast& e) {
THROW_RUNTIME_ERROR("Value \"" + s + "\" is not numerical and so it cannot be used in Data Set!");
THROW_RUNTIME_ERROR(
"Value \"" + s + "\" is not numerical and so it cannot be used in Data Set!");
}
}
std::vector<double> output;
for(auto ind : *output_col_indices) {
for (auto ind : *output_col_indices) {
output.emplace_back(std::stod(line.at(ind)));
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment