Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r] Run styler::style_pkg() #3239

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 32 additions & 30 deletions apis/r/R/BlockwiseIter.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ BlockwiseReadIterBase <- R6::R6Class(
#' @template param-coords-iter
#' @template param-dots-ignored
#'
initialize = function(
sr,
array,
coords,
axis,
...,
reindex_disable_on_axis = NA
) {
initialize = function(sr,
array,
coords,
axis,
...,
reindex_disable_on_axis = NA) {
super$initialize(sr)
stopifnot(
"'array' must be a 'SOMASparseNDArray'" = inherits(array, "SOMASparseNDArray")
Expand Down Expand Up @@ -99,8 +97,10 @@ BlockwiseReadIterBase <- R6::R6Class(
#'
#' @return \code{TRUE} if read is complete, otherwise \code{FALSE}
#'
read_complete = function() !self$coords_axis$has_next() ||
is.null(private$soma_reader_pointer),
read_complete = function() {
!self$coords_axis$has_next() ||
is.null(private$soma_reader_pointer)
},
#' @description Read the next chunk of the iterated read. If read
#' is complete, throws an \code{iterationCompleteWarning} warning and
#' returns \code{NULL}
Expand All @@ -109,7 +109,7 @@ BlockwiseReadIterBase <- R6::R6Class(
#'
read_next = function() {
if (is.null(private$soma_reader_pointer)) {
return(NULL)
return(NULL)
}
if (self$read_complete()) {
return(private$.readComplete())
Expand Down Expand Up @@ -156,8 +156,10 @@ BlockwiseReadIterBase <- R6::R6Class(
#' @field reindexable Shorthand to see if this iterator is poised to be
#' re-indexed or not
#'
reindexable = function() length(self$axes_to_reindex) ||
!bit64::as.integer64(self$axis) %in% self$reindex_disable_on_axis
reindexable = function() {
length(self$axes_to_reindex) ||
!bit64::as.integer64(self$axis) %in% self$reindex_disable_on_axis
}
),
private = list(
.array = NULL,
Expand All @@ -168,10 +170,12 @@ BlockwiseReadIterBase <- R6::R6Class(
.reindexers = list(),
# @description Throw an error saying that re-indexed
# iterators are not concatenatable
.notConcatenatable = function() stop(errorCondition(
message = "Re-indexed blockwise iterators are not concatenatable",
class = "notConcatenatableError"
)),
.notConcatenatable = function() {
stop(errorCondition(
message = "Re-indexed blockwise iterators are not concatenatable",
class = "notConcatenatableError"
))
},
# @description Reset internal state of SOMA Reader while keeping array open
reset = function() {
if (is.null(private$soma_reader_pointer)) {
Expand All @@ -183,7 +187,7 @@ BlockwiseReadIterBase <- R6::R6Class(
# @description Re-index an Arrow table
reindex_arrow_table = function(tbl) {
stopifnot(
"'tbl' must be an Arrow table" = R6::is.R6(tbl) && inherits(tbl, 'Table')
"'tbl' must be an Arrow table" = R6::is.R6(tbl) && inherits(tbl, "Table")
)
dname <- self$array$dimnames()[self$axis + 1L]
if (!dname %in% names(tbl)) {
Expand Down Expand Up @@ -289,15 +293,13 @@ BlockwiseSparseReadIter <- R6::R6Class(
#' @template param-dots-ignored
#' @template param-repr-read
#'
initialize = function(
sr,
array,
coords,
axis,
...,
repr = "T",
reindex_disable_on_axis = NA
) {
initialize = function(sr,
array,
coords,
axis,
...,
repr = "T",
reindex_disable_on_axis = NA) {
super$initialize(
sr,
array,
Expand All @@ -310,9 +312,9 @@ BlockwiseSparseReadIter <- R6::R6Class(
"Sparse reads only work with two-dimensional arrays" = self$array$ndim() == 2L
)
reprs <- c(
'T',
if (!bit64::as.integer64(0L) %in% self$reindex_disable_on_axis)'R',
if (!bit64::as.integer64(1L) %in% self$reindex_disable_on_axis) 'C'
"T",
if (!bit64::as.integer64(0L) %in% self$reindex_disable_on_axis) "R",
if (!bit64::as.integer64(1L) %in% self$reindex_disable_on_axis) "C"
)
private$.repr <- match.arg(repr, choices = reprs)
private$.shape <- sapply(coords, length)
Expand Down
4 changes: 2 additions & 2 deletions apis/r/R/ConfigList.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#' @noMd
#'
ConfigList <- R6::R6Class(
classname = 'ConfigList',
classname = "ConfigList",
inherit = MappingBase,
public = list(
#' @param param Outer key or \dQuote{parameter} to fetch
Expand Down Expand Up @@ -54,7 +54,7 @@ ConfigList <- R6::R6Class(
"'param' must be a single character" = is_scalar_character(param)
)
parammap <- super$get(key = param, default = ScalarMap$new())
if (missing(key) && inherits(x = value, what = 'ScalarMap')) {
if (missing(key) && inherits(x = value, what = "ScalarMap")) {
parammap$update(map = value)
super$set(key = param, value = parammap)
return(invisible(x = self))
Expand Down
34 changes: 20 additions & 14 deletions apis/r/R/CoordsStrider.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ CoordsStrider <- R6::R6Class(
stopifnot(
"'start' must be a single integer value" = rlang::is_integerish(start, 1L, TRUE) ||
(inherits(start, "integer64") && length(start) == 1L && is.finite(start)),
"'end' must be a single integer value" = rlang::is_integerish(end, 1L, TRUE) ||
"'end' must be a single integer value" = rlang::is_integerish(end, 1L, TRUE) ||
(inherits(end, "integer64") && length(end) == 1L && is.finite(end)),
"'start' must be less than or equal to 'end'" = start <= end
)
Expand Down Expand Up @@ -140,18 +140,22 @@ CoordsStrider <- R6::R6Class(
#' @field start If set, the starting point of the iterated coordinates;
#' otherwise the minimum value of \code{self$coords}
#'
start = function() if (is.null(self$coords)) {
private$.start
} else {
bit64::min.integer64(self$coords)
start = function() {
if (is.null(self$coords)) {
private$.start
} else {
bit64::min.integer64(self$coords)
}
},
#' @field end If set, the end point of the iterated coordinates;
#' otherwise the maximum value of \code{self$coords}
#'
end = function() if (is.null(self$coords)) {
private$.end
} else {
bit64::max.integer64(self$coords)
end = function() {
if (is.null(self$coords)) {
private$.end
} else {
bit64::max.integer64(self$coords)
}
},
#' @field stride The stride, or how many coordinates to generate per
#' iteration; note: this field is settable, which will reset the iterator
Expand Down Expand Up @@ -184,10 +188,12 @@ CoordsStrider <- R6::R6Class(
.end = NULL,
.stride = NULL,
.index = NULL,
.stopIteration = function() stop(errorCondition(
"StopIteration",
class = "stopIteration"
))
.stopIteration = function() {
stop(errorCondition(
"StopIteration",
class = "stopIteration"
))
}
)
)

Expand Down Expand Up @@ -223,7 +229,7 @@ hasNext.CoordsStrider <- function(obj, ...) obj$has_next()
unlist64 <- function(x) {
stopifnot(
"'x' must be a list" = is.list(x),
"'x' must contain 'integer64' values" = all(vapply_lgl(x, inherits, what = 'integer64'))
"'x' must contain 'integer64' values" = all(vapply_lgl(x, inherits, what = "integer64"))
)
res <- bit64::integer64(sum(vapply_int(x, length)))
idx <- 1L
Expand Down
Loading