Skip to content

Commit

Permalink
Merge branch 'release/1.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Jan 7, 2025
2 parents 860b985 + 3f3e96a commit b0da6fc
Show file tree
Hide file tree
Showing 125 changed files with 11,494 additions and 11,000 deletions.
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## -------------------------------------------------------------------------
## Ensure that all text files have LF line endings.
##
## If an editor introduces CRLF line endings, git will automatically
## convert those to LF. The 'auto' tells git to decide which
## files are text files and which are not.
## -------------------------------------------------------------------------
* text=auto eol=lf
46 changes: 18 additions & 28 deletions .github/workflows/R-CMD-check-valgrind.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@ jobs:

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RSPM: https://packagemanager.rstudio.com/cran/__linux__/jammy/latest
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
## R CMD check
_R_CHECK_CRAN_INCOMING_: false
_R_CHECK_LENGTH_1_CONDITION_: true
_R_CHECK_LENGTH_1_LOGIC2_: true
_R_CHECK_MATRIX_DATA_: true
## Specific to package
_R_CHECK_USE_VALGRIND_: true
Expand All @@ -33,50 +30,43 @@ jobs:
- uses: r-lib/actions/setup-r@v2
with:
r-version: release
use-public-rspm: true

- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}

- name: Cache R packages
uses: actions/cache@v3
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
extra-packages: any::rcmdcheck
needs: check

- name: Install system dependencies
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
sudo -s eval "$sysreqs"
sudo apt-get install --yes valgrind
- name: Install dependencies
run: |
remotes::install_deps(dependencies = TRUE)
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
capabilities()
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
## Verify LANGUAGE settings by generating a translatable error
cat(sprintf("LANGUAGE=%s\n", sQuote(Sys.getenv("LANGUAGE"))))
cat(sprintf("locales: %s\n", sQuote(Sys.getlocale())))
tryCatch(log("a"), error = conditionMessage)
shell: Rscript {0}

- name: Check with valgrind
run: rcmdcheck::rcmdcheck(build_args = "--no-build-vignettes", args = c("--use-valgrind", "--no-codoc", "--no-examples", "--no-manual", "--ignore-vignettes"), error_on = "warning", check_dir = "check")
run: |
rcmdcheck::rcmdcheck(
build_args = "--no-build-vignettes",
args = c("--use-valgrind", "--no-codoc", "--no-examples",
"--no-manual", "--ignore-vignettes"),
error_on = "warning",
check_dir = "check"
)
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ runner.os }}-rrelease-results
path: check
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
on: [push]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
name: covr

timeout-minutes: 30

runs-on: ubuntu-latest

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2
- name: Assert CODECOV_TOKEN is set
run: |
if [[ -z "${{secrets.CODECOV_TOKEN}}" ]]; then
>&2 echo "::error::ERROR: 'secrets.CODECOV_TOKEN' not set"
exit 1
fi
- uses: r-lib/actions/setup-r@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: matrixStats
Version: 1.4.1
Version: 1.5.0
Depends:
R (>= 2.12.0)
R (>= 3.4.0)
Suggests:
utils,
base64enc,
Expand Down
37 changes: 32 additions & 5 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
# Version 1.5.0 [2025-01-07]

## Significant Changes

* Package now requires R (>= 3.4.0) [2017-04-21], because the next
release of R will have stricter C header requirements that are not
backward compatible with older versions of R.

## Deprecated and Defunct

* The hidden R options for deescalating the error for using `useNames
= NA` to a warning has been removed; `useNames = NA` is now always
an error.

* Calling `colRanks()` and `rowRanks()` without explicitly specifying
argument `ties.method` is deprecated since version 1.3.0
[2024-04-10]. If not explicitly specified, a deprecation warning is
now produced every 10:th call not specifying the `ties.method`
argument.

## Bug Fixes

* The error message of `colTabulates()` and `rowTabulates()`
asserting that double values are passed, reported on the class of
the input data, not the storage type.


# Version 1.4.1 [2024-09-06]

## Bug Fixes

* Fix a potential `runtime error: null pointer passed as argument 1,
which is declared to never be null` bug introduced in v1.4.0 that
was detected by the UndefinedBehaviorSanitizer (UBSan) running on CRAN.
* Fix a `runtime error: null pointer passed as argument 1, which is
declared to never be null` bug introduced in v1.4.0 that was
detected by the UndefinedBehaviorSanitizer (UBSan) running on CRAN.


