Skip to content

Commit

Permalink
Change naming per seth's recommendation and make use of aliases
Browse files Browse the repository at this point in the history
more consistent.
  • Loading branch information
akleeman committed Jul 19, 2018
1 parent 46b84cf commit 6203305
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
14 changes: 7 additions & 7 deletions albatross/core/parameter_handling_mixin.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ class ParameterHandlingMixin {
}
}

void set_param_values(const std::map<std::string, ParameterValue> &params) {
for (const auto &pair : params) {
void set_param_values(const std::map<ParameterKey, ParameterValue> &values) {
for (const auto &pair : values) {
check_param_key(pair.first);
unchecked_set_param(pair.first, pair.second);
}
}

void set_param(const ParameterKey &key, const ParameterValue &value) {
void set_param_value(const ParameterKey &key, const ParameterValue &value) {
check_param_key(key);
unchecked_set_param(key, value);
}
Expand Down Expand Up @@ -249,17 +249,17 @@ class ParameterHandlingMixin {
}
}

ParameterValue get_param_value(const std::string &name) const {
ParameterValue get_param_value(const ParameterKey &name) const {
return get_params().at(name).value;
}

void unchecked_set_param(const std::string &name,
void unchecked_set_param(const ParameterKey &name,
const ParameterValue value) {
Parameter param = {value, get_params()[name].prior};
unchecked_set_param(name, param);
}

void unchecked_set_prior(const std::string &name,
void unchecked_set_prior(const ParameterKey &name,
const ParameterPrior &prior) {
Parameter param = {get_params()[name].value, prior};
unchecked_set_param(name, param);
Expand Down Expand Up @@ -288,7 +288,7 @@ class ParameterHandlingMixin {

virtual ParameterStore get_params() const { return params_; }

virtual void unchecked_set_param(const std::string &name,
virtual void unchecked_set_param(const ParameterKey &name,
const Parameter &param) {
params_[name] = param;
}
Expand Down
8 changes: 6 additions & 2 deletions albatross/covariance_functions/covariance_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,12 @@ template <typename Term> struct CovarianceFunction {
inline auto set_params(const ParameterStore &params) {
return term.set_params(params);
};
inline auto set_param(const ParameterKey &key, const ParameterValue &value) {
return term.set_param(key, value);
inline auto set_param_values(const std::map<ParameterKey, ParameterValue> &values) {
return term.set_param_values(values);
};
inline auto set_param_value(const ParameterKey &key,
const ParameterValue &value) {
return term.set_param_value(key, value);
};
inline auto set_param(const ParameterKey &key, const Parameter &param) {
return term.set_param(key, param);
Expand Down
2 changes: 1 addition & 1 deletion albatross/covariance_functions/covariance_term.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class CombinationOfCovarianceTerms : public CovarianceTerm {
return map_join(lhs_.get_params(), rhs_.get_params());
}

void unchecked_set_param(const std::string &name,
void unchecked_set_param(const ParameterKey &name,
const Parameter &param) override {
if (map_contains(lhs_.get_params(), name)) {
lhs_.set_param(name, param);
Expand Down
6 changes: 5 additions & 1 deletion albatross/covariance_functions/scaling_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ template <typename ScalingFunction> class ScalingTerm : public CovarianceTerm {
scaling_function_.set_params(params);
}

void set_param_values(const std::map<ParameterKey, ParameterValue> &values) {
scaling_function_.set_param_values(values);
}

virtual ParameterStore get_params() const override {
return scaling_function_.get_params();
}
Expand All @@ -94,7 +98,7 @@ template <typename ScalingFunction> class ScalingTerm : public CovarianceTerm {
archive(cereal::make_nvp("scaling_function", scaling_function_));
}

void unchecked_set_param(const std::string &name,
void unchecked_set_param(const ParameterKey &name,
const Parameter &param) override {
scaling_function_.set_param(name, param);
}
Expand Down

0 comments on commit 6203305

Please sign in to comment.