Skip to content

Commit

Permalink
fix: lintr annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
gisler committed Dec 26, 2023
1 parent e85c8de commit bc3f57b
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 33 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# DTSg v1.1.3.9000

* Slightly improved documentation.
* Minor internal code improvements.

# DTSg v1.1.3

Expand Down
25 changes: 12 additions & 13 deletions R/ClassDTSg.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ DTSg <- R6Class(
tryCatch(
{
if (!testMultiClass(i, c("integer", "numeric")) && !is.expression(i) &&
!is.character(i) && !is.list(i)) {
!is.character(i) && !is.list(i)) {
i <- expr
}

Expand Down Expand Up @@ -429,15 +429,14 @@ DTSg <- R6Class(
if (...length() > 0L) {
dots <- list(...)
dots <- sprintf("%s = %s", names(dots), dots)
sprintf(", %s", paste(dots, collapse = ", "))
sprintf(", %s", toString(dots))
} else {
""
}
}

text <- paste(
sprintf("%s = %s(%s%s)", resultCols, funs, cols, dotsToCharacter(...)),
collapse = ", "
text <- toString(
sprintf("%s = %s(%s%s)", resultCols, funs, cols, dotsToCharacter(...))
)

sprintf("list(%s)", text)
Expand Down Expand Up @@ -581,7 +580,7 @@ DTSg <- R6Class(
}

if ((by != private$.periodicity || na.status == "explicit") &&
by != "unrecognised") {
by != "unrecognised") {
if (rollback && mday(from) > 28L && grepl("^\\d+ (month|year)(s?)$", by)) {
DT <- data.table(
.dateTime = rollback(seq(
Expand All @@ -608,7 +607,7 @@ DTSg <- R6Class(
call. = FALSE
)
} else if (na.status == "explicit" && by == "unrecognised" &&
private$.timestamps > 2L) {
private$.timestamps > 2L) {
warning(
"Only time series with recognised periodicity can have explicitly missing values.\n",
'Consider calling "alter()" with "na.status = \'explicit\'" and specified "by" argument.',
Expand Down Expand Up @@ -758,7 +757,7 @@ DTSg <- R6Class(

modes <- vapply(
private$.values[, cols, with = FALSE],
function(col) mode(col),
function(col) mode(col), # nolint
character(1L)
)

Expand All @@ -770,7 +769,7 @@ DTSg <- R6Class(

typeofs <- vapply(
private$.values[, cols, with = FALSE],
function(col) typeof(col),
function(col) typeof(col), # nolint
character(1L)
)

Expand Down Expand Up @@ -937,7 +936,7 @@ DTSg <- R6Class(
secAxisLabel = ""
) {
if (!requireNamespace("dygraphs", quietly = TRUE) ||
!requireNamespace("RColorBrewer", quietly = TRUE)) {
!requireNamespace("RColorBrewer", quietly = TRUE)) {
stop(
'Packages "dygraphs" and "RColorBrewer" must be installed for this method.',
call. = FALSE
Expand Down Expand Up @@ -1124,7 +1123,7 @@ DTSg <- R6Class(
DT <- private$.values[DT, on = sprintf("%s == .dateTime", firstCol)]
lags <- diff(DT[[1L]])
if (all(lags >= private$.minLag) && all(lags <= private$.maxLag) &&
sum(!is.na(DT[, -1L])) == sum(!is.na(private$.values[seqLen, -1L]))) {
sum(!is.na(DT[, -1L])) == sum(!is.na(private$.values[seqLen, -1L]))) {
private$.periodicity <- by

break
Expand Down Expand Up @@ -1443,8 +1442,8 @@ DTSg <- R6Class(
)
assertNoStartingDot(cols)
if (length(cols) == length(names(private$.values)) - 1L &&
((is.list(values) && all(vapply(values, is.null, logical(1L)))) ||
is.null(values))) {
((is.list(values) && all(vapply(values, is.null, logical(1L)))) ||
is.null(values))) {
stop("Removing all value columns is not allowed.", call. = FALSE)
}
qassert(clone, "B1")
Expand Down
6 changes: 3 additions & 3 deletions R/Swrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ S3WrapperGenerator <- function(R6Method, self = "x", dots = TRUE) {
R6Method <- as.expression(substitute(R6Method))
}
if (!is.expression(R6Method) ||
R6Method[[1L]][[2L]][[3L]] != "public_methods" ||
!is.R6Class(eval(R6Method[[1L]][[2L]][[2L]]))) {
R6Method[[1L]][[2L]][[3L]] != "public_methods" ||
!is.R6Class(eval(R6Method[[1L]][[2L]][[2L]]))) {
stop(
'"R6Method" must contain a public method of an "R6ClassGenerator".',
call. = FALSE
Expand All @@ -38,7 +38,7 @@ S3WrapperGenerator <- function(R6Method, self = "x", dots = TRUE) {
qassert(dots, "B1")

args <- list()
args[[self]] <- alist(`self` = )$`self`
args[[self]] <- alist(self = )$self
args <- c(args, formals(eval(R6Method)))

if (dots && !any(names(args) == "...")) {
Expand Down
2 changes: 1 addition & 1 deletion R/TALFs.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ to.fakeUTCdateTime <- function(.dateTime, .helpers) {
)

if (grepl("^\\d+ (month|year)(s?)$", .helpers[["periodicity"]]) &&
mday(.dateTime[1L]) > 28L) {
mday(.dateTime[1L]) > 28L) {
.dateTime <- rollback(.dateTime, .helpers[["periodicity"]])
}

Expand Down
12 changes: 6 additions & 6 deletions R/aaa.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
NULL

.onLoad <- function(libname, pkgname) {
suppressWarnings(onCRAN <- isTRUE(as.logical(as.numeric(
suppressWarnings(onCRAN <- isTRUE(as.logical(as.numeric( # nolint
Sys.getenv("_R_CHECK_EXAMPLE_TIMING_CPU_TO_ELAPSED_THRESHOLD_")
))))
if (onCRAN) {
setDTthreads(2L)
}

getOption("DTSgClone" , options(DTSgClone = TRUE )) # nolint
getOption("DTSgDeprecatedWarnings", options(DTSgDeprecatedWarnings = TRUE )) # nolint
getOption("DTSgFast" , options(DTSgFast = FALSE )) # nolint
getOption("DTSgFunbyApproach" , options(DTSgFunbyApproach = "base" )) # nolint
getOption("DTSgNA.status" , options(DTSgNA.status = "explicit")) # nolint
getOption("DTSgClone" , options(DTSgClone = TRUE ))
getOption("DTSgDeprecatedWarnings", options(DTSgDeprecatedWarnings = TRUE ))
getOption("DTSgFast" , options(DTSgFast = FALSE ))
getOption("DTSgFunbyApproach" , options(DTSgFunbyApproach = "base" ))
getOption("DTSgNA.status" , options(DTSgNA.status = "explicit"))
}
4 changes: 2 additions & 2 deletions R/assertives.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ assertFunbyApproach <- function(funbyApproach) {
funbyApproach <- match.arg(funbyApproach, c("base", "fasttime", "RcppCCTZ"))

if (funbyApproach == "fasttime" &&
!requireNamespace("fasttime", quietly = TRUE)) {
!requireNamespace("fasttime", quietly = TRUE)) {
stop(
'Package "fasttime" must be installed for this approach.',
call. = FALSE
)
} else if (funbyApproach == "RcppCCTZ" &&
!requireNamespace("RcppCCTZ", quietly = TRUE)) {
!requireNamespace("RcppCCTZ", quietly = TRUE)) {
stop(
'Package "RcppCCTZ" must be installed for this approach.',
call. = FALSE
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/data.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library(data.table) # nolint
library(data.table)

#### global test data ####
DT1 <- data.table(
Expand Down
5 changes: 2 additions & 3 deletions inst/tinytest/test_DTSg.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source("data.R") # nolint
source("data.R")

#### aggregate method ####
expect_identical(
Expand Down Expand Up @@ -1118,13 +1118,12 @@ expect_identical(
info = "values are copied"
)

expect_identical(
expect_null(
{
TS <- DTSg$new(DT1)
TS$values(TRUE)[, col1 := NULL]
TS$values(TRUE)[["col1"]]
},
NULL,
info = "reference to values is returned"
)

Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_TALFs.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source("data.R") # nolint
source("data.R")

for (approach in c("base", "fasttime", "RcppCCTZ")) {
options(DTSgFunbyApproach = approach)
Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_deprecated.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source("data.R") # nolint
source("data.R")

options(DTSgDeprecatedWarnings = FALSE)

Expand Down
2 changes: 1 addition & 1 deletion inst/tinytest/test_utils.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source("data.R") # nolint
source("data.R")

#### interpolateLinear ####
expect_identical(
Expand Down
2 changes: 1 addition & 1 deletion vignettes/b_advancedUsage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ TS <- DTSg$new(flow)
TS$summary()
TS$
colapply(
function(x, ...) ifelse(is.na(x), TRUE, FALSE),
function(x, ...) is.na(x),
resultCols = "missing"
)$
colapply(interpolateLinear)$
Expand Down

0 comments on commit bc3f57b

Please sign in to comment.