Skip to content

Commit

Permalink
remove redundant assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
cyianor committed Nov 22, 2024
1 parent cedfa98 commit 17ddc7c
Showing 1 changed file with 10 additions and 29 deletions.
39 changes: 10 additions & 29 deletions R/scregclust.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ scregclust <- function(expression,
# START input validation
###############################

# This one needs to happen first so we can use it for input validation
if (!(
is.logical(verbose)
&& length(verbose) == 1
)) {
cli::cli_abort(
"{.var verbose} needs to be TRUE or FALSE."
)
}

if (verbose) {
cat(paste0(cli::symbol$arrow_right, " Validating input"))
cl <- TRUE
Expand Down Expand Up @@ -225,8 +235,6 @@ scregclust <- function(expression,
"i" =
"There needs to be one gene symbol for each gene in {.var expression}."
))
} else {
genesymbols <- genesymbols
}

if (!(
Expand Down Expand Up @@ -357,8 +365,6 @@ scregclust <- function(expression,
"for each column of {.var expression}."
)
))
} else {
sample_assignment <- sample_assignment
}

if (!(
Expand All @@ -372,8 +378,6 @@ scregclust <- function(expression,
cli::cli_abort(
"{.var center} needs to be TRUE or FALSE."
)
} else {
center <- center
}

# If no split indices are provided, then the data split is determined
Expand Down Expand Up @@ -630,8 +634,6 @@ scregclust <- function(expression,
cli::cli_abort(
"{.var allocate_per_obs} needs to be TRUE or FALSE."
)
} else {
allocate_per_obs <- allocate_per_obs
}

if (!(
Expand Down Expand Up @@ -678,8 +680,6 @@ scregclust <- function(expression,
cli::cli_abort(
"{.var use_kmeanspp_init} needs to be TRUE or FALSE."
)
} else {
use_kmeanspp_init <- use_kmeanspp_init
}

if (!(
Expand Down Expand Up @@ -771,8 +771,6 @@ scregclust <- function(expression,
cli::cli_abort(
"{.var compute_predictive_r2} needs to be TRUE or FALSE."
)
} else {
compute_predictive_r2 <- compute_predictive_r2
}

if (!(
Expand All @@ -786,23 +784,6 @@ scregclust <- function(expression,
cli::cli_abort(
"{.var compute_silhouette} needs to be TRUE or FALSE."
)
} else {
compute_silhouette <- compute_silhouette
}

if (!(
is.logical(verbose)
&& length(verbose) == 1
)) {
if (verbose && cl) {
cat("\n")
cl <- FALSE
}
cli::cli_abort(
"{.var verbose} needs to be TRUE or FALSE."
)
} else {
verbose <- verbose
}

if (verbose) {
Expand Down

0 comments on commit 17ddc7c

Please sign in to comment.