From 96ffbb275d6c1fe49f53fd8437efa00d75a0f191 Mon Sep 17 00:00:00 2001 From: "Matthew L. Fidler" Date: Sun, 14 Jan 2024 09:31:49 -0600 Subject: [PATCH] Add forder and rxInv string fixes as requested by CRAN --- NEWS.md | 1 + src/forder.cpp | 10 +++++----- src/rxInv.cpp | 24 ++++++++++++------------ src/rxode2_df.cpp | 4 ++-- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/NEWS.md b/NEWS.md index b5b8b4d43..f8e2eded9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/src/forder.cpp b/src/forder.cpp index 84fd72cb3..3d246a3de 100644 --- a/src/forder.cpp +++ b/src/forder.cpp @@ -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 @@ -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; @@ -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 diff --git a/src/rxInv.cpp b/src/rxInv.cpp index 3eaa9c6b7..b4ec482fd 100644 --- a/src/rxInv.cpp +++ b/src/rxInv.cpp @@ -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){ @@ -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); @@ -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. @@ -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 theta = R_NilValue, std::string type = "cholOmegaInv", int thetaNumber = 0){ @@ -200,7 +200,7 @@ RObject rxSymInvCholEnvCalculate(List obj, std::string what, Nullable(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(e["chol.omega1"]); diff --git a/src/rxode2_df.cpp b/src/rxode2_df.cpp index 4a1754c0a..7c5959a61 100644 --- a/src/rxode2_df.cpp +++ b/src/rxode2_df.cpp @@ -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++){ @@ -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'")); }