Skip to content
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

Clean up orphan functions and tiny one-off helpers #6022

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
20fa50f
replace single use internal functions
teunbrand Aug 1, 2024
0bfbcc3
move helper to location where it is used
teunbrand Aug 1, 2024
79866e8
remove orphan functions
teunbrand Aug 1, 2024
a5a1ce5
replace and remove redundant `adjust_breaks()` function
teunbrand Aug 1, 2024
c4c61de
replace `df_rows()` with `vec_slice()`
teunbrand Aug 1, 2024
2ce92fb
inline `f_as_facets_list()`
teunbrand Aug 1, 2024
15241a6
inline `find_origin()`
teunbrand Aug 1, 2024
2e9b8c2
inline `firstUpper()`
teunbrand Aug 1, 2024
0cca7a3
replace `has_name()`
teunbrand Aug 1, 2024
5f4a4b9
replace `interleave()` with `vec_interleave()`
teunbrand Aug 1, 2024
79fa0b1
remove `cunion()`
teunbrand Aug 1, 2024
abc62dd
inline `is_dotted_var()`
teunbrand Aug 1, 2024
4a3ffff
inline `is_facets()`
teunbrand Aug 1, 2024
9976913
inline `is_labeller()`
teunbrand Aug 1, 2024
b4e0d80
inline `is_missing_arg()`
teunbrand Aug 1, 2024
be4081a
replace `is_npc()` (we partially backport `unitType()`)
teunbrand Aug 1, 2024
70cc78b
inline `is_scalar_numeric()`
teunbrand Aug 1, 2024
997d9fe
inline `is.margin()`
teunbrand Aug 1, 2024
1bdc20d
inline `is.sec_axis()`
teunbrand Aug 1, 2024
b044fa2
inline `is.subclass()`
teunbrand Aug 1, 2024
490c9c3
inline `is_triple_bang()`
teunbrand Aug 1, 2024
4ebdea3
remove `justify_grobs()`
teunbrand Aug 2, 2024
e086817
inline `label_variable()`
teunbrand Aug 2, 2024
024a1b6
more responsibility for `parse_axes_labeling()`, so that it is less d…
teunbrand Aug 2, 2024
b2de86e
remove `resolve_guide()`
teunbrand Aug 2, 2024
f7c8cb6
inline revalue
teunbrand Aug 2, 2024
3232471
simplify `scale_flip_position()`
teunbrand Aug 2, 2024
37da401
remove `as.quoted()` (note there is still `as_quoted()`)
teunbrand Aug 2, 2024
6ac62cf
replace `simplify_formula()` with `simplify()`
teunbrand Aug 2, 2024
db6feb8
inline `single_value()`
teunbrand Aug 2, 2024
e75c6d6
inline `update_guides()`
teunbrand Aug 2, 2024
4739a12
inline `is_column_vec()` and better name for `validate_column_vec()`
teunbrand Aug 2, 2024
47e36e2
remove/replace `wrap_as_facets_list()` (by `compact_facets()`
teunbrand Aug 2, 2024
d74f6a5
finishing touches
teunbrand Aug 2, 2024
8621926
resolve merge conflicts
teunbrand Aug 27, 2024
2f1f42f
`parse_axes_labeling` uses parent call
teunbrand Aug 27, 2024
276e6a2
elaborate on regex pattern
teunbrand Aug 27, 2024
2978d4d
Revert "inline `is_labeller()`"
teunbrand Aug 27, 2024
037c1ae
Revert "inline `is.sec_axis()`"
teunbrand Aug 27, 2024
8076706
Revert "replace single use internal functions"
teunbrand Aug 27, 2024
049db27
Collection of test functions for user-facing components
teunbrand Aug 27, 2024
ae2561b
apply tests when applicable
teunbrand Aug 27, 2024
3be8e6d
redocument
teunbrand Aug 27, 2024
13b8d36
abolish `uniquecols()`'s rownames
teunbrand Sep 13, 2024
d7092aa
move `is.*()` functions to class definitions
teunbrand Sep 13, 2024
16b35e9
resolve merge conflict
teunbrand Sep 13, 2024
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
11 changes: 11 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,20 @@ export(guide_transform)
export(guides)
export(has_flipped_aes)
export(is.Coord)
export(is.coord)
export(is.element)
export(is.facet)
export(is.geom)
export(is.ggplot)
export(is.ggproto)
export(is.guide)
export(is.guides)
export(is.layer)
export(is.mapping)
export(is.margin)
export(is.position)
export(is.scale)
export(is.stat)
export(is.theme)
export(label_both)
export(label_bquote)
Expand Down
6 changes: 0 additions & 6 deletions R/coord-.R
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ Coord <- ggproto("Coord",
}
)

