Skip to content

Commit

Permalink
fix vignettes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjschne committed Aug 24, 2024
1 parent e1a44b1 commit e8864ce
Show file tree
Hide file tree
Showing 181 changed files with 214 additions and 21,082 deletions.
2 changes: 0 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
export("%-|%")
export("%>%")
export("%|-%")
export("+")
export(arc)
export(as.geom)
export(bind)
Expand Down Expand Up @@ -42,7 +41,6 @@ export(rotate)
export(round_probability)
export(segment)
export(set_props)
export(str)
export(style)
export(turn)
if (getRversion() < "4.3.0") importFrom("S7", "@")
Expand Down
19 changes: 5 additions & 14 deletions R/a_early.R
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,8 @@ method(bind, class_list) <- function(x) {
#' structure
#'
#' @param object object
#' @export
#' @keywords internal
str <- new_generic(name = "str", dispatch_args = "object")

#' Addition
#'
#' @param e1 object
#' @param e2 object
#' @keywords internal
#' @export
`+` <- new_generic("+", c("e1", "e2"))
str <- new_external_generic(package = "utils", name = "str", dispatch_args = "object")

method(`+`, list(class_ggplot, has_style)) <- function(e1, e2) {
e1 + as.geom(e2)
Expand Down Expand Up @@ -571,15 +562,15 @@ check_inconsistent <- function(object) {
max_n <- max(prop_n)
prop_inconsistent <- prop_n[!(prop_n %in% unique(c(0, 1, max_n)))]
if (length(prop_inconsistent) > 0) {
msg <- tibble::enframe(prop_n[!(prop_n %in% unique(c(0, 1)))]) %>%
msg <- tibble::enframe(prop_n[!(prop_n %in% unique(c(0, 1)))]) |>
dplyr::summarize(.by = value,
name = paste0(name, collapse = ", ")) %>%
name = paste0(name, collapse = ", ")) |>
dplyr::mutate(v = paste0(
"Size ",
value,
": Properties: ",
name)) %>%
dplyr::pull(v) %>%
name)) |>
dplyr::pull(v) |>
paste0(collapse = "\n")
object_class <- .simpleCap(S7_class(object)@name)

Expand Down
10 changes: 5 additions & 5 deletions R/arcs.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ arc_props <- list(
pr <- purrr::map(arc_styles,
prop,
object = self
) %>%
) |>
`names<-`(arc_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down Expand Up @@ -459,8 +459,8 @@ method(as.geom, arc) <- function(x, ...) {
d <- dplyr::rename(d, length = arrowhead_length)
}

d <- d %>%
dplyr::mutate(group = factor(dplyr::row_number())) %>%
d <- d |>
dplyr::mutate(group = factor(dplyr::row_number())) |>
dplyr::mutate(xy = purrr::pmap(list(x0, y0, r, start, end, n),
\(X0, Y0, R, START, END, N) {
THETA <- seq(c(START), c(END), length.out = N)
Expand All @@ -478,8 +478,8 @@ method(as.geom, arc) <- function(x, ...) {

}
dd
})) %>%
tidyr::unnest(xy) %>%
})) |>
tidyr::unnest(xy) |>
dplyr::select(-c(x0, y0, r, start, end, n))