# Version 1.4.0 [2024-09-03]
Expand All @@ -28,8 +55,8 @@
## Deprecated and Defunct

* Calling `colRanks()` and `rowRanks()` without explicitly specifying
argument `ties.method` is deprecated since version 1.3.0. If not
explicitly specified, a deprecation warning is now produced every
argument `ties.method` is deprecated since version 1.3.0 [2024-04-10].
If not explicitly specified, a deprecation warning is now produced every
25:th call not specifying the `ties.method` argument.


Expand Down
50 changes: 22 additions & 28 deletions R/000.DEPRECATION.R
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
isUseNamesNADefunct <- function() {
action <- getOption("matrixStats.useNames.NA", "defunct")
action <- match.arg(action, choices = c("deprecated", "defunct"))
(action == "defunct")
}

deprecatedUseNamesNA <- function() {
if (isUseNamesNADefunct()) {
.Defunct(msg = sprintf("[%s (>= 1.2.0)] useNames = NA is defunct. Instead, specify either useNames = TRUE or useNames = FALSE. See also ?matrixStats::matrixStats.options", .packageName), package = .packageName)
} else {
.Deprecated(msg = sprintf("[%s (>= 1.2.0)] useNames = NA is deprecated. Instead, specify either useNames = TRUE or useNames = FALSE. See also ?matrixStats::matrixStats.options", .packageName), package = .packageName)
}
}


