Skip to content

Commit

Permalink
Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
aornugent committed Apr 26, 2021
1 parent 454b13a commit 5d5d507
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Expand Up @@ -63,8 +63,8 @@ export(check_inviable)
export(check_point)
export(clamp_domain)
export(cohort_schedule_times_default)
export(equilibrium_offspring_arriving)
export(equilibrium_quiet)
export(equilibrium_seed_rain)
export(equilibrium_verbose)
export(expand_parameters)
export(fast_control)
Expand Down
2 changes: 1 addition & 1 deletion R/fitness.R
@@ -1,4 +1,4 @@
offspring arrival##' Construct a fitness landscape.
##' Construct a fitness landscape.
##'
##' @title Fitness Landscape
##' @param trait_matrix A matrix of traits corresponding to mutants to
Expand Down
2 changes: 1 addition & 1 deletion R/stochastic.R
@@ -1,4 +1,4 @@
offspring arrival## This might yet move into the compiled code if we need it there.
## This might yet move into the compiled code if we need it there.
##
## Generate a vector of arrival times.
##
Expand Down
42 changes: 21 additions & 21 deletions inst/include/plant/RcppR6_post.hpp
Expand Up @@ -280,8 +280,8 @@ template <> inline SEXP wrap(const plant::Control& x) {
ret["plant_assimilation_tol"] = Rcpp::wrap(x.plant_assimilation_tol);
ret["plant_assimilation_iterations"] = Rcpp::wrap(x.plant_assimilation_iterations);
ret["plant_assimilation_rule"] = Rcpp::wrap(x.plant_assimilation_rule);
ret["plant_seed_tol"] = Rcpp::wrap(x.plant_seed_tol);
ret["plant_seed_iterations"] = Rcpp::wrap(x.plant_seed_iterations);
ret["plant_offspring_tol"] = Rcpp::wrap(x.plant_offspring_tol);
ret["plant_offspring_iterations"] = Rcpp::wrap(x.plant_offspring_iterations);
ret["cohort_gradient_eps"] = Rcpp::wrap(x.cohort_gradient_eps);
ret["cohort_gradient_direction"] = Rcpp::wrap(x.cohort_gradient_direction);
ret["cohort_gradient_richardson"] = Rcpp::wrap(x.cohort_gradient_richardson);
Expand All @@ -303,10 +303,10 @@ template <> inline SEXP wrap(const plant::Control& x) {
ret["schedule_patch_survival"] = Rcpp::wrap(x.schedule_patch_survival);
ret["equilibrium_nsteps"] = Rcpp::wrap(x.equilibrium_nsteps);
ret["equilibrium_eps"] = Rcpp::wrap(x.equilibrium_eps);
ret["equilibrium_large_seed_rain_change"] = Rcpp::wrap(x.equilibrium_large_seed_rain_change);
ret["equilibrium_large_offspring_arriving_change"] = Rcpp::wrap(x.equilibrium_large_offspring_arriving_change);
ret["equilibrium_verbose"] = Rcpp::wrap(x.equilibrium_verbose);
ret["equilibrium_solver_name"] = Rcpp::wrap(x.equilibrium_solver_name);
ret["equilibrium_extinct_seed_rain"] = Rcpp::wrap(x.equilibrium_extinct_seed_rain);
ret["equilibrium_extinct_offspring_arriving"] = Rcpp::wrap(x.equilibrium_extinct_offspring_arriving);
ret["equilibrium_nattempts"] = Rcpp::wrap(x.equilibrium_nattempts);
ret["equilibrium_solver_logN"] = Rcpp::wrap(x.equilibrium_solver_logN);
ret["equilibrium_solver_try_keep"] = Rcpp::wrap(x.equilibrium_solver_try_keep);
Expand All @@ -332,10 +332,10 @@ template <> inline plant::Control as(SEXP x) {
ret.plant_assimilation_iterations = Rcpp::as<size_t >(xl["plant_assimilation_iterations"]);
// ret.plant_assimilation_rule = Rcpp::as<decltype(retplant_assimilation_rule) >(xl["plant_assimilation_rule"]);
ret.plant_assimilation_rule = Rcpp::as<size_t >(xl["plant_assimilation_rule"]);
// ret.plant_seed_tol = Rcpp::as<decltype(retplant_seed_tol) >(xl["plant_seed_tol"]);
ret.plant_seed_tol = Rcpp::as<double >(xl["plant_seed_tol"]);
// ret.plant_seed_iterations = Rcpp::as<decltype(retplant_seed_iterations) >(xl["plant_seed_iterations"]);
ret.plant_seed_iterations = Rcpp::as<int >(xl["plant_seed_iterations"]);
// ret.plant_offspring_tol = Rcpp::as<decltype(retplant_offspring_tol) >(xl["plant_offspring_tol"]);
ret.plant_offspring_tol = Rcpp::as<double >(xl["plant_offspring_tol"]);
// ret.plant_offspring_iterations = Rcpp::as<decltype(retplant_offspring_iterations) >(xl["plant_offspring_iterations"]);
ret.plant_offspring_iterations = Rcpp::as<int >(xl["plant_offspring_iterations"]);
// ret.cohort_gradient_eps = Rcpp::as<decltype(retcohort_gradient_eps) >(xl["cohort_gradient_eps"]);
ret.cohort_gradient_eps = Rcpp::as<double >(xl["cohort_gradient_eps"]);
// ret.cohort_gradient_direction = Rcpp::as<decltype(retcohort_gradient_direction) >(xl["cohort_gradient_direction"]);
Expand Down Expand Up @@ -378,14 +378,14 @@ template <> inline plant::Control as(SEXP x) {
ret.equilibrium_nsteps = Rcpp::as<size_t >(xl["equilibrium_nsteps"]);
// ret.equilibrium_eps = Rcpp::as<decltype(retequilibrium_eps) >(xl["equilibrium_eps"]);
ret.equilibrium_eps = Rcpp::as<double >(xl["equilibrium_eps"]);
// ret.equilibrium_large_seed_rain_change = Rcpp::as<decltype(retequilibrium_large_seed_rain_change) >(xl["equilibrium_large_seed_rain_change"]);
ret.equilibrium_large_seed_rain_change = Rcpp::as<double >(xl["equilibrium_large_seed_rain_change"]);
// ret.equilibrium_large_offspring_arriving_change = Rcpp::as<decltype(retequilibrium_large_offspring_arriving_change) >(xl["equilibrium_large_offspring_arriving_change"]);
ret.equilibrium_large_offspring_arriving_change = Rcpp::as<double >(xl["equilibrium_large_offspring_arriving_change"]);
// ret.equilibrium_verbose = Rcpp::as<decltype(retequilibrium_verbose) >(xl["equilibrium_verbose"]);
ret.equilibrium_verbose = Rcpp::as<bool >(xl["equilibrium_verbose"]);
// ret.equilibrium_solver_name = Rcpp::as<decltype(retequilibrium_solver_name) >(xl["equilibrium_solver_name"]);
ret.equilibrium_solver_name = Rcpp::as<std::string >(xl["equilibrium_solver_name"]);
// ret.equilibrium_extinct_seed_rain = Rcpp::as<decltype(retequilibrium_extinct_seed_rain) >(xl["equilibrium_extinct_seed_rain"]);
ret.equilibrium_extinct_seed_rain = Rcpp::as<double >(xl["equilibrium_extinct_seed_rain"]);
// ret.equilibrium_extinct_offspring_arriving = Rcpp::as<decltype(retequilibrium_extinct_offspring_arriving) >(xl["equilibrium_extinct_offspring_arriving"]);
ret.equilibrium_extinct_offspring_arriving = Rcpp::as<double >(xl["equilibrium_extinct_offspring_arriving"]);
// ret.equilibrium_nattempts = Rcpp::as<decltype(retequilibrium_nattempts) >(xl["equilibrium_nattempts"]);
ret.equilibrium_nattempts = Rcpp::as<int >(xl["equilibrium_nattempts"]);
// ret.equilibrium_solver_logN = Rcpp::as<decltype(retequilibrium_solver_logN) >(xl["equilibrium_solver_logN"]);
Expand Down Expand Up @@ -502,7 +502,7 @@ template <> inline SEXP wrap(const plant::Parameters<plant::FF16_Strategy,plant:
ret["n_patches"] = Rcpp::wrap(x.n_patches);
ret["disturbance_mean_interval"] = Rcpp::wrap(x.disturbance_mean_interval);
ret["strategies"] = Rcpp::wrap(x.strategies);
ret["seed_rain"] = Rcpp::wrap(x.seed_rain);
ret["offspring_arriving"] = Rcpp::wrap(x.offspring_arriving);
ret["is_resident"] = Rcpp::wrap(x.is_resident);
ret["control"] = Rcpp::wrap(x.control);
ret["strategy_default"] = Rcpp::wrap(x.strategy_default);
Expand Down Expand Up @@ -532,8 +532,8 @@ template <> inline plant::Parameters<plant::FF16_Strategy,plant::FF16_Environmen
ret.disturbance_mean_interval = Rcpp::as<double >(xl["disturbance_mean_interval"]);
// ret.strategies = Rcpp::as<decltype(retstrategies) >(xl["strategies"]);
ret.strategies = Rcpp::as<std::vector<plant::FF16_Strategy> >(xl["strategies"]);
// ret.seed_rain = Rcpp::as<decltype(retseed_rain) >(xl["seed_rain"]);
ret.seed_rain = Rcpp::as<std::vector<double> >(xl["seed_rain"]);
// ret.offspring_arriving = Rcpp::as<decltype(retoffspring_arriving) >(xl["offspring_arriving"]);
ret.offspring_arriving = Rcpp::as<std::vector<double> >(xl["offspring_arriving"]);
// ret.is_resident = Rcpp::as<decltype(retis_resident) >(xl["is_resident"]);
ret.is_resident = Rcpp::as<std::vector<bool> >(xl["is_resident"]);
// ret.control = Rcpp::as<decltype(retcontrol) >(xl["control"]);
Expand All @@ -559,7 +559,7 @@ template <> inline SEXP wrap(const plant::Parameters<plant::FF16r_Strategy,plant
ret["n_patches"] = Rcpp::wrap(x.n_patches);
ret["disturbance_mean_interval"] = Rcpp::wrap(x.disturbance_mean_interval);
ret["strategies"] = Rcpp::wrap(x.strategies);
ret["seed_rain"] = Rcpp::wrap(x.seed_rain);
ret["offspring_arriving"] = Rcpp::wrap(x.offspring_arriving);
ret["is_resident"] = Rcpp::wrap(x.is_resident);
ret["control"] = Rcpp::wrap(x.control);
ret["strategy_default"] = Rcpp::wrap(x.strategy_default);
Expand Down Expand Up @@ -589,8 +589,8 @@ template <> inline plant::Parameters<plant::FF16r_Strategy,plant::FF16_Environme
ret.disturbance_mean_interval = Rcpp::as<double >(xl["disturbance_mean_interval"]);
// ret.strategies = Rcpp::as<decltype(retstrategies) >(xl["strategies"]);
ret.strategies = Rcpp::as<std::vector<plant::FF16r_Strategy> >(xl["strategies"]);
// ret.seed_rain = Rcpp::as<decltype(retseed_rain) >(xl["seed_rain"]);
ret.seed_rain = Rcpp::as<std::vector<double> >(xl["seed_rain"]);
// ret.offspring_arriving = Rcpp::as<decltype(retoffspring_arriving) >(xl["offspring_arriving"]);
ret.offspring_arriving = Rcpp::as<std::vector<double> >(xl["offspring_arriving"]);
// ret.is_resident = Rcpp::as<decltype(retis_resident) >(xl["is_resident"]);
ret.is_resident = Rcpp::as<std::vector<bool> >(xl["is_resident"]);
// ret.control = Rcpp::as<decltype(retcontrol) >(xl["control"]);
Expand All @@ -616,7 +616,7 @@ template <> inline SEXP wrap(const plant::Parameters<plant::K93_Strategy,plant::
ret["n_patches"] = Rcpp::wrap(x.n_patches);
ret["disturbance_mean_interval"] = Rcpp::wrap(x.disturbance_mean_interval);
ret["strategies"] = Rcpp::wrap(x.strategies);
ret["seed_rain"] = Rcpp::wrap(x.seed_rain);
ret["offspring_arriving"] = Rcpp::wrap(x.offspring_arriving);
ret["is_resident"] = Rcpp::wrap(x.is_resident);
ret["control"] = Rcpp::wrap(x.control);
ret["strategy_default"] = Rcpp::wrap(x.strategy_default);
Expand Down Expand Up @@ -646,8 +646,8 @@ template <> inline plant::Parameters<plant::K93_Strategy,plant::K93_Environment>
ret.disturbance_mean_interval = Rcpp::as<double >(xl["disturbance_mean_interval"]);
// ret.strategies = Rcpp::as<decltype(retstrategies) >(xl["strategies"]);
ret.strategies = Rcpp::as<std::vector<plant::K93_Strategy> >(xl["strategies"]);
// ret.seed_rain = Rcpp::as<decltype(retseed_rain) >(xl["seed_rain"]);
ret.seed_rain = Rcpp::as<std::vector<double> >(xl["seed_rain"]);
// ret.offspring_arriving = Rcpp::as<decltype(retoffspring_arriving) >(xl["offspring_arriving"]);
ret.offspring_arriving = Rcpp::as<std::vector<double> >(xl["offspring_arriving"]);
// ret.is_resident = Rcpp::as<decltype(retis_resident) >(xl["is_resident"]);
ret.is_resident = Rcpp::as<std::vector<bool> >(xl["is_resident"]);
// ret.control = Rcpp::as<decltype(retcontrol) >(xl["control"]);
Expand Down
2 changes: 1 addition & 1 deletion inst/include/plant/cohort.h
Expand Up @@ -62,7 +62,7 @@ class Cohort {
double log_density_dt;
double density; // hmm...
double offspring_produced_survival_weighted;
double soffspring_produced_survival_weighted_dt;
double offspring_produced_survival_weighted_dt;
double pr_patch_survival_at_birth;
};

Expand Down
18 changes: 9 additions & 9 deletions inst/include/plant/scm.h
Expand Up @@ -32,9 +32,9 @@ class SCM {
void reset();
bool complete() const;

// * Output total offsrping calculation (not per capita)
// * Output total offspring calculation (not per capita)
double offspring_produced(size_t species_index) const;
std::vector<double> offspring_produced() const;
std::vector<double> all_offspring_produced() const;

// * R interface
std::vector<util::index> r_run_next();
Expand Down Expand Up @@ -105,7 +105,7 @@ std::vector<size_t> SCM<T,E>::run_next() {
e = cohort_schedule.next_event();
}
}
patch.add_offpring_entering(ret);
patch.add_all_offspring(ret);

const bool use_ode_times = cohort_schedule.using_ode_times();
solver.set_state_from_system(patch);
Expand Down Expand Up @@ -244,22 +244,22 @@ template <typename T, typename E>
double SCM<T,E>::offspring_produced_total() const {
double tot = 0.0;
for (size_t i = 0; i < patch.size(); ++i) {
tot += offspring_produced_total(i);
tot += offspring_produced(i);
}
return tot;
}

template <typename T, typename E>
std::vector<double> SCM<T,E>::offspring_produced_cohort(size_t species_index) const {
const std::vector<double> times = cohort_schedule.times(species_index);
const Disturbance& disturbance_regime = patch.disturbance_regime;
const Disturbance& disturbance_regime = patch.disturbance_regime();
const double S_D = parameters.strategies[species_index].S_D;
const double scal = S_D * parameters.offspring_arriving[species_index];
std::vector<double> offspring = patch.at(species_index).offspring();
for (size_t i = 0; i < offspring.size(); ++i) {
offspring[i] *= disturbance_regime.density(times[i]) * scal;
std::vector<double> offspring_produced = patch.at(species_index).all_offspring();
for (size_t i = 0; i < offspring_produced.size(); ++i) {
offspring_produced[i] *= disturbance_regime.density(times[i]) * scal;
}
return offspring;
return offspring_produced;
}

}
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-cohort.R
Expand Up @@ -130,7 +130,7 @@ for (x in names(strategy_types)) {
## Ode *values*:
cmp <- c(plant$internals$states,
0, # offspring_produced_survival_weighted
log(pr_estab * env$offspring_produced_dt / g) # log density
log(pr_estab * env$offspring_arriving_dt / g) # log density
)
cmp[which(plant$ode_names == 'mortality')] <- -log(pr_estab)
expect_equal(cohort$ode_state, cmp)
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test-environment.R
Expand Up @@ -56,16 +56,16 @@ for (x in names(strategy_types)) {

test_that("Seed rain related parameters", {
env <- make_environment(x, Parameters(x, e)())
expect_error(env$offspring_produced_dt, "Cannot get offspring arrival for empty environment")
expect_error(env$offspring_arriving_dt, "Cannot get offspring arrivals for empty environment")

z <- c(.1, .2)
env <- test_environment(x, 10, n_strategies=2, offspring_arriving=z)

expect_identical(env$offspring_produced_dt, z[[1]])
expect_identical(env$offspring_arriving_dt, z[[1]])
env$set_offspring_arriving_index(1)
expect_identical(env$offspring_produced_dt, z[[1]])
expect_identical(env$offspring_arriving_dt, z[[1]])
env$set_offspring_arriving_index(2)
expect_identical(env$offspring_produced_dt, z[[2]])
expect_identical(env$offspring_arriving_dt, z[[2]])
expect_error(env$set_offspring_arriving_index(0), "Invalid value for index")
expect_error(env$set_offspring_arriving_index(3), "Index 3 out of bounds")
})
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-scm.R
Expand Up @@ -256,9 +256,9 @@ test_that("Seed rain & error calculations correct", {
pa <- d$density(a)
p <- scm$parameters
scale <- scm$parameters$strategies[[1]]$S_D * p$offspring_arriving
offspring <- pa * scm$patch$species[[1]]$offspring * scale
total <- trapezium(a, offspring)
if (error) local_error_integration(a, offspring, total) else total
all_offspring <- pa * scm$patch$species[[1]]$all_offspring * scale
total <- trapezium(a, all_offspring)
if (error) local_error_integration(a, all_offspring, total) else total
}

expect_equal(scm$offspring_produced(1), offspring_produced_R(scm))
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-strategy-k93.R
@@ -1,4 +1,4 @@
offspring arrival# Built from tests/testthat/test-strategy-ff16r.R on Wed Aug 12 15:33:08 2020 using the scaffolder, from the strategy: FF16r
# Built from tests/testthat/test-strategy-ff16r.R on Wed Aug 12 15:33:08 2020 using the scaffolder, from the strategy: FF16r
# Built from tests/testthat/test-strategy-ff16.R on Fri Jul 3 08:14:35 2020 using the scaffolder, from the strategy: FF16
context("Strategy-K93")

Expand Down

0 comments on commit 5d5d507

Please sign in to comment.