-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added check_input_matrices option to python bindings #2787
Changes from 13 commits
266ae6e
f1368e2
6ef1eca
22f5932
124d39d
e5bfb40
c3ff8d3
ee889c7
8a8f0ea
62c9f50
be82a0d
990ef53
7d6a209
aeb0f49
bfff19e
7056aeb
5e0a347
dc398bf
6ad120a
04dee7e
0e8e6f1
acc559f
654e650
33af71d
723ecf8
0c60d8c
141b92d
0d31176
954f3c4
f5b32bc
7ec4058
16ff91b
458b302
ab3110e
0914fe9
5b76b2f
3664422
23c3903
9a3815f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,3 +267,52 @@ void IO::ClearSettings() | |
GetSingleton().aliases = persistentAliases; | ||
GetSingleton().functionMap = persistentFunctions; | ||
} | ||
|
||
void IO::CheckInputMatrices() | ||
{ | ||
typedef typename std::tuple<data::DatasetInfo, arma::mat> TupleType; | ||
std::map<std::string, util::ParamData>::iterator itr; | ||
|
||
for (itr = IO::Parameters().begin(); itr != IO::Parameters().end(); ++itr) | ||
{ | ||
std::string paramName = itr->first; | ||
std::string paramType = itr->second.cppType; | ||
std::string errMsg = "The input " + paramName + " has NaN values."; | ||
if (paramType == "arma::mat") | ||
{ | ||
if (IO::GetParam<arma::Mat<double>>(paramName).has_nan()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it is a good idea, I have added the same. I decided to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @NippunSharma maybe now it makes sense to split out the body of each if statement into a templated function? The bodies of each if statement are basically identical, so it would be great if we could capture that identical functionality in one standalone function. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that will reduce the repetitive code. I have added |
||
Log::Fatal << errMsg << std::endl; | ||
} | ||
else if (paramType == "arma::Mat<size_t>") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think now you can remove these |
||
{ | ||
if (IO::GetParam<arma::Mat<size_t>>(paramName).has_nan()) | ||
Log::Fatal << errMsg << std::endl; | ||
} | ||
else if (paramType == "arma::colvec") | ||
{ | ||
if (IO::GetParam<arma::Col<double>>(paramName).has_nan()) | ||
Log::Fatal << errMsg << std::endl; | ||
} | ||
else if (paramType == "arma::Col<size_t>") | ||
{ | ||
if (IO::GetParam<arma::Col<size_t>>(paramName).has_nan()) | ||
Log::Fatal << errMsg << std::endl; | ||
} | ||
else if (paramType == "arma::rowvec") | ||
{ | ||
if (IO::GetParam<arma::Row<double>>(paramName).has_nan()) | ||
Log::Fatal << errMsg << std::endl; | ||
} | ||
else if (paramType == "arma::Row<size_t>") | ||
{ | ||
if (IO::GetParam<arma::Row<size_t>>(paramName).has_nan()) | ||
Log::Fatal << errMsg << std::endl; | ||
} | ||
else if (paramType == "std::tuple<data::DatasetInfo, arma::mat>") | ||
{ | ||
if (std::get<1>(IO::GetParam<TupleType>(paramName)).has_nan()) | ||
Log::Fatal << errMsg << std::endl; | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra space.