#' Is this object a coordinate system?
#'
#' @export is.Coord
#' @keywords internal
is.Coord <- function(x) inherits(x, "Coord")

# Renders an axis with the correct orientation or zeroGrob if no axis should be
# generated
render_axis <- function(panel_params, axis, scale, position, theme) {
Expand Down
7 changes: 0 additions & 7 deletions R/facet-.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,6 @@ get_strip_labels <- function(plot = get_last_plot()) {
plot$plot$facet$format_strip_labels(layout, params)
}

#' Is this object a faceting specification?
#'
#' @param x object to test
#' @keywords internal
#' @export
is.facet <- function(x) inherits(x, "Facet")

# A "special" value, currently not used but could be used to determine
# if faceting is active
NO_PANEL <- -1L
Expand Down
5 changes: 0 additions & 5 deletions R/ggproto.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ ggproto_parent <- function(parent, self) {
structure(list(parent = parent, self = self), class = "ggproto_parent")
}

#' @param x An object to test.
#' @export
#' @rdname ggproto
is.ggproto <- function(x) inherits(x, "ggproto")

fetch_ggproto <- function(x, name) {
res <- NULL

Expand Down
6 changes: 0 additions & 6 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,6 @@ plot_clone <- function(plot) {
p
}

#' Reports whether x is a ggplot object
#' @param x An object to test
#' @keywords internal
#' @export
is.ggplot <- function(x) inherits(x, "ggplot")

#' Explicitly draw plot
#'
#' Generally, you do not need to print or plot a ggplot2 plot explicitly: the
Expand Down
6 changes: 0 additions & 6 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -905,12 +905,6 @@ combine_elements <- function(e1, e2) {
e1
}

#' Reports whether x is a theme object
#' @param x An object to test
#' @export
#' @keywords internal
is.theme <- function(x) inherits(x, "theme")

#' @export
`$.theme` <- function(x, ...) {
.subset2(x, ...)
Expand Down
83 changes: 83 additions & 0 deletions R/utilities-checks.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,86 @@
# Tests -------------------------------------------------------------------

#' Reports whether x is a type of object
#' @param x An object to test
#' @keywords internal
#' @export
#' @name is_tests
is.ggplot <- function(x) inherits(x, "ggplot")

#' @export
#' @rdname is_tests
is.mapping <- function(x) inherits(x, "uneval")

#' @export
#' @rdname is_tests
is.coord <- function(x) inherits(x, "Coord")

#' @export
#' @rdname is_tests
#' @usage is.Coord(x) # Deprecated
is.Coord <- function(x) {
deprecate_soft0("3.5.2", "is.Coord()", "is.coord()")
is.coord(x)
}

#' @export
#' @rdname is_tests
is.ggproto <- function(x) inherits(x, "ggproto")

#' @export
#' @rdname is_tests
is.facet <- function(x) inherits(x, "Facet")

#' @export
#' @rdname is_tests
#' @usage
#' # Layer related tests
#' is.layer(x)
teunbrand marked this conversation as resolved.
Show resolved Hide resolved
is.layer <- function(x) inherits(x, "Layer")

#' @export
#' @rdname is_tests
is.geom <- function(x) inherits(x, "Geom")

#' @export
#' @rdname is_tests
is.stat <- function(x) inherits(x, "Stat")

#' @export
#' @rdname is_tests
is.position <- function(x) inherits(x, "Position")

#' @export
#' @usage
#' # Scale and guide related tests
#' is.scale(x)
#' @rdname is_tests
is.scale <- function(x) inherits(x, "Scale")

#' @export
#' @rdname is_tests
is.guide <- function(x) inherits(x, "Guide")

#' @export
#' @rdname is_tests
is.guides <- function(x) inherits(x, "Guides")
thomasp85 marked this conversation as resolved.
Show resolved Hide resolved

#' @export
#' @usage
#' # Theme related tests
#' is.theme(x)
#' @rdname is_tests
is.theme <- function(x) inherits(x, "theme")

#' @export
#' @rdname is_tests
is.element <- function(x) inherits(x, "element")

#' @export
#' @rdname is_tests
is.margin <- function(x) inherits(x, "margin")

# Checks ------------------------------------------------------------------

# Extra checks in addition to the ones in import-standalone-types-check.R

Expand Down