Skip to content

Commit d0e49e1

Browse files
Merge pull request #45 from m-muecke/equals
refactor: remove redundant comparison use more `isTRUE()` and `isFALSE`
2 parents fa93ce0 + 0328b28 commit d0e49e1

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

R/baselearners.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ hyper_signal <- function(mf, vary, inS="smooth", knots = 10, boundary.knots = NU
229229
# stop("variable names and knot names must be the same")
230230
# if (is.list(boundary.knots)) if(!all(names(boundary.knots) %in% nm))
231231
# stop("variable names and boundary.knot names must be the same")
232-
if (!identical(center, FALSE) && cyclic)
232+
if (!isFALSE(center) && cyclic)
233233
stop("centering of cyclic covariates not yet implemented")
234234
# ret <- vector(mode = "list", length = length(nm))
235235
# names(ret) <- nm
@@ -363,7 +363,7 @@ X_bsignal <- function(mf, vary, args) {
363363

364364
#####################################################
365365
####### K <- crossprod(K) has been computed before!
366-
if (!identical(args$center, FALSE)) {
366+
if (!isFALSE(args$center)) {
367367

368368
### L = \Gamma \Omega^1/2 in Section 2.3. of
369369
### Fahrmeir et al. (2004, Stat Sinica); "spectralDecomp"
@@ -1102,7 +1102,7 @@ hyper_hist <- function(mf, vary, knots = 10, boundary.knots = NULL, degree = 3,
11021102
# stop("variable names and knot names must be the same")
11031103
# if (is.list(boundary.knots)) if(!all(names(boundary.knots) %in% nm))
11041104
# stop("variable names and boundary.knot names must be the same")
1105-
if (!identical(center, FALSE) && cyclic)
1105+
if (!isFALSE(center) && cyclic)
11061106
stop("centering of cyclic covariates not yet implemented")
11071107
# ret <- vector(mode = "list", length = length(nm))
11081108
# names(ret) <- nm
@@ -1990,7 +1990,7 @@ X_bbsc <- function(mf, vary, args) {
19901990
if (vary != "" && ncol(by) > 1){ # build block diagonal penalty
19911991
suppressMessages(K <- kronecker(diag(ncol(by)), K))
19921992
}
1993-
if (!identical(args$center, FALSE)) {
1993+
if (!isFALSE(args$center)) {
19941994
### L = \Gamma \Omega^1/2 in Section 2.3. of Fahrmeir et al.
19951995
### (2004, Stat Sinica), always
19961996
L <- eigen(K, symmetric = TRUE)
@@ -2010,7 +2010,7 @@ X_bbsc <- function(mf, vary, args) {
20102010
### <SB> Calculate constraints
20112011

20122012
## for center = TRUE, design matrix does not contain constant part
2013-
if(args$center != FALSE){
2013+
if(!isFALSE(args$center)){
20142014

20152015
## center the columns of the design matrix
20162016
## Z contains column means

R/baselearnersX.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ hyper_histx <- function(mf, vary, knots = 10, boundary.knots = NULL, degree = 3,
3232
stop("variable names and knot names must be the same")
3333
if (is.list(boundary.knots)) if(!all(names(boundary.knots) %in% nm))
3434
stop("variable names and boundary.knot names must be the same")
35-
if (!identical(center, FALSE) && cyclic)
35+
if (!isFALSE(center) && cyclic)
3636
stop("centering of cyclic covariates not yet implemented")
3737
ret <- vector(mode = "list", length = length(nm))
3838
names(ret) <- nm

R/constrainedX.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@
8989
if(any(used_bl == "bolsc")) stop("Use bols instead of bolsc with %Xc%.")
9090
if(any(used_bl == "brandomc")) stop("Use brandom instead of brandomc with %Xc%.")
9191
if(any(used_bl == "bbsc")) stop("Use bbs instead of bbsc with %Xc%.")
92-
if( (!is.null(match.call()$bl1$intercept) && match.call()$bl1$intercept != TRUE) ||
93-
(!is.null(match.call()$bl2$intercept) && match.call()$bl2$intercept != TRUE) ){
92+
if( (!is.null(match.call()$bl1$intercept) && !isTRUE(match.call()$bl1$intercept)) ||
93+
(!is.null(match.call()$bl2$intercept) && !isTRUE(match.call()$bl2$intercept)) ){
9494
stop("Set intercept = TRUE in base-learners used with %Xc%.")
9595
}
9696

R/crossvalidation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ validateFDboost <- function(object, response = NULL,
800800
# Using the offset of object with the following settings
801801
# call$control <- boost_control(risk="oobag")
802802
# call$oobweights <- oobweights[id]
803-
if(refitSmoothOffset == FALSE && is.null(call$offset) ){
803+
if(!refitSmoothOffset && is.null(call$offset) ){
804804
if(!inherits(object, "FDboostLong")){
805805
call$offset <- matrix(object$offset, ncol = Gy)[1, ]
806806
}else{

R/methods.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ coef.FDboost <- function(object, raw = FALSE, which = NULL,
10501050
if(!is.matrix(predHelp)){
10511051
X <- predHelp
10521052
}else{
1053-
X <- if(any(trm$get_names() %in% c("ONEtime")) ||
1053+
X <- if(any(trm$get_names() %in% "ONEtime") ||
10541054
inherits(object, "FDboostScalar")){ # effect constant in t
10551055
predHelp[,1]
10561056
}else{

0 commit comments

Comments
 (0)