From 8f803f17b666e8066380e9058ae2ecf1218c5bdd Mon Sep 17 00:00:00 2001 From: ChristineStawitz-NOAA Date: Tue, 31 Oct 2023 23:18:10 +0000 Subject: [PATCH] style: run clang format --- inst/include/common/fims_math.hpp | 23 +++++---- inst/include/common/information.hpp | 50 ++++++++++--------- .../functors/tmb_distributions.hpp | 4 +- .../interface/rcpp/rcpp_objects/rcpp_data.hpp | 3 +- .../population_dynamics/fleet/fleet.hpp | 7 +-- .../growth/functors/ewaa.hpp | 2 +- .../growth/functors/growth_base.hpp | 2 +- .../maturity/functors/logistic.hpp | 4 +- .../maturity/functors/maturity_base.hpp | 2 +- .../population/population.hpp | 12 +++-- .../population/subpopulation.hpp | 2 +- .../recruitment/functors/recruitment_base.hpp | 2 +- .../recruitment/functors/sr_beverton_holt.hpp | 2 +- .../selectivity/functors/double_logistic.hpp | 4 +- .../selectivity/functors/logistic.hpp | 2 +- .../selectivity/functors/selectivity_base.hpp | 2 +- tests/gtest/test_population_test_fixture.hpp | 3 +- 17 files changed, 67 insertions(+), 59 deletions(-) diff --git a/inst/include/common/fims_math.hpp b/inst/include/common/fims_math.hpp index abf79c73e..0250f4ddc 100644 --- a/inst/include/common/fims_math.hpp +++ b/inst/include/common/fims_math.hpp @@ -26,8 +26,8 @@ namespace fims_math { /** * @brief The exponential function. * - * @param x value to exponentiate. Please use fims_math::exp(x) if x is an - * integer. + * @param x value to exponentiate. Please use fims_math::exp(x) if x is + * an integer. * @return the exponentiated value */ template @@ -37,8 +37,8 @@ inline const Type exp(const Type &x) { /** * @brief The natural log function (base e) - * @param x the value to take the log of. Please use fims_math::log(x) if x - * is an integer. + * @param x the value to take the log of. Please use fims_math::log(x) + * if x is an integer. * @return */ template @@ -54,8 +54,8 @@ inline const Type log(const Type &x) { * @brief The exponential function. * The code cannot be tested using the compilation flag * -DTMB_MODEL through CMake and Google Test - * @param x value to exponentiate. Please use fims_math::exp(x) if x is an - * integer. + * @param x value to exponentiate. Please use fims_math::exp(x) if x is + * an integer. * @return the exponentiated value */ template @@ -73,8 +73,8 @@ inline const double exp(const double &x) { * @brief The natural log function (base e) * The code cannot be tested using the compilation flag * -DTMB_MODEL through CMake and Google Test. - * @param x the value to take the log of. Please use fims_math::log(x) if x - * is an integer. + * @param x the value to take the log of. Please use fims_math::log(x) + * if x is an integer. * @return the log of the value */ template @@ -100,7 +100,8 @@ inline const double log(const double &x) { * @return */ template -inline const Type logistic(const Type &median, const Type &slope, const Type &x) { +inline const Type logistic(const Type &median, const Type &slope, + const Type &x) { return (1.0) / (1.0 + exp(-1.0 * slope * (x - median))); } @@ -155,8 +156,8 @@ inline const Type inv_logit(const Type &a, const Type &b, const Type &logit_x) { template inline const Type double_logistic(const Type &median_asc, const Type &slope_asc, - const Type &median_desc, const Type &slope_desc, - const Type &x) { + const Type &median_desc, + const Type &slope_desc, const Type &x) { return (1.0) / (1.0 + exp(-1.0 * slope_asc * (x - median_asc))) * (1.0 - (1.0) / (1.0 + exp(-1.0 * slope_desc * (x - median_desc)))); } diff --git a/inst/include/common/information.hpp b/inst/include/common/information.hpp index 0734fb5c7..8dd49deb9 100644 --- a/inst/include/common/information.hpp +++ b/inst/include/common/information.hpp @@ -36,7 +36,7 @@ class Information { size_t nages; /**< number of ages>*/ static std::shared_ptr > - fims_information; /**< singleton instance >*/ + fims_information; /**< singleton instance >*/ std::vector parameters; /**< list of all estimated parameters >*/ std::vector random_effects_parameters; /**< list of all random effects parameters >*/ @@ -46,42 +46,40 @@ class Information { // data objects std::map > > data_objects; /*!< map that holds data objects >*/ - typedef typename std::map > >::iterator + typedef typename std::map< + uint32_t, std::shared_ptr > >::iterator data_iterator; /**< iterator for the data objects */ // life history modules std::map > > recruitment_models; /*! > >::iterator - recruitment_models_iterator; + typedef typename std::map< + uint32_t, std::shared_ptr > >::iterator + recruitment_models_iterator; /**< iterator for recruitment objects>*/ std::map > > selectivity_models; /*! > >::iterator - selectivity_models_iterator; + typedef typename std::map< + uint32_t, std::shared_ptr > >::iterator + selectivity_models_iterator; /**< iterator for selectivity objects>*/ std::map > > growth_models; /*! > >::iterator + typedef typename std::map< + uint32_t, std::shared_ptr > >::iterator growth_models_iterator; /**< iterator for growth objects>*/ std::map > > maturity_models; /*! > >::iterator + typedef typename std::map< + uint32_t, std::shared_ptr > >::iterator maturity_models_iterator; /**< iterator for maturity objects>*/ @@ -90,7 +88,8 @@ class Information { fleets; /*! > >::iterator + typename std::map > >::iterator fleet_iterator; /**< iterator for fleet objects>*/ @@ -98,19 +97,20 @@ class Information { std::map > > populations; /*! > >::iterator + typedef typename std::map< + uint32_t, std::shared_ptr > >::iterator population_iterator; /**< iterator for population objects>*/ // distributions - std::map > > + std::map > > distribution_models; /*! > >::iterator - distribution_models_iterator; + typedef typename std::map< + uint32_t, + std::shared_ptr > >::iterator + distribution_models_iterator; /**< iterator for distribution objects>*/ Information() {} @@ -135,7 +135,9 @@ class Information { * * @param p */ - void RegisterParameter(Type& p) { this->fixed_effects_parameters.push_back(&p); } + void RegisterParameter(Type& p) { + this->fixed_effects_parameters.push_back(&p); + } /** * Register a random effect as estimable. diff --git a/inst/include/distributions/functors/tmb_distributions.hpp b/inst/include/distributions/functors/tmb_distributions.hpp index f0fa4b5ad..b1c359af6 100644 --- a/inst/include/distributions/functors/tmb_distributions.hpp +++ b/inst/include/distributions/functors/tmb_distributions.hpp @@ -22,8 +22,8 @@ template struct Dnorm : public DistributionsBase { Type x; /*!< observation */ Type mean; /*!< mean of the normal distribution */ - Type sd; /*!< standard deviation of the normal distribution, must be strictly - positive.*/ + Type sd; /*!< standard deviation of the normal distribution, must be strictly + positive.*/ Dnorm() : DistributionsBase() {} diff --git a/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp b/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp index 428c38b34..d3cd9e955 100644 --- a/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp +++ b/inst/include/interface/rcpp/rcpp_objects/rcpp_data.hpp @@ -86,7 +86,8 @@ class AgeCompDataInterface : public DataInterfaceBase { template bool add_to_fims_tmb_internal() { std::shared_ptr> age_comp_data = - std::make_shared>(this->ymax, this->amax); + std::make_shared>(this->ymax, + this->amax); age_comp_data->id = this->id; for (int y = 0; y < ymax; y++) { diff --git a/inst/include/population_dynamics/fleet/fleet.hpp b/inst/include/population_dynamics/fleet/fleet.hpp index 5713775c0..041b840d3 100644 --- a/inst/include/population_dynamics/fleet/fleet.hpp +++ b/inst/include/population_dynamics/fleet/fleet.hpp @@ -153,9 +153,10 @@ struct Fleet : public fims_model_object::FIMSObject { size_t dims = this->observed_agecomp_data->get_imax() * this->observed_agecomp_data->get_jmax(); if (dims != this->catch_numbers_at_age.size()) { - fims::fims_log::get("fleet.log") << "Error: observed age comp is of size " - << dims << " and expected is of size " - << this->age_composition.size() << std::endl; + fims::fims_log::get("fleet.log") + << "Error: observed age comp is of size " << dims + << " and expected is of size " << this->age_composition.size() + << std::endl; } else { for (size_t y = 0; y < this->nyears; y++) { // EigenVector declares a vector type from the Eigen library, which is diff --git a/inst/include/population_dynamics/growth/functors/ewaa.hpp b/inst/include/population_dynamics/growth/functors/ewaa.hpp index ba6ba4565..92454ac4e 100644 --- a/inst/include/population_dynamics/growth/functors/ewaa.hpp +++ b/inst/include/population_dynamics/growth/functors/ewaa.hpp @@ -43,5 +43,5 @@ struct EWAAgrowth : public GrowthBase { return ret; } }; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_GROWTH_EWAA_HPP */ \ No newline at end of file diff --git a/inst/include/population_dynamics/growth/functors/growth_base.hpp b/inst/include/population_dynamics/growth/functors/growth_base.hpp index ccff6d2f1..a6da2de1f 100644 --- a/inst/include/population_dynamics/growth/functors/growth_base.hpp +++ b/inst/include/population_dynamics/growth/functors/growth_base.hpp @@ -48,6 +48,6 @@ struct GrowthBase : public fims_model_object::FIMSObject { template uint32_t GrowthBase::id_g = 0; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_GROWTH_BASE_HPP */ diff --git a/inst/include/population_dynamics/maturity/functors/logistic.hpp b/inst/include/population_dynamics/maturity/functors/logistic.hpp index fa8a5ed22..0110e083f 100644 --- a/inst/include/population_dynamics/maturity/functors/logistic.hpp +++ b/inst/include/population_dynamics/maturity/functors/logistic.hpp @@ -37,11 +37,11 @@ struct LogisticMaturity : public MaturityBase { * @param x The independent variable in the logistic function (e.g., age or * size at maturity). */ - virtual const Type evaluate(const Type & x) { + virtual const Type evaluate(const Type& x) { return fims_math::logistic(median, slope, x); } }; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_MATURITY_LOGISTIC_HPP */ diff --git a/inst/include/population_dynamics/maturity/functors/maturity_base.hpp b/inst/include/population_dynamics/maturity/functors/maturity_base.hpp index 8663ffd15..402233dfc 100644 --- a/inst/include/population_dynamics/maturity/functors/maturity_base.hpp +++ b/inst/include/population_dynamics/maturity/functors/maturity_base.hpp @@ -50,6 +50,6 @@ struct MaturityBase : public fims_model_object::FIMSObject { template uint32_t MaturityBase::id_g = 0; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_MATURITY_BASE_HPP */ diff --git a/inst/include/population_dynamics/population/population.hpp b/inst/include/population_dynamics/population/population.hpp index 4997adef8..33bee66d7 100644 --- a/inst/include/population_dynamics/population/population.hpp +++ b/inst/include/population_dynamics/population/population.hpp @@ -35,8 +35,8 @@ directly?) template struct Population : public fims_model_object::FIMSObject { using ParameterVector = - typename fims::ModelTraits::ParameterVector; /*!< the vector of population - parameters*/ + typename fims::ModelTraits::ParameterVector; /*!< the vector of + population parameters*/ static uint32_t id_g; /*!< reference id for population object*/ size_t nyears; /*!< total number of years in the fishery*/ size_t nseasons; /*!< total number of seasons in the fishery*/ @@ -106,12 +106,14 @@ struct Population : public fims_model_object::FIMSObject { // Define objective function object to be able to REPORT and ADREPORT #ifdef TMB_MODEL - ::objective_function *of; // :: references global namespace, defined in src/FIMS.cpp, available anywhere in the R package + ::objective_function + *of; // :: references global namespace, defined in src/FIMS.cpp, + // available anywhere in the R package #endif // this -> means you're referring to a class member (member of self) - Population() { this->id = Population::id_g++; } + Population() { this->id = Population::id_g++; } /** * @brief Initialize values. Called once at the start of model run. @@ -692,6 +694,6 @@ struct Population : public fims_model_object::FIMSObject { template uint32_t Population::id_g = 0; -} // namespace fims +} // namespace fims_popdy #endif /* FIMS_POPULATION_DYNAMICS_POPULATION_HPP */ diff --git a/inst/include/population_dynamics/population/subpopulation.hpp b/inst/include/population_dynamics/population/subpopulation.hpp index 4f4663d8b..9ccc7e6bb 100644 --- a/inst/include/population_dynamics/population/subpopulation.hpp +++ b/inst/include/population_dynamics/population/subpopulation.hpp @@ -40,6 +40,6 @@ namespace fims_popdy { template class Subpopulation {}; -} // namespace fims +} // namespace fims_popdy #endif /* FIMS_POPULATION_DYNAMICS_POPULATION_SUBPOPULATION_HPP */ diff --git a/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp b/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp index 85340038a..8818f656c 100644 --- a/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp +++ b/inst/include/population_dynamics/recruitment/functors/recruitment_base.hpp @@ -115,6 +115,6 @@ struct RecruitmentBase : public fims_model_object::FIMSObject { template uint32_t RecruitmentBase::id_g = 0; -} // namespace fims +} // namespace fims_popdy #endif /* FIMS_POPULATION_DYNAMICS_RECRUITMENT_BASE_HPP */ diff --git a/inst/include/population_dynamics/recruitment/functors/sr_beverton_holt.hpp b/inst/include/population_dynamics/recruitment/functors/sr_beverton_holt.hpp index f6bd5f822..781eaa20f 100644 --- a/inst/include/population_dynamics/recruitment/functors/sr_beverton_holt.hpp +++ b/inst/include/population_dynamics/recruitment/functors/sr_beverton_holt.hpp @@ -62,6 +62,6 @@ struct SRBevertonHolt : public RecruitmentBase { } }; -} // namespace fims +} // namespace fims_popdy #endif /* FIMS_POPULATION_DYNAMICS_RECRUITMENT_SR_BEVERTON_HOLT_HPP */ diff --git a/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp b/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp index 2c572cc77..506b2ddc2 100644 --- a/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp +++ b/inst/include/population_dynamics/selectivity/functors/double_logistic.hpp @@ -48,10 +48,10 @@ struct DoubleLogisticSelectivity : public SelectivityBase { */ virtual const Type evaluate(const Type &x) { return fims_math::double_logistic(median_asc, slope_asc, median_desc, - slope_desc, x); + slope_desc, x); } }; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_SELECTIVITY_DOUBLE_LOGISTIC_HPP */ diff --git a/inst/include/population_dynamics/selectivity/functors/logistic.hpp b/inst/include/population_dynamics/selectivity/functors/logistic.hpp index fc5f6e8a6..fa5dc36c4 100644 --- a/inst/include/population_dynamics/selectivity/functors/logistic.hpp +++ b/inst/include/population_dynamics/selectivity/functors/logistic.hpp @@ -45,6 +45,6 @@ struct LogisticSelectivity : public SelectivityBase { } }; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_SELECTIVITY_LOGISTIC_HPP */ diff --git a/inst/include/population_dynamics/selectivity/functors/selectivity_base.hpp b/inst/include/population_dynamics/selectivity/functors/selectivity_base.hpp index 49659b803..a67b9bd8d 100644 --- a/inst/include/population_dynamics/selectivity/functors/selectivity_base.hpp +++ b/inst/include/population_dynamics/selectivity/functors/selectivity_base.hpp @@ -53,6 +53,6 @@ struct SelectivityBase : public fims_model_object::FIMSObject { template uint32_t SelectivityBase::id_g = 0; -} // namespace fims +} // namespace fims_popdy #endif /* POPULATION_DYNAMICS_SELECTIVITY_BASE_HPP */ diff --git a/tests/gtest/test_population_test_fixture.hpp b/tests/gtest/test_population_test_fixture.hpp index f3b27c9cb..67c6f8b38 100644 --- a/tests/gtest/test_population_test_fixture.hpp +++ b/tests/gtest/test_population_test_fixture.hpp @@ -77,7 +77,8 @@ class PopulationPrepareTestFixture : public testing::Test { // Does Fmort need to be in side of the year loop like log_q? for (int i = 0; i < nfleets; i++) { auto fleet = std::make_shared>(); - auto selectivity = std::make_shared>(); + auto selectivity = + std::make_shared>(); selectivity->median = 7; selectivity->slope = 0.5;