Skip to content

Commit 8a273b5

Browse files
author
Michael McLeod
committed
More linting
1 parent b7121e9 commit 8a273b5

File tree

2 files changed

+15
-28
lines changed

2 files changed

+15
-28
lines changed

cpp/purify/yaml-parser.cc

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,10 @@ void YamlParser::parseAndSetGeneralConfiguration(const YAML::Node& generalConfig
119119
this->source_ = purify::utilities::vis_source::measurements;
120120
this->measurements_ = get_vector<std::vector<std::string>>(
121121
generalConfigNode, {"InputOutput", "input", "measurements", "measurements_files"});
122-
try
123-
{
124-
this->w_term_ = get<bool>(
125-
generalConfigNode, {"InputOutput", "input", "measurements", "w_term"});
126-
}
127-
catch(...)
128-
{
122+
try {
123+
this->w_term_ =
124+
get<bool>(generalConfigNode, {"InputOutput", "input", "measurements", "w_term"});
125+
} catch (...) {
129126
PURIFY_LOW_LOG("W-term flag not set for input measurements; defaulting to true.");
130127
this->w_term_ = true;
131128
}
@@ -210,8 +207,7 @@ void YamlParser::parseAndSetSARA(const YAML::Node& SARANode) {
210207

211208
void YamlParser::parseAndSetAlgorithmOptions(const YAML::Node& algorithmOptionsNode) {
212209
this->algorithm_ = get<std::string>(algorithmOptionsNode, {"algorithm"});
213-
if (this->algorithm_ == "padmm")
214-
{
210+
if (this->algorithm_ == "padmm") {
215211
this->epsilonConvergenceScaling_ =
216212
get<t_real>(algorithmOptionsNode, {"padmm", "epsilonConvergenceScaling"});
217213
this->mpiAlgorithm_ = factory::algo_distribution_string.at(
@@ -223,9 +219,7 @@ void YamlParser::parseAndSetAlgorithmOptions(const YAML::Node& algorithmOptionsN
223219
get<t_real>(algorithmOptionsNode, {"padmm", "stepsize", "update_tolerance"});
224220
this->dualFBVarianceConvergence_ =
225221
get<t_real>(algorithmOptionsNode, {"padmm", "dualFBVarianceConvergence"});
226-
}
227-
else if (this->algorithm_ == "fb" or this->algorithm_ == "fb_joint_map")
228-
{
222+
} else if (this->algorithm_ == "fb" or this->algorithm_ == "fb_joint_map") {
229223
this->mpiAlgorithm_ = factory::algo_distribution_string.at(
230224
get<std::string>(algorithmOptionsNode, {"fb", "mpiAlgorithm"}));
231225
this->relVarianceConvergence_ =
@@ -238,17 +232,17 @@ void YamlParser::parseAndSetAlgorithmOptions(const YAML::Node& algorithmOptionsN
238232

239233
this->nondiffFuncType_ = nondiff_type_string.at(
240234
get<std::string>(algorithmOptionsNode, {"fb", "nonDifferentiableFunctionType"}));
241-
if(this->nondiffFuncType_ == nondiff_func_type::Denoiser)
242-
{
235+
if (this->nondiffFuncType_ == nondiff_func_type::Denoiser) {
243236
this->model_path_ = get<std::string>(algorithmOptionsNode, {"fb", "modelPath"});
244237
}
245238

246239
this->diffFuncType_ = diff_type_string.at(
247240
get<std::string>(algorithmOptionsNode, {"fb", "differentiableFunctionType"}));
248-
if(this->diffFuncType_ == diff_func_type::L2Norm_with_CRR)
249-
{
250-
this->CRR_function_model_path_ = get<std::string>(algorithmOptionsNode, {"fb", "CRR_function_model_path"});
251-
this->CRR_gradient_model_path_ = get<std::string>(algorithmOptionsNode, {"fb", "CRR_gradient_model_path"});
241+
if (this->diffFuncType_ == diff_func_type::L2Norm_with_CRR) {
242+
this->CRR_function_model_path_ =
243+
get<std::string>(algorithmOptionsNode, {"fb", "CRR_function_model_path"});
244+
this->CRR_gradient_model_path_ =
245+
get<std::string>(algorithmOptionsNode, {"fb", "CRR_gradient_model_path"});
252246
this->CRR_mu_ = get<t_real>(algorithmOptionsNode, {"fb", "CRR_mu"});
253247
this->CRR_lambda_ = get<t_real>(algorithmOptionsNode, {"fb", "CRR_lambda"});
254248
}
@@ -264,9 +258,7 @@ void YamlParser::parseAndSetAlgorithmOptions(const YAML::Node& algorithmOptionsN
264258
get<t_real>(algorithmOptionsNode, {"fb", "joint_map_estimation", "alpha"});
265259
this->jmap_beta_ = get<t_real>(algorithmOptionsNode, {"fb", "joint_map_estimation", "beta"});
266260
}
267-
}
268-
else if (this->algorithm_ == "primaldual")
269-
{
261+
} else if (this->algorithm_ == "primaldual") {
270262
this->epsilonConvergenceScaling_ =
271263
get<t_real>(algorithmOptionsNode, {"primaldual", "epsilonConvergenceScaling"});
272264
this->mpiAlgorithm_ = factory::algo_distribution_string.at(
@@ -279,9 +271,7 @@ void YamlParser::parseAndSetAlgorithmOptions(const YAML::Node& algorithmOptionsN
279271
get<t_real>(algorithmOptionsNode, {"primaldual", "stepsize", "update_tolerance"});
280272
this->precondition_iters_ =
281273
get<t_int>(algorithmOptionsNode, {"primaldual", "precondition_iters"});
282-
}
283-
else
284-
{
274+
} else {
285275
throw std::runtime_error(
286276
"Only padmm algorithm configured for now. Please fill the appropriate block in the "
287277
"configuration file.");

cpp/purify/yaml-parser.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ class YamlParser {
149149
YAML_MACRO(t_real, CRR_mu, 20)
150150
YAML_MACRO(t_real, CRR_lambda, 5000)
151151

152-
std::string output_path() const
153-
{
154-
return out_path;
155-
}
152+
std::string output_path() const { return out_path; }
156153

157154
#undef YAML_MACRO
158155
private:

0 commit comments

Comments
 (0)