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

Resolve R devel visual tests #5358

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions tests/testthat/helper-density.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

# In R devel from 4.3.0 onwards, the density calculation has slightly changed,
# which affects visual snapshots that use a density calculation, like
# `geom_violin()` and `geom_density()`.
# See https://developer.r-project.org/blosxom.cgi/R-devel/NEWS/2023/05/03#n2023-05-03
#
# It has a backwards compatibility argument called 'old.coords' that can be used
# to perform the classic density calculation, which means we can stably use
# visual tests in R devel.
#
# Since that argument is not available in older versions, we have to use the
# following workaround. Here, we conditionally override the default
# density method to use `old.coords = TRUE`.
if ("old.coords" %in% names(formals(stats::density.default))) {
registerS3method(
"density", "default",
function(..., old.coords = TRUE) {
stats::density.default(..., old.coords = old.coords)
}
)
}
Loading