Skip to content

Fix Travis failures on r-devel #3163

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

Merged
Merged
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
5 changes: 5 additions & 0 deletions R/backports.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ if (getRversion() < 3.3) {
} else {
backport_unit_methods <- function() {}
}

# isFALSE() is available on R (>=3.5)
if (getRversion() < 3.5) {
isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
}
2 changes: 1 addition & 1 deletion R/guide-colorbar.r
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ guide_geom.colorbar <- function(guide, layers, default_mapping) {
guide_layers <- lapply(layers, function(layer) {
matched <- matched_aes(layer, guide, default_mapping)

if (length(matched) && ((is.na(layer$show.legend) || layer$show.legend))) {
if (length(matched) > 0 && (isTRUE(is.na(layer$show.legend)) || isTRUE(layer$show.legend))) {
layer
} else {
# This layer does not use this guide
Expand Down
4 changes: 2 additions & 2 deletions R/guide-legend.r
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ guide_geom.legend <- function(guide, layers, default_mapping) {
include <- is.na(layer$show.legend[matched]) ||
layer$show.legend[matched]
} else {
include <- is.na(layer$show.legend) || layer$show.legend
include <- isTRUE(is.na(layer$show.legend)) || isTRUE(layer$show.legend)
}

if (include) {
Expand All @@ -271,7 +271,7 @@ guide_geom.legend <- function(guide, layers, default_mapping) {
}
} else {
# This layer does not contribute to the legend
if (is.na(layer$show.legend) || !layer$show.legend) {
if (isTRUE(is.na(layer$show.legend)) || !isTRUE(layer$show.legend)) {
# Default is to exclude it
return(NULL)
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/guides-.r
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ guides_train <- function(scales, theme, guides, labels) {
# this should be changed to testing guide == "none"
# scale$legend is backward compatibility
# if guides(XXX=FALSE), then scale_ZZZ(guides=XXX) is discarded.
if (guide == "none" || (is.logical(guide) && !guide)) next
if (identical(guide, "none") || isFALSE(guide)) next

# check the validity of guide.
# if guide is character, then find the guide object
guide <- validate_guide(guide)

# check the consistency of the guide and scale.
if (guide$available_aes != "any" && !scale$aesthetics %in% guide$available_aes)
if (!identical(guide$available_aes, "any") && !any(scale$aesthetics %in% guide$available_aes))
stop("Guide '", guide$name, "' cannot be used for '", scale$aesthetics, "'.")

guide$title <- scale$make_title(guide$title %|W|% scale$name %|W|% labels[[output]])
Expand Down
2 changes: 1 addition & 1 deletion R/position-stack.r
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ PositionFill <- ggproto("PositionFill", PositionStack,

stack_var <- function(data) {
if (!is.null(data$ymax)) {
if (any(data$ymin != 0 && data$ymax != 0, na.rm = TRUE)) {
if (any(data$ymin != 0 & data$ymax != 0, na.rm = TRUE)) {
warning("Stacking not well defined when not anchored on the axis", call. = FALSE)
}
"ymax"
Expand Down
6 changes: 4 additions & 2 deletions R/scale-.r
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,8 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = waiver(),

position <- match.arg(position, c("left", "right", "top", "bottom"))

if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
# If the scale is non-positional, break = NULL means removing the guide
if (is.null(breaks) && all(!is_position_aes(aesthetics))) {
guide <- "none"
}

Expand Down Expand Up @@ -634,7 +635,8 @@ discrete_scale <- function(aesthetics, scale_name, palette, name = waiver(),

position <- match.arg(position, c("left", "right", "top", "bottom"))

if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
# If the scale is non-positional, break = NULL means removing the guide
if (is.null(breaks) && all(!is_position_aes(aesthetics))) {
guide <- "none"
}

Expand Down