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

fix bug merging themes #4416

Merged
merged 4 commits into from
Oct 1, 2024
Merged

fix bug merging themes #4416

merged 4 commits into from
Oct 1, 2024

Conversation

haakon-e
Copy link
Contributor

@haakon-e haakon-e commented Sep 27, 2024

deepcopy correctly handles copying of non-toplevel attributes like Theme(Axis = (; titlesize=10)), otherwise leftmost argument to merge is modified.

Description

Fixes the following bug in which theme1 is being modified by merge:

julia> theme1 = Theme(Axis = (; titlesize = 10))
Attributes with 1 entry:
  Axis => Attributes with 1 entry:
    titlesize => 10

julia> theme2 = Theme(Axis = (; xgridvisible = false))
Attributes with 1 entry:
  Axis => Attributes with 1 entry:
    xgridvisible => false

julia> merge(theme1, theme2)
Attributes with 1 entry:
  Axis => Attributes with 2 entries:
    titlesize => 10
    xgridvisible => false

julia> theme1
Attributes with 1 entry:
  Axis => Attributes with 2 entries:
    titlesize => 10
    xgridvisible => false

Type of change

Delete options that do not apply:

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

Fix bug where input arg to `merge` is modified.
Change `copy` -> `deepcopy`, which correctly handles
copying of non-toplevel attributes like
`Theme(Axis = (; titlesize=10))`.

otherwise leftmost argument to `merge` is modified.
@ffreyer
Copy link
Collaborator

ffreyer commented Sep 30, 2024

Thanks, this is something I've been unhappy with too.

I think we'll need to review this rather carefully since it has the potential to subtly change which attributes get picked. I'm not sure if I trust CI to pick up on that, though maybe I'm underestimating it.

We may also want to consider this breaking since users might already use merge

@haakon-e
Copy link
Contributor Author

We may also want to consider this breaking since users might already use merge

That's fair. Though merge (without !) should promise to not modify input arguments, so I feel this is somewhat more clearly "bugfix" than "breaking feature".

In any case, I'd enjoy seeing this fixed as it was causing some reproducibility issues in my code, and in the end, this (+#4419) made it hard to combine Themes in a reasonable way.

@SimonDanisch
Copy link
Member

I don't expect many people to use merge and I also don't expect anyone to rely on this behavior.
So I'm happy to merge this for the next patch release.

Copy link
Collaborator

@ffreyer ffreyer left a comment

Choose a reason for hiding this comment

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

I looked through all the merge functions we call. As far as I can tell we always rely on merge!() for Attributes/Themes, or cast to Dict beforehand. So I think this shouldn't cause any issues

@SimonDanisch SimonDanisch merged commit 561dfdb into MakieOrg:master Oct 1, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

4 participants