Skip to content

Commit

Permalink
poped plot fix and add special ini to timeIndexer
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Sep 22, 2024
1 parent 6561b24 commit 7eebd5c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
6 changes: 5 additions & 1 deletion R/poped.R
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,11 @@ attr(rxUiGet.popedFfFun, "desc") <- "PopED parameter model (ff_fun)"
.d[[.wtime]] <- t
.d
}))
rbind(.data, .data3)[, -.wdvid]
if (length(.wdvid) == 1L) {
rbind(.data, .data3)[, -.wdvid]
} else {
rbind(.data, .data3)
}
})))
.et <- rxode2::etTrans(.dat, .e$modelF)
.e$dataF <- .et
Expand Down
21 changes: 17 additions & 4 deletions src/timeIndexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ class timeIndexer {
sorted = false;
}

void initialize(const std::vector<int>& ids, const std::vector<double>& times) {
std::unordered_map<int, std::vector<double>> idToTimesMap;
void initialize(const std::vector<int>& ids, const std::vector<double>& times,
const bool optTime) {
if (optTime && initialized) {
return;
}
if (isSame(ids, times)) {
return;
}
std::unordered_map<int, std::vector<double>> idToTimesMap;
reset();

this->times = times;
Expand All @@ -84,10 +88,19 @@ class timeIndexer {
initialize(outIds, outTimes);
}

void initialize(Rcpp::IntegerVector& ids, Rcpp::NumericVector& time) {
void initialize(const std::vector<int>& ids, const std::vector<double>& times) {
initialize(ids, times, false);
}

void initialize(Rcpp::IntegerVector& ids, Rcpp::NumericVector& time,
const bool optTime) {
std::vector<int> idsVec = Rcpp::as<std::vector<int>>(ids);
std::vector<double> timeVec = Rcpp::as<std::vector<double>>(time);
initialize(idsVec, timeVec);
initialize(idsVec, timeVec, optTime);
}

void initialize(Rcpp::IntegerVector& ids, Rcpp::NumericVector& time) {
initialize(ids, time, false);
}

bool isSame(const std::vector<int>& ids, const std::vector<double>& times) {
Expand Down

0 comments on commit 7eebd5c

Please sign in to comment.