Skip to content

Commit

Permalink
Merge pull request #36 from rsetienne/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rsetienne authored Apr 26, 2024
2 parents fa2d5e9 + d403e1e commit 615cf7e
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v2
- run: pip install cpplint
- run: cpplint --quiet --exclude="src/RcppExports.cpp" src/*.cpp src/*.h
- run: cpplint --quiet src/secsse_sim2.h src/secsse_sim.cpp

cppcheck:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Type: Package
Title: Several Examined and Concealed States-Dependent Speciation and
Extinction
Version: 3.1.0
Date: 2024-03-18
Date: 2024-04-26
License: GPL (>= 3) | file LICENSE
Authors@R: c(
person(given = "Leonel",
Expand Down
43 changes: 20 additions & 23 deletions src/secsse_sim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ num_mat_mat list_to_nummatmat(const Rcpp::List& lambdas_R) {

} // namespace util

//'

// [[Rcpp::export]]
Rcpp::List secsse_sim_cpp(const std::vector<double>& m_R,
const Rcpp::List& lambdas_R,
Expand All @@ -82,14 +80,12 @@ Rcpp::List secsse_sim_cpp(const std::vector<double>& m_R,
const std::vector<double>& conditioning_vec,
bool return_tree_size_hist,
bool start_at_crown) {

try {

num_mat q;
util::numericmatrix_to_vector(q_R, &q);

num_mat_mat lambdas = util::list_to_nummatmat(lambdas_R);

secsse_sim sim(m_R,
lambdas,
q,
Expand All @@ -108,25 +104,26 @@ Rcpp::List secsse_sim_cpp(const std::vector<double>& m_R,
sim.run();
cnt++;
if (return_tree_size_hist) sim.update_tree_size_hist(&tree_size_hist[cnt]);

if (sim.num_species() >= min_species) {
sim.check_conditioning(condition,
num_concealed_states,
m_R.size(),
conditioning_vec);

if (sim.run_info == done) {
break;
} else {
tracker[ sim.run_info ]++;
}
} else { // if not reached minimum size
if (sim.run_info == extinct) tracker[extinct]++;
else {
} else { // if not reached minimum size
if (sim.run_info == extinct) {
tracker[extinct]++;
} else {
tracker[ 5 ]++;
}
}

if (verbose) {
if (cnt % 1000 == 0) {
Rcpp::Rcout << "extinct: " << tracker[extinct] << " "
Expand All @@ -141,20 +138,20 @@ Rcpp::List secsse_sim_cpp(const std::vector<double>& m_R,
Rcpp::checkUserInterrupt();
if (!non_extinction && sim.run_info == extinct) break;
}
// extract and return
Rcpp::NumericMatrix ltable_for_r;

Rcpp::NumericMatrix ltable_for_r; // extract and return
util::vector_to_numericmatrix(sim.extract_ltable(), &ltable_for_r);

auto traits = sim.get_traits();
auto init = sim.get_initial_state();
Rcpp::List output = Rcpp::List::create(Rcpp::Named("ltable") = ltable_for_r,
Rcpp::Named("traits") = traits,
Rcpp::Named("initial_state") = init,
Rcpp::Named("tracker") = tracker,
Rcpp::Named("hist_tree_size") = tree_size_hist);
return output;


Rcpp::List output =
Rcpp::List::create(Rcpp::Named("ltable") = ltable_for_r,
Rcpp::Named("traits") = traits,
Rcpp::Named("initial_state") = init,
Rcpp::Named("tracker") = tracker,
Rcpp::Named("hist_tree_size") = tree_size_hist);
return output;
} catch(std::exception &ex) {
forward_exception_to_r(ex);
} catch (const char* msg) {
Expand Down
Loading

0 comments on commit 615cf7e

Please sign in to comment.