Skip to content

Fix version comparison #5376

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

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# ggplot2 3.4.3

This hotfix release addresses a version comparison change in r-devel. There are
no user-facing or breaking changes.

# ggplot2 3.4.2
This is a hotfix release anticipating changes in r-devel, but folds in upkeep
changes and a few bug fixes as well.
Expand Down
4 changes: 2 additions & 2 deletions R/backports.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Backport fix from R 3.3:
# https://github.com/wch/r-source/commit/4efc81c98d262f93de9e7911aaa910f5c63cd00f
if (getRversion() < 3.3) {
if (getRversion() < "3.3") {
absolute.units <- getFromNamespace("absolute.units", "grid")
absolute.units.unit <- getFromNamespace("absolute.units.unit", "grid")
absolute.units.unit.list <- getFromNamespace("absolute.units.unit.list", "grid")
Expand All @@ -18,6 +18,6 @@ if (getRversion() < 3.3) {
on_load(backport_unit_methods())

# isFALSE() is available on R (>=3.5)
if (getRversion() < 3.5) {
if (getRversion() < "3.5") {
isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
}
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)
}
)
}