defunctShouldBeMatrixOrDim <- function(x) {
x_class <- sQuote(class(x)[1])
x_name <- sQuote(as.character(substitute(x)))
Expand All @@ -31,16 +16,17 @@ defunctShouldBeMatrixOrVector <- function(x) {
.Defunct(msg = sprintf("[%s] Argument %s is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", .packageName, x_name, x_class, x_class)) #nolint
}

validateScalarCenter <- function(center, n, dimname) {
onScalar <- getOption("matrixStats.center.onScalar", "defunct")
if (identical(onScalar, "ignore")) return()

validateScalarCenter <- function(center, n, dimname) { onScalar <- getOption("matrixStats.center.onScalar", "defunct")
action <- switch(onScalar,
deprecated = .Deprecated,
defunct = .Defunct,
function(...) NULL
NULL
)

if (is.null(action)) {
stop(sprintf("R option 'matrixStats.center.onScalar' must not be \"%s\"; the only valid values are \"defunct\" and \"deprecated\"", onScalar))
}

msg <- sprintf("[%s (>= 0.58.0)] Argument '%s' should be of the same length as number of %s of '%s'. Use of a scalar value is %s: %s != %s (See also ?matrixStats::matrixStats.options)", .packageName, "center", dimname, "x", onScalar, length(center), n)
action(msg = msg, package = .packageName)
}
Expand Down Expand Up @@ -80,13 +66,16 @@ centerOnUse <- function(fcnname, calls = sys.calls(), msg = NULL) {
value <- getOption("matrixStats.center.onUse", "ignore")
if (identical(value, "ignore")) return()

value <- match.arg(value, c("deprecated", "defunct"))
action <- switch(value,
deprecated = .Deprecated,
defunct = .Defunct,
function(...) NULL
NULL
)

if (is.null(action)) {
stop(sprintf("R option 'matrixStats.center.onScalar' must not be \"%s\"; the only valid values are \"defunct\", \"deprecated\", and \"ignore\"", value))
}

if (is.null(msg)) {
msg <- sprintf("[%s] Argument '%s' of %s::%s() is %s: %s (See also ?matrixStats::matrixStats.options)",
.packageName, "center", .packageName, fcnname,
Expand All @@ -102,7 +91,7 @@ validateTiesMethodMissing <- local({
always <- structure(TRUE, when = "each time this function is called")

function() {
freq <- getOption("matrixStats.ties.method.freq", 25L)
freq <- getOption("matrixStats.ties.method.freq", 10L)

## Nothing to do?
if (is.null(freq)) return(FALSE)
Expand All @@ -128,18 +117,23 @@ validateTiesMethodMissing <- local({

tiesMethodMissing <- local({
function() {
action <- getOption("matrixStats.ties.method.missing", if (getRversion() >= "4.4.0") "deprecated" else "ignore")
if (action == "ignore") return()
value <- getOption("matrixStats.ties.method.missing", if (getRversion() >= "4.4.0") "deprecated" else "ignore")
if (value == "ignore") return()

## How often should we check?
if (!validateTiesMethodMissing()) return()

action <- switch(action,
action <- switch(value,
deprecated = .Deprecated,
defunct = .Defunct,
function(...) NULL
NULL
)
msg <- sprintf("[%s (>= 1.3.0)] Please explicitly specify argument 'ties.method' when calling colRanks() and rowRanks() of %s. This is because the current default ties.method=\"max\" will eventually be updated to ties.method=\"average\" in order to align with the default of base::rank(). See also ?matrixStats::matrixStats.options", .packageName, .packageName)

if (is.null(action)) {
stop(sprintf("R option 'matrixStats.ties.method.missing' must not be \"%s\"; the only valid values are \"defunct\", \"deprecated\", and \"ignore\"", value))
}

msg <- sprintf("[%s (>= 1.3.0)] Please explicitly specify argument 'ties.method' when calling colRanks() and rowRanks() of %s. This is because the current default ties.method=\"max\" will eventually be updated to ties.method=\"average\" in order to align with the default of base::rank(). If you are an end-user that cannot update the R code causing this, see ?matrixStats::matrixStats.options for how to temporarily disable this check", .packageName, .packageName)
action(msg = msg, package = .packageName)
}
})
25 changes: 6 additions & 19 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#' Action taken when argument \code{center} is a scalar.
#' If \code{"defunct"}, an error is thrown.
#' If \code{"deprecated"}, a warning is signaled.
#' If \code{"ignore"}, it's silently ignored.
#' (Default: \code{"deprecated"})}
#' }
#'
Expand Down Expand Up @@ -54,32 +53,22 @@
#' \describe{
#' \item{\option{matrixStats.ties.method.freq}:}{(numeric)
#' Controls how often the above validation is checked.
#' (Default: \code{25} - every 25:th call starting with the first)}
#' }
#'
#' \describe{
#' \item{\option{matrixStats.useNames.NA}:}{(string)
#' Action taken when argument \code{useNames} is set to \code{NA}.
#' If \code{"defunct"}, an error is thrown.
#' If \code{"deprecated"}, a warning is signaled.
#' (Default: \code{"defunct"})}
#' (Default: \code{10} - every 10:th call starting with the first)}
#' }
#'
#' @section Environment variables that set R options:
#' All of the above \R \option{matrixStats.*} options can be set by
#' corresponding environment variable \env{R_MATRIXSTATS_*}
#' \emph{when the \pkg{matrixStats} package is loaded}.
#' For example, if \code{R_MATRIXSTATS_USENAMES_NA=defunct}, then option
#' \option{matrixStats.useNames.NA} is set to \code{"defunct"} (string).
#' For example, if \code{R_MATRIXSTATS_TIES_METHOD_FREQ=10}, then option
#' \option{matrixStats.ties.method.freq} is set to \code{10} (integer).
#'
#' @examples
#' \dontrun{
#' options(matrixStats.useNames.NA = "defunct")
#' options(matrixStats.ties.method.freq = 10L)
#' }
#'
#' @aliases
#' matrixStats.useNames.NA
#' R_MATRIXSTATS_USENAMES_NA
#' matrixStats.vars.formula.freq
#' R_MATRIXSTATS_VARS_FORMULA_FREQ
#' matrixStats.vars.formula.onMistake
Expand Down Expand Up @@ -209,11 +198,9 @@ update_package_options <- function() {

update_package_option("matrixStats.vars.center.onUse", default = "ignore", choices = c("deprecated", "defunct", "ignore"))

update_package_option("matrixStats.center.onScalar", default = "defunct", choices = c("deprecated", "defunct", "ignore"))
update_package_option("matrixStats.center.onScalar", default = "defunct", choices = c("deprecated", "defunct"))

update_package_option("matrixStats.useNames.NA", default = "defunct", choices = c("deprecated", "defunct"))

update_package_option("matrixStats.ties.method.missing", default = if (getRversion() >= "4.4.0") "deprecated" else "ignore", choices = c("deprecated", "defunct", "ignore"))

update_package_option("matrixStats.ties.method.freq", mode = "numeric", default = "25")
update_package_option("matrixStats.ties.method.freq", mode = "numeric", default = "10")
}
Loading

0 comments on commit b0da6fc

Please sign in to comment.