Skip to content

Commit

Permalink
default parameters for scalePalette
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptisteDlp committed Dec 9, 2023
1 parent e17e79a commit 01e5424
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
26 changes: 22 additions & 4 deletions R/defStormsList.R
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,12 @@ checkInputsDefStormsList <- function(sds, loi, seasons, names, maxDist, scale, s
stopifnot("scale must be vector of numeric" = identical(class(scale), "numeric"))

# Checking scalePalette input
stopifnot("scalePalette must be a named vector of character" = identical(class(scalePalette), "character"))
if(!is.null(scalePalette)){
stopifnot("scalePalette must be a (named) character vector" = identical(class(scalePalette), "character"))
stopifnot("(lenght(scalePalette) must be equal to lenght(scale) + 1)" =
length(scalePalette) == length(scale) + 1)

Check warning on line 659 in R/defStormsList.R

View check run for this annotation

Codecov / codecov/patch

R/defStormsList.R#L657-L659

Added lines #L657 - L659 were not covered by tests
}

stopifnot("invalid length of either scale or scalePalette input (lenght(scalePalette) must be equal to lenght(scalePalette) + 1)" =
length(scalePalette) == length(scale) + 1)

#Checking verbose input
stopifnot("verbose must be numeric" = identical(class(verbose), "numeric"))
Expand Down Expand Up @@ -1042,7 +1044,7 @@ defStormsList <- function(sds,
names = NULL,
maxDist = 300,
scale = sshs,
scalePalette = sshsPalette,
scalePalette = NULL,
removeUnder = NULL,
verbose = 2) {

Expand All @@ -1052,6 +1054,22 @@ defStormsList <- function(sds,

# order scale
scale = scale[order(scale)]


if(identical(scale, sshs) & is.null(scalePalette)){
# Default palette should be SSHS
scalePalette <- sshsPalette

}else if(scale != sshs & is.null(scalePalette)){

Check warning on line 1063 in R/defStormsList.R

View check run for this annotation

Codecov / codecov/patch

R/defStormsList.R#L1063

Added line #L1063 was not covered by tests
# Create a default color Palette based on the number of level in scale

}else if(is.null(names(scalePalette))){

Check warning on line 1066 in R/defStormsList.R

View check run for this annotation

Codecov / codecov/patch

R/defStormsList.R#L1066

Added line #L1066 was not covered by tests
# If scalePalette has no names, provide default ones
names(scalePalette) <- seq(1, length(scalePalette))

Check warning on line 1068 in R/defStormsList.R

View check run for this annotation

Codecov / codecov/patch

R/defStormsList.R#L1068

Added line #L1068 was not covered by tests

}



if (length(seasons) == 2)
seasons <- seasons[order(seasons)]
Expand Down
2 changes: 1 addition & 1 deletion man/defStormsList.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 01e5424

Please sign in to comment.