Skip to content

Commit ba76efc

Browse files
committed
replace is.zero() with is_zero()
1 parent 884b0b0 commit ba76efc

13 files changed

+26
-21
lines changed

R/facet-grid-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ ulevels <- function(x, na.last = TRUE) {
430430

431431
table_has_grob <- function(table, pattern) {
432432
grobs <- table$grobs[grep(pattern, table$layout$name)]
433-
!all(vapply(grobs, is.zero, logical(1)))
433+
!all(vapply(grobs, is_zero, logical(1)))
434434
}
435435

436436
seam_table <- function(table, grobs = NULL, side, shift = 1, name, z = 1,

R/facet-wrap.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ FacetWrap <- ggproto("FacetWrap", Facet,
327327
if (length(empty_bottom) > 0) {
328328
x_axes <- original$x$bottom[matched[empty_bottom]]
329329
clash["bottom"] <- strip == "bottom" && !inside && !free$x &&
330-
!all(vapply(x_axes, is.zero, logical(1)))
330+
!all(vapply(x_axes, is_zero, logical(1)))
331331
if (!clash["bottom"]) {
332332
bottom[empty_bottom] <- x_axes
333333
}
@@ -336,7 +336,7 @@ FacetWrap <- ggproto("FacetWrap", Facet,
336336
if (length(empty_top) > 0) {
337337
x_axes <- original$x$top[matched[empty_top]]
338338
clash["top"] <- strip == "top" && !inside && !free$x &&
339-
!all(vapply(x_axes, is.zero, logical(1)))
339+
!all(vapply(x_axes, is_zero, logical(1)))
340340
if (!clash["top"]) {
341341
top[empty_top] <- x_axes
342342
}
@@ -345,7 +345,7 @@ FacetWrap <- ggproto("FacetWrap", Facet,
345345
if (length(empty_right) > 0) {
346346
y_axes <- original$y$right[matched[empty_right]]
347347
clash["right"] <- strip == "right" && !inside && !free$y &&
348-
!all(vapply(y_axes, is.zero, logical(1)))
348+
!all(vapply(y_axes, is_zero, logical(1)))
349349
if (!clash["right"]) {
350350
right[empty_right] <- y_axes
351351
}
@@ -354,7 +354,7 @@ FacetWrap <- ggproto("FacetWrap", Facet,
354354
if (length(empty_left) > 0) {
355355
y_axes <- original$y$left[matched[empty_left]]
356356
clash["left"] <- strip == "left" && !inside && !free$y &&
357-
!all(vapply(y_axes, is.zero, logical(1)))
357+
!all(vapply(y_axes, is_zero, logical(1)))
358358
if (!clash["left"]) {
359359
left[empty_left] <- y_axes
360360
}
@@ -410,7 +410,7 @@ FacetWrap <- ggproto("FacetWrap", Facet,
410410

411411
if (!inside) {
412412
axes <- grepl(paste0("axis-", pos), table$layout$name)
413-
has_axes <- !vapply(table$grobs[axes], is.zero, logical(1))
413+
has_axes <- !vapply(table$grobs[axes], is_zero, logical(1))
414414
has_axes <- split(has_axes, table$layout[[pos]][axes])
415415
has_axes <- vapply(has_axes, sum, numeric(1)) > 0
416416
padding <- rep(padding, length(has_axes))

R/grob-null.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ grobHeight.zeroGrob <- function(x) unit(0, "cm")
2323
#' @method drawDetails zeroGrob
2424
drawDetails.zeroGrob <- function(x, recording) {}
2525

26-
is.zero <- function(x) is.null(x) || inherits(x, "zeroGrob")
26+
is_zero <- function(x) is.null(x) || inherits(x, "zeroGrob")
27+
28+
is.zero <- function(x) {
29+
deprecate_warn("4.0.0", "is.zero()", "is_zero()")
30+
is_zero(x)
31+
}

R/guide-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ Guide <- ggproto(
421421
},
422422

423423
add_title = function(gtable, title, position, just) {
424-
if (is.zero(title)) {
424+
if (is_zero(title)) {
425425
return(gtable)
426426
}
427427

R/guide-axis-stack.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ GuideAxisStack <- ggproto(
195195
}
196196

197197
# Remove empty grobs
198-
grobs <- grobs[!vapply(grobs, is.zero, logical(1))]
198+
grobs <- grobs[!vapply(grobs, is_zero, logical(1))]
199199
if (length(grobs) == 0) {
200200
return(zeroGrob())
201201
}

R/guide-axis.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ GuideAxis <- ggproto(
420420
# Unlist the 'label' grobs
421421
z <- if (params$position == "left") c(2, 1, 3) else 1:3
422422
z <- rep(z, c(1, length(grobs$labels), 1))
423-
has_labels <- !is.zero(grobs$labels[[1]])
423+
has_labels <- !is_zero(grobs$labels[[1]])
424424
grobs <- c(list(grobs$ticks), grobs$labels, list(grobs$title))
425425

426426
# Initialise empty gtable

R/guide-legend.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ GuideLegend <- ggproto(
544544
gt <- gtable(widths = widths, heights = heights)
545545

546546
# Add keys
547-
if (!is.zero(grobs$decor)) {
547+
if (!is_zero(grobs$decor)) {
548548
n_key_layers <- params$n_key_layers %||% 1L
549549
key_cols <- rep(layout$key_col, each = n_key_layers)
550550
key_rows <- rep(layout$key_row, each = n_key_layers)
@@ -560,7 +560,7 @@ GuideLegend <- ggproto(
560560
)
561561
}
562562

563-
if (!is.zero(grobs$labels)) {
563+
if (!is_zero(grobs$labels)) {
564564
gt <- gtable_add_grob(
565565
gt, grobs$labels,
566566
name = names(labels) %||%
@@ -579,7 +579,7 @@ GuideLegend <- ggproto(
579579
gt <- gtable_add_padding(gt, unit(elements$padding, "cm"))
580580

581581
# Add background
582-
if (!is.zero(elements$background)) {
582+
if (!is_zero(elements$background)) {
583583
gt <- gtable_add_grob(
584584
gt, elements$background,
585585
name = "background", clip = "off",

R/guides-.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ Guides <- ggproto(
492492
)
493493

494494
grobs <- self$draw(theme, positions, theme$legend.direction)
495-
keep <- !vapply(grobs, is.zero, logical(1), USE.NAMES = FALSE)
495+
keep <- !vapply(grobs, is_zero, logical(1), USE.NAMES = FALSE)
496496
grobs <- grobs[keep]
497497
if (length(grobs) < 1) {
498498
return(zeroGrob())
@@ -590,7 +590,7 @@ Guides <- ggproto(
590590
# arguments to collect guides
591591
package_box = function(grobs, position, theme) {
592592

593-
if (is.zero(grobs) || length(grobs) == 0) {
593+
if (is_zero(grobs) || length(grobs) == 0) {
594594
return(zeroGrob())
595595
}
596596

R/guides-grid.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ guide_grid <- function(theme, panel_params, coord, square = TRUE) {
3030
grill <- compact(grill)
3131

3232
background <- element_render(theme, "panel.background")
33-
if (!isTRUE(square) && !is.zero(background)) {
33+
if (!isTRUE(square) && !is_zero(background)) {
3434
gp <- background$gp
3535
background <- data_frame0(x = c(1, 1, -1, -1), y = c(1, -1, -1, 1)) * Inf
3636
background <- coord_munch(coord, background, panel_params, is_closed = TRUE)

R/labeller.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ build_strip <- function(label_df, labeller, theme, horizontal) {
546546
#'
547547
#' @noRd
548548
assemble_strips <- function(grobs, theme, horizontal = TRUE, clip) {
549-
if (length(grobs) == 0 || is.zero(grobs[[1]])) {
549+
if (length(grobs) == 0 || is_zero(grobs[[1]])) {
550550
# Subsets matrix of zeroGrobs to correct length (#4050)
551551
grobs <- grobs[seq_len(NROW(grobs))]
552552
return(grobs)

0 commit comments

Comments
 (0)