[go: nahoru, domu]

Skip to content

Commit

Permalink
Getting gganimate to stop warning about partial argument match. (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonthegeek committed Mar 22, 2021
1 parent 1061d1a commit 0244fab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions R/tween_state.R
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@
#'
tween_state <- function(.data, to, ease, nframes, id = NULL, enter = NULL, exit = NULL) {
from <- .get_last_frame(.data)
from$.phase <- rep('raw', length = nrow(from))
to$.phase <- rep('raw', length = nrow(to))
to$.id <- rep(NA_integer_, length = nrow(to))
from$.phase <- rep('raw', length.out = nrow(from))
to$.phase <- rep('raw', length.out = nrow(to))
to$.id <- rep(NA_integer_, length.out = nrow(to))
id <- enquo(id)
if (.has_frames(.data)) nframes <- nframes + 1
if (!setequal(names(from), names(to))) {
Expand Down Expand Up @@ -173,7 +173,7 @@ tween_state <- function(.data, to, ease, nframes, id = NULL, enter = NULL, exit
#' @export
keep_state <- function(.data, nframes) {
state <- .get_last_frame(.data)
state$.phase <- rep('raw', length = nrow(state))
state$.phase <- rep('raw', length.out = nrow(state))
if (.has_frames(.data)) nframes <- nframes + 1
if (nrow(state) == 0) {
return(.with_prior_frames(.data, state, nframes))
Expand Down
5 changes: 4 additions & 1 deletion tests/testthat/test-state.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ test_that("tween_state works", {
})

test_that("keep_state works", {
keep <- keep_state(df1, 5)
expect_warning(
keep <- keep_state(df1, 5),
NA
)
expect_equal(max(keep$.frame), 5)
expect_true(all(keep$.phase[c(9:10)] == 'raw'))
expect_true(all(keep$.phase[c(1:8)] == 'static'))
Expand Down

0 comments on commit 0244fab

Please sign in to comment.