Skip to content

Commit ae2561b

Browse files
committed
apply tests when applicable
1 parent 049db27 commit ae2561b

13 files changed

+18
-18
lines changed

R/coord-cartesian-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ view_scales_from_scale <- function(scale, coord_limits = NULL, expand = TRUE) {
159159
}
160160

161161
panel_guides_grob <- function(guides, position, theme, labels = NULL) {
162-
if (!inherits(guides, "Guides")) {
162+
if (!is.guides(guides)) {
163163
return(zeroGrob())
164164
}
165165
pair <- guides$get_position(position)

R/facet-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ as_facets_list <- function(x) {
437437
}
438438

439439
validate_facets <- function(x) {
440-
if (inherits(x, "uneval")) {
440+
if (is.mapping(x)) {
441441
cli::cli_abort("Please use {.fn vars} to supply facet variables.")
442442
}
443443
# Native pipe have higher precedence than + so any type of gg object can be

R/fortify.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ fortify.default <- function(model, data, ...) {
7979
"or an object coercible by {.fn fortify}, or a valid ",
8080
"{.cls data.frame}-like object coercible by {.fn as.data.frame}"
8181
)
82-
if (inherits(model, "uneval")) {
82+
if (is.mapping(model)) {
8383
msg <- c(
8484
paste0(msg, ", not ", obj_type_friendly(model), "."),
8585
"i" = "Did you accidentally pass {.fn aes} to the {.arg data} argument?"

R/geom-defaults.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ get_geom_defaults <- function(geom, theme = theme_get()) {
9898
if (is.character(geom)) {
9999
geom <- check_subclass(geom, "Geom")
100100
}
101-
if (inherits(geom, "Geom")) {
101+
if (is.geom(geom)) {
102102
out <- geom$use_defaults(data = NULL, theme = theme)
103103
return(out)
104104
}

R/geom-label.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ GeomLabel <- ggproto("GeomLabel", Geom,
7878
data <- coord$transform(data, panel_params)
7979
data$vjust <- compute_just(data$vjust, data$y, data$x, data$angle)
8080
data$hjust <- compute_just(data$hjust, data$x, data$y, data$angle)
81-
if (!inherits(label.padding, "margin")) {
81+
if (!is.margin("margin")) {
8282
label.padding <- rep(label.padding, length.out = 4)
8383
}
8484

R/guide-.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ Guide <- ggproto(
377377
# Renders tickmarks
378378
build_ticks = function(key, elements, params, position = params$position,
379379
length = elements$ticks_length) {
380-
if (!inherits(elements, "element")) {
380+
if (!is.element(elements)) {
381381
elements <- elements$ticks
382382
}
383383
if (!inherits(elements, "element_line")) {

R/guides-.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ NULL
6969
guides <- function(...) {
7070
args <- list2(...)
7171
if (length(args) > 0) {
72-
if (is.list(args[[1]]) && !inherits(args[[1]], "guide")) args <- args[[1]]
72+
if (is.list(args[[1]]) && !is.guide(args[[1]])) args <- args[[1]]
7373
args <- rename_aes(args)
7474
}
7575

@@ -138,7 +138,7 @@ Guides <- ggproto(
138138
if (is.null(guides)) {
139139
return(invisible())
140140
}
141-
if (inherits(guides, "Guides")) {
141+
if (is.guides(guides)) {
142142
guides <- guides$guides
143143
}
144144
self$guides <- defaults(guides, self$guides)
@@ -862,7 +862,7 @@ validate_guide <- function(guide) {
862862
guide <- fun()
863863
}
864864
}
865-
if (inherits(guide, "Guide")) {
865+
if (is.guide(guide)) {
866866
return(guide)
867867
}
868868
if (inherits(guide, "guide") && is.list(guide)) {

R/layer.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@
5858
#' `NA`, the default, includes if any aesthetics are mapped.
5959
#' `FALSE` never includes, and `TRUE` always includes.
6060
#' It can also be a named logical vector to finely select the aesthetics to
61-
#' display. To include legend keys for all levels, even
62-
#' when no data exists, use `TRUE`. If `NA`, all levels are shown in legend,
61+
#' display. To include legend keys for all levels, even
62+
#' when no data exists, use `TRUE`. If `NA`, all levels are shown in legend,
6363
#' but unobserved levels are omitted.
6464
#' @param inherit.aes If `FALSE`, overrides the default aesthetics,
6565
#' rather than combining with them. This is most useful for helper functions
@@ -203,7 +203,7 @@ layer <- function(geom = NULL, stat = NULL,
203203
}
204204

205205
validate_mapping <- function(mapping, call = caller_env()) {
206-
if (!inherits(mapping, "uneval")) {
206+
if (!is.mapping(mapping)) {
207207
msg <- "{.arg mapping} must be created by {.fn aes}."
208208
# Native pipe have higher precedence than + so any type of gg object can be
209209
# expected here, not just ggplot

R/plot-build.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ ggplot_gtable.ggplot_built <- function(data) {
288288
plot_margin <- calc_element("plot.margin", theme)
289289
plot_table <- gtable_add_padding(plot_table, plot_margin)
290290

291-
if (inherits(theme$plot.background, "element")) {
291+
if (is.element(theme$plot.background)) {
292292
plot_table <- gtable_add_grob(plot_table,
293293
element_render(theme, "plot.background"),
294294
t = 1, l = 1, b = -1, r = -1, name = "background", z = -Inf)

R/plot-construction.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ ggplot_add.labels <- function(object, plot, object_name) {
149149
}
150150
#' @export
151151
ggplot_add.Guides <- function(object, plot, object_name) {
152-
if (inherits(plot$guides, "Guides")) {
152+
if (is.guides(plot$guides)) {
153153
# We clone the guides object to prevent modify-in-place of guides
154154
old <- plot$guides
155155
new <- ggproto(NULL, old)

0 commit comments

Comments
 (0)