Skip to content

Commit

Permalink
Merge pull request #644 from nlmixr2/m1mac
Browse files Browse the repository at this point in the history
Add forder and rxInv string fixes as requested by CRAN
  • Loading branch information
mattfidler authored Jan 14, 2024
2 parents b385d12 + 96ffbb2 commit 37da029
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Other changes

- `rxUi` compression now defaults to fast compression
- Fixes String literal formatting issues as identified by CRAN (#643)

# rxode2 2.1.0

Expand Down
10 changes: 5 additions & 5 deletions src/forder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ extern "C" int getRxThreads(const int64_t n, const bool throttle) {

extern "C" SEXP getRxThreads_R(SEXP verbose) {
if (!isLogical(verbose) || LENGTH(verbose)!=1 || INTEGER(verbose)[0]==NA_LOGICAL)
Rf_errorcall(R_NilValue, _("'verbose' must be TRUE or FALSE"));
Rf_errorcall(R_NilValue, "%s", _("'verbose' must be TRUE or FALSE"));
if (LOGICAL(verbose)[0]) {
#ifndef _OPENMP
Rprintf(_("This installation of data.table has not been compiled with OpenMP support.\n"));
Rprintf("%s", _("This installation of data.table has not been compiled with OpenMP support.\n"));
#endif
// this output is captured, paste0(collapse="; ")'d, and placed at the end of test.data.table() for display in the last 13 lines of CRAN check logs
// it is also printed at the start of test.data.table() so that we can trace any Killed events on CRAN before the end is reached
Expand All @@ -125,7 +125,7 @@ extern "C" SEXP getRxThreads_R(SEXP verbose) {
extern "C" SEXP setRxthreads(SEXP threads, SEXP percent, SEXP throttle) {
if (length(throttle)) {
if (!isInteger(throttle) || LENGTH(throttle)!=1 || INTEGER(throttle)[0]<1)
error(_("'throttle' must be a single number, non-NA, and >=1"));
error("%s", _("'throttle' must be a single number, non-NA, and >=1"));
rxThrottle = INTEGER(throttle)[0];
}
int old = rxThreads;
Expand All @@ -139,11 +139,11 @@ extern "C" SEXP setRxthreads(SEXP threads, SEXP percent, SEXP throttle) {
} else if (length(threads)) {
int n=0;
if (length(threads)!=1 || !isInteger(threads) || (n=INTEGER(threads)[0]) < 0) { // <0 catches NA too since NA is negative (INT_MIN)
Rf_errorcall(R_NilValue, _("threads= must be either NULL or a single number >= 0 See ?setRxthreads"));
Rf_errorcall(R_NilValue, "%s", _("threads= must be either NULL or a single number >= 0 See ?setRxthreads"));
}
int num_procs = imax(omp_get_num_procs(), 1); // max just in case omp_get_num_procs() returns <= 0 (perhaps error, or unsupported)
if (!isLogical(percent) || length(percent)!=1 || LOGICAL(percent)[0]==NA_LOGICAL) {
Rf_errorcall(R_NilValue, _("internal error: percent= must be TRUE or FALSE at C level")); // # nocov
Rf_errorcall(R_NilValue, "%s", _("internal error: percent= must be TRUE or FALSE at C level")); // # nocov
}
if (LOGICAL(percent)[0]) {
if (n<2 || n>100) error(_("internal error: threads==%d should be between 2 and 100 (percent=TRUE at C level)"), n); // # nocov
Expand Down
24 changes: 12 additions & 12 deletions src/rxInv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ using namespace R;
using namespace arma;
extern "C" SEXP _rxCholInv(SEXP dms, SEXP theta, SEXP tn);

//' Invert matrix using RcppArmadillo.
//' Invert matrix using RcppArmadillo.
//'
//' @param matrix matrix to be inverted.
//'
//'
//' @return inverse or pseudo inverse of matrix.
//'
//'
//' @export
// [[Rcpp::export]]
NumericVector rxInv(SEXP matrix){
Expand All @@ -33,7 +33,7 @@ NumericVector rxInv(SEXP matrix){
success = inv(imat, smatrix);
if (!success){
imat = pinv(smatrix);
Rprintf(_("matrix seems singular; Using pseudo-inverse\n"));
Rprintf("%s", _("matrix seems singular; Using pseudo-inverse\n"));
}
NumericVector ret;
ret = wrap(imat);
Expand Down Expand Up @@ -71,15 +71,15 @@ arma::mat rxToCholOmega(arma::mat cholMat){
//' [rxSymInvCholCreate()] with the default arguments and return a
//' reactive s3 object. Otherwise, use the inversion object to
//' calculate the requested derivative/inverse.
//'
//'
//' @param theta Thetas to be used for calculation. If missing (`NULL`), a
//' special s3 class is created and returned to access `Omega^1`
//' objects as needed and cache them based on the theta that is
//' used.
//'
//'
//' @param type The type of object. Currently the following types are
//' supported:
//'
//'
//' * `cholOmegaInv` gives the
//' Cholesky decomposition of the Omega Inverse matrix.
//' * `omegaInv` gives the Omega Inverse matrix.
Expand All @@ -88,18 +88,18 @@ arma::mat rxToCholOmega(arma::mat cholMat){
//' * `d(D)` gives the `d(diagonal(Omega^-1))` with respect to
//' the theta parameter specified in the `thetaNumber`
//' parameter
//'
//'
//' @param thetaNumber For types `d(omegaInv)` and `d(D)`,
//' the theta number that the derivative is taken against. This
//' must be positive from 1 to the number of thetas defining the
//' Omega matrix.
//'
//'
//' @return Matrix based on parameters or environment with all the
//' matrixes calculated in variables `omega`, `omegaInv`, `dOmega`,
//' `dOmegaInv`.
//'
//'
//' @author Matthew L. Fidler
//'
//'
//' @export
// [[Rcpp::export]]
RObject rxSymInvChol(RObject invObjOrMatrix, Nullable<NumericVector> theta = R_NilValue, std::string type = "cholOmegaInv", int thetaNumber = 0){
Expand Down Expand Up @@ -200,7 +200,7 @@ RObject rxSymInvCholEnvCalculate(List obj, std::string what, Nullable<NumericVec
} else if (what == "chol.omega1"){
rxSymInvCholEnvCalculate(obj, "chol.omegaInv", R_NilValue);
arma::mat ret = rxToCholOmega(as<arma::mat>(e["chol.omegaInv"]));
e["chol.omega1"] = ret;
e["chol.omega1"] = ret;
} else if (what == "omega"){
rxSymInvCholEnvCalculate(obj, "chol.omega1", R_NilValue);
arma::mat U1 = as<mat>(e["chol.omega1"]);
Expand Down
4 changes: 2 additions & 2 deletions src/rxode2_df.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ extern "C" SEXP rxode2_df(int doDose0, int doTBS) {
if (op->badSolve){
if (op->naTime){
rxSolveFreeC();
Rf_errorcall(R_NilValue, _("'alag(.)'/'rate(.)'/'dur(.)' cannot depend on the state values"));
Rf_errorcall(R_NilValue, "%s", _("'alag(.)'/'rate(.)'/'dur(.)' cannot depend on the state values"));
}
if (nidCols == 0){
for (int solveid = 0; solveid < rx->nsub * rx->nsim; solveid++){
Expand All @@ -225,7 +225,7 @@ extern "C" SEXP rxode2_df(int doDose0, int doTBS) {
}
}
rxSolveFreeC();
Rf_errorcall(R_NilValue, _("could not solve the system"));
Rf_errorcall(R_NilValue, "%s", _("could not solve the system"));
} else {
warning(_("some ID(s) could not solve the ODEs correctly; These values are replaced with 'NA'"));
}
Expand Down

0 comments on commit 37da029

Please sign in to comment.