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

Update to update_*_defaults() #5781

Merged
merged 6 commits into from
Apr 2, 2024
Merged

Conversation

teunbrand
Copy link
Collaborator

@teunbrand teunbrand commented Mar 18, 2024

This PR aims to fix #4993 and supersedes #5098.

Briefly:

  1. There is a reset mechanism by setting new = NULL.
  2. The update functions return the previous defaults, as is customary.

In contrast to #5098:

  1. There is now 1 mechanism, instead of two separate ones.
  2. Cache uses snake_case of class as index, which prevents having to use two caches and should be somewhat easier to maintain.

@teunbrand teunbrand added this to the ggplot2 3.5.1 milestone Mar 18, 2024
@teunbrand
Copy link
Collaborator Author

teunbrand commented Mar 28, 2024

TODO: look into feasibility of the suggestion here: #4993 (comment)
EDIT: Postponing this for now

Copy link
Member

@thomasp85 thomasp85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apart from comment lgtm

Comment on lines 65 to 67
if (!index %in% ls(cache_defaults)) {
cache_defaults[[index]] <- old
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe overengineering it, but this is a rather unperformant way to check for existence in an environment as it ignores the whole hash structure. exists() are there to check for bindings in an environment

@teunbrand teunbrand merged commit 60407ac into tidyverse:main Apr 2, 2024
12 checks passed
@teunbrand teunbrand deleted the update_defaults2 branch April 2, 2024 08:15
teunbrand added a commit to teunbrand/ggplot2 that referenced this pull request Apr 12, 2024
teunbrand added a commit to teunbrand/ggplot2 that referenced this pull request Apr 12, 2024
teunbrand added a commit to teunbrand/ggplot2 that referenced this pull request Apr 15, 2024
teunbrand added a commit that referenced this pull request Apr 18, 2024
* Revert "Update to `update_*_defaults()` (#5781)"

This reverts commit 60407ac.

* remove news entry
teunbrand added a commit to teunbrand/ggplot2 that referenced this pull request Apr 18, 2024
* unify updating mechanism

* add tests

* redocument

* add news bullet

* add review suggestion
teunbrand added a commit that referenced this pull request Apr 29, 2024
* Update to `update_*_defaults()` (#5781)

* unify updating mechanism

* add tests

* redocument

* add news bullet

* add review suggestion

* move news bullet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reset original defaults with update_geom_defaults()
2 participants