Skip to content

Commit f340b1a

Browse files
authored
Clear merge debris (Re: #6416) (#6432)
* rename `is.waiver()` to `is_waiver()` * rename `is.zero()` to `is_zero()` * rename `is.rel()` to `is_rel()` * replace `is.formula()` with `rlang::is_formula()` * rename `is.derived()` to `is_derived()` * rename `is.sec_axis()` to `is_sec_axis()` * rename `is.discrete()` to `is_discrete()` * include novelty elements in `is_theme_element()` * consistently use `is_theme_element()` * catch an `is_zero()` case
1 parent a7371db commit f340b1a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+131
-132
lines changed

NAMESPACE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,6 @@ export(is.facet)
478478
export(is.ggplot)
479479
export(is.ggproto)
480480
export(is.theme)
481-
export(is.waiver)
482481
export(is_coord)
483482
export(is_facet)
484483
export(is_geom)
@@ -494,6 +493,7 @@ export(is_scale)
494493
export(is_stat)
495494
export(is_theme)
496495
export(is_theme_element)
496+
export(is_waiver)
497497
export(label_both)
498498
export(label_bquote)
499499
export(label_context)

NEWS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
@yutannihilation's prior work, #3120)
9595
* When discrete breaks have names, they'll be used as labels by default
9696
(@teunbrand, #6147).
97-
* The helper function `is.waiver()` is now exported to help extensions to work
97+
* The helper function `is_waiver()` is now exported to help extensions to work
9898
with `waiver()` objects (@arcresu, #6173).
9999
* Date(time) scales now throw appropriate errors when `date_breaks`,
100100
`date_minor_breaks` or `date_labels` are not strings (@RodDalBen, #5880)

R/aes.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ aes_ <- function(x, y, ...) {
302302
caller_env <- parent.frame()
303303

304304
as_quosure_aes <- function(x) {
305-
if (is.formula(x) && length(x) == 2) {
305+
if (is_formula(x) && length(x) == 2) {
306306
as_quosure(x)
307307
} else if (is.null(x) || is.call(x) || is.name(x) || is.atomic(x)) {
308308
new_aesthetic(x, caller_env)

R/axis-secondary.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,19 @@ dup_axis <- function(transform = identity, name = derive(), breaks = derive(),
124124
sec_axis(transform, trans = trans, name, breaks, labels, guide)
125125
}
126126

127-
is.sec_axis <- function(x) {
127+
is_sec_axis <- function(x) {
128128
inherits(x, "AxisSecondary")
129129
}
130130

131131
set_sec_axis <- function(sec.axis, scale) {
132-
if (!is.waiver(sec.axis)) {
132+
if (!is_waiver(sec.axis)) {
133133
if (scale$is_discrete()) {
134134
if (!identical(.subset2(sec.axis, "trans"), identity)) {
135135
cli::cli_abort("Discrete secondary axes must have the {.fn identity} transformation.")
136136
}
137137
}
138-
if (is.formula(sec.axis)) sec.axis <- sec_axis(sec.axis)
139-
if (!is.sec_axis(sec.axis)) {
138+
if (is_formula(sec.axis)) sec.axis <- sec_axis(sec.axis)
139+
if (!is_sec_axis(sec.axis)) {
140140
cli::cli_abort("Secondary axes must be specified using {.fn sec_axis}.")
141141
}
142142
scale$secondary.axis <- sec.axis
@@ -150,7 +150,7 @@ set_sec_axis <- function(sec.axis, scale) {
150150
derive <- function() {
151151
structure(list(), class = "derived")
152152
}
153-
is.derived <- function(x) {
153+
is_derived <- function(x) {
154154
inherits(x, "derived")
155155
}
156156
#' @rdname ggplot2-ggproto
@@ -182,9 +182,9 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
182182
if (!is.function(transform)) {
183183
cli::cli_abort("Transformation for secondary axes must be a function.")
184184
}
185-
if (is.derived(self$name) && !is.waiver(scale$name)) self$name <- scale$name
186-
if (is.derived(self$breaks)) self$breaks <- scale$breaks
187-
if (is.waiver(self$breaks)) {
185+
if (is_derived(self$name) && !is_waiver(scale$name)) self$name <- scale$name
186+
if (is_derived(self$breaks)) self$breaks <- scale$breaks
187+
if (is_waiver(self$breaks)) {
188188
if (scale$is_discrete()) {
189189
self$breaks <- setNames(nm = scale$get_breaks())
190190
} else {
@@ -197,8 +197,8 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
197197
}
198198
}
199199
}
200-
if (is.derived(self$labels)) self$labels <- scale$labels
201-
if (is.derived(self$guide)) self$guide <- scale$guide
200+
if (is_derived(self$labels)) self$labels <- scale$labels
201+
if (is_derived(self$guide)) self$guide <- scale$guide
202202
},
203203

204204
transform_range = function(self, range) {

R/coord-radial.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ deg2rad <- function(deg) deg * pi / 180
576576
# Function to rotate a radius axis through viewport
577577
rotate_r_axis <- function(axis, angle, bbox, position = "left") {
578578

579-
if (inherits(axis, "zeroGrob")) {
579+
if (is_zero(axis)) {
580580
return(axis)
581581
}
582582

R/coord-sf.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
116116
x_breaks <- graticule$degree[graticule$type == "E"]
117117
if (is.null(scale_x$labels)) {
118118
x_labels <- rep(NA, length(x_breaks))
119-
} else if (is.waiver(scale_x$labels)) {
119+
} else if (is_waiver(scale_x$labels)) {
120120
x_labels <- graticule$degree_label[graticule$type == "E"]
121121
needs_autoparsing[graticule$type == "E"] <- TRUE
122122
} else {
@@ -141,7 +141,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
141141
y_breaks <- graticule$degree[graticule$type == "N"]
142142
if (is.null(scale_y$labels)) {
143143
y_labels <- rep(NA, length(y_breaks))
144-
} else if (is.waiver(scale_y$labels)) {
144+
} else if (is_waiver(scale_y$labels)) {
145145
y_labels <- graticule$degree_label[graticule$type == "N"]
146146
needs_autoparsing[graticule$type == "N"] <- TRUE
147147
} else {
@@ -335,7 +335,7 @@ CoordSf <- ggproto("CoordSf", CoordCartesian,
335335

336336
# we don't draw the graticules if the major panel grid is
337337
# turned off
338-
if (inherits(el, "element_blank")) {
338+
if (is_theme_element(el, "blank")) {
339339
grobs <- list(element_render(theme, "panel.background"))
340340
} else {
341341
line_gp <- gg_par(
@@ -554,7 +554,7 @@ coord_sf <- function(xlim = NULL, ylim = NULL, expand = TRUE,
554554
ndiscr = 100, default = FALSE, clip = "on",
555555
reverse = "none") {
556556

557-
if (is.waiver(label_graticule) && is.waiver(label_axes)) {
557+
if (is_waiver(label_graticule) && is_waiver(label_axes)) {
558558
# if both `label_graticule` and `label_axes` are set to waive then we
559559
# use the default of labels on the left and at the bottom
560560
label_graticule <- ""
@@ -641,13 +641,13 @@ sf_breaks <- function(scale_x, scale_y, bbox, crs) {
641641
bbox[is.na(bbox)] <- c(-180, -90, 180, 90)[is.na(bbox)]
642642
}
643643

644-
if (!(is.waiver(scale_x$breaks) && is.null(scale_x$n.breaks))) {
644+
if (!(is_waiver(scale_x$breaks) && is.null(scale_x$n.breaks))) {
645645
x_breaks <- scale_x$get_breaks(limits = bbox[c(1, 3)])
646646
finite <- is.finite(x_breaks)
647647
x_breaks <- if (any(finite)) x_breaks[finite] else NULL
648648
}
649649

650-
if (!(is.waiver(scale_y$breaks) && is.null(scale_y$n.breaks))) {
650+
if (!(is_waiver(scale_y$breaks) && is.null(scale_y$n.breaks))) {
651651
y_breaks <- scale_y$get_breaks(limits = bbox[c(2, 4)])
652652
finite <- is.finite(y_breaks)
653653
y_breaks <- if (any(finite)) y_breaks[finite] else NULL
@@ -770,7 +770,7 @@ view_scales_from_graticule <- function(graticule, scale, aesthetic,
770770
if (scale$position != position) {
771771
# Try to use secondary axis' guide
772772
guide <- scale$secondary.axis$guide %||% waiver()
773-
if (is.derived(guide)) {
773+
if (is_derived(guide)) {
774774
guide <- scale$guide
775775
}
776776
} else {

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-null.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ FacetNull <- ggproto("FacetNull", Facet,
3030
layout_null()
3131
},
3232
map_data = function(data, layout, params) {
33-
# Need the is.waiver check for special case where no data, but aesthetics
33+
# Need the is_waiver check for special case where no data, but aesthetics
3434
# are mapped to vectors
35-
if (is.waiver(data))
35+
if (is_waiver(data))
3636
return(data_frame0(PANEL = factor()))
3737

3838
if (empty(data))

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ 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")

0 commit comments

Comments
 (0)