overrides <- get_non_empty_props(style(...))
Expand Down
2 changes: 1 addition & 1 deletion R/arrows.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ar_props <- list(
),
style = new_property(
getter = function(self) {
pr <- purrr::map(sg_styles, prop, object = self) %>%
pr <- purrr::map(sg_styles, prop, object = self) |>
`names<-`(sg_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/bzcurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bz_props <- list(
pr <- purrr::map(bz_styles,
prop,
object = self
) %>%
) |>
`names<-`(bz_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/circles.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cr_props <- list(
style = new_property(
getter = function(self) {
pr <- purrr::map(cr_styles,
prop, object = self) %>%
prop, object = self) |>
`names<-`(cr_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/ellipses.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ el_props <- list(
style = new_property(
getter = function(self) {
pr <- purrr::map(el_styles,
prop, object = self) %>%
prop, object = self) |>
`names<-`(el_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/labels.R
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ method(`[`, label) <- function(x, y) {
}

centerpoint_label <- function(label, center, d, shape_name = "shape", ...) {
if (is.character(label) || S7_inherits(label, class_angle)) {
if (is.character(label) || S7_inherits(label, class_angle) || is.numeric(label)) {
label <- label(label = label, p = center, ...)
}

Expand Down
14 changes: 7 additions & 7 deletions R/lines.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ line <- new_class(
d_names <- colnames(d)

if (all(c("a", "b", "c") %in% d_names)) {
check_ab0 <- d %>%
dplyr::mutate(ab0 = (a == 0) & (b == 0) & (c != 0)) %>%
dplyr::pull(ab0) %>%
check_ab0 <- d |>
dplyr::mutate(ab0 = (a == 0) & (b == 0) & (c != 0)) |>
dplyr::pull(ab0) |>
any()
if (check_ab0) stop("If a and b are 0, c must be 0.")

Expand Down Expand Up @@ -253,7 +253,7 @@ str_properties(object,
}

method(get_tibble, line) <- function(x) {
x@tibble %>%
x@tibble |>
dplyr::mutate(geom = ifelse(is.infinite(slope), "v", "ab"))
}

Expand Down Expand Up @@ -296,12 +296,12 @@ method(get_tibble_defaults, line) <- function(x) {

method(as.geom, line) <- function(x, ...) {
overrides <- get_non_empty_props(style(...))
get_tibble_defaults(x) %>%
tidyr::nest(.by = geom, .key = "d") %>%
get_tibble_defaults(x) |>
tidyr::nest(.by = geom, .key = "d") |>
dplyr::mutate(a = ifelse(geom == "ab", c(abline_aesthetics_list), c(vline_aesthetics_list)),
output = purrr::map2(d,a,
make_geom_helper,
user_overrides = overrides)) %>%
user_overrides = overrides)) |>
dplyr::pull(output)
}

Expand Down
2 changes: 1 addition & 1 deletion R/paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ path_props <- list(
pr <- purrr::map(path_styles,
prop,
object = self
) %>%
) |>
`names<-`(path_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/points.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pt_props <- list(
style = new_property(
getter = function(self) {
pr <- purrr::map(pt_styles,
prop, object = self) %>%
prop, object = self) |>
`names<-`(pt_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/polygons.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ pgon_props <- list(
pr <- purrr::map(pgon_styles,
prop,
object = self
) %>%
) |>
`names<-`(pgon_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/rectangles.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ rc_props <- list(
style = new_property(
getter = function(self) {
pr <- purrr::map(rc_styles,
prop, object = self) %>%
prop, object = self) |>
`names<-`(rc_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
2 changes: 1 addition & 1 deletion R/segments.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ sg_props <- list(
),
style = new_property(
getter = function(self) {
pr <- purrr::map(sg_styles, prop, object = self) %>%
pr <- purrr::map(sg_styles, prop, object = self) |>
`names<-`(sg_styles)
rlang::inject(style(!!!get_non_empty_list(pr)))
},
Expand Down
17 changes: 0 additions & 17 deletions man/plus.Rd

This file was deleted.

6 changes: 5 additions & 1 deletion man/str.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 4 additions & 15 deletions tests/testthat/test-addition.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_that("equality", {
tidyr::crossing(tibble::tibble(
.f = list(degree, radian, turn),
ratio = c(360, 2 * pi, 1)),
.g = list(`>`, `<`, `<=`, `>=`, `==`, `!=`)) %>%
.g = list(`>`, `<`, `<=`, `>=`, `==`, `!=`)) |>
dplyr::mutate(t1 = .2,
t2 = .3,
a1 = purrr::map2(.f, t1, \(f,t) f(t)),
Expand All @@ -29,9 +29,9 @@ test_that("equality", {
ta = purrr::pmap_lgl(list(.g, a1,a2), \(g, aa1, aa2) g(aa1,aa2)),
tn = purrr::pmap_lgl(list(.g, n1,n2), \(g, aa1, aa2) g(aa1,aa2)),
test = ta == tn
) %>%
dplyr::pull(test) %>%
all() %>%
) |>
dplyr::pull(test) |>
all() |>
expect_true()
})

Expand Down Expand Up @@ -293,14 +293,3 @@ test_that("inside", {

})




test_that("string concatenation", {
expect_equal("a" + "b", "ab")
expect_equal(2 + "b", "2b")
expect_equal("a" + 2, "a2")
expect_equal(2 + 2, 4)
})


44 changes: 35 additions & 9 deletions vignettes/angles.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ arc_labels <- as.character(end_angles - start_angles)
mycolors <- c("firebrick4", "royalblue3", "orchid4")
arc_labels[3] <- arc_labels[1] +
" + " + arc_labels[2] +
" = " + arc_labels[3]
arc_labels[3] <- paste0(arc_labels[1],
" + ",
arc_labels[2],
" = ",
arc_labels[3])
arcs <- arc(radius = r,
start = start_angles,
Expand Down Expand Up @@ -354,23 +356,35 @@ ggplot() +
segment(
polar(theta = 0, r = cos(theta)),
p,
label = "sin(" + theta + ") = " + round(sin(theta), 2),
label = paste0("sin(",
theta,
") = ",
round(sin(theta), 2)),
color = my_colors[1],
linewidth = .5
) +
# cos(theta)
segment(
point(0, sin(theta)),
point(cos(theta), sin(theta)),
label = label("cos(" + theta + ") = " + round(cos(theta), 2), vjust = 1),
label = label(
paste0(
"cos(",
theta,
") = ",
round(cos(theta), 2)), vjust = 1),
color = my_colors[2],
linewidth = .5
) +
# tan(theta)
segment(
p,
p + polar(theta - 90, r = tan(theta)),
label = "tan(" + theta + ") = " + round(tan(theta), 2),
label = paste0(
"tan(",
theta,
") = ",
round(tan(theta), 2)),
color = my_colors[3],
linewidth = .5
) +
Expand All @@ -379,7 +393,11 @@ ggplot() +
o,
point(1 / cos(theta)),
label = label(
label = "sec(" + theta + ") = " + round(1 / cos(theta), 2),
label = paste0(
"sec(",
theta,
") = ",
round(1 / cos(theta), 2)),
vjust = 1
),
color = my_colors[5]
Expand All @@ -388,15 +406,23 @@ ggplot() +
segment(
p + polar(theta + 90, r = 1 / tan(theta)),
p,
label = "cot(" + theta + ") = " + round(1 / tan(theta), 2),
label = paste0(
"cot(",
theta,
") = ",
round(1 / tan(theta), 2)),
color = my_colors[4],
linewidth = .5
) +
# csc(theta)
segment(
o,
point(0, 1 / sin(theta)),
label = "csc(" + theta + ") = " + round(1 / sin(theta), 2),
label = paste0(
"csc(",
theta,
") = ",
round(1 / sin(theta), 2)),
color = my_colors[6]
)
Expand Down
5 changes: 0 additions & 5 deletions vignettes/angles_cache/html/__packages

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed vignettes/angles_files/figure-html/fig-3060-1.png
Binary file not shown.
Loading

0 comments on commit e8864ce

Please sign in to comment.