-
-
Notifications
You must be signed in to change notification settings - Fork 322
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
Improve and use shared_attributes
for attribute passthrough
#4399
base: master
Are you sure you want to change the base?
Conversation
Compile Times benchmarkNote, that these numbers may fluctuate on the CI servers, so take them with a grain of salt. All benchmark results are based on the mean time and negative percent mean faster than the base branch. Note, that GLMakie + WGLMakie run on an emulated GPU, so the runtime benchmark is much slower. Results are from running: using_time = @ctime using Backend
# Compile time
create_time = @ctime fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @ctime Makie.colorbuffer(display(fig))
# Runtime
create_time = @benchmark fig = scatter(1:4; color=1:4, colormap=:turbo, markersize=20, visible=true)
display_time = @benchmark Makie.colorbuffer(fig)
|
…g/Makie.jl into ff/attribute-passthrough
This is more dangerous than I first thought. There are many recipes that use I also noticed some issues with my |
Some things I'm (re)considering;
|
I'm marking this as breaking since it changes how attributes are passed along, i.e. it will make some attributes work that didn't work before. I hope that this is an improvement in most cases, but there will be some cases where an attribute is wrongfully included. I hope that I can catch most of these through CI, but I doubt it will be all of them. |
After some discussions with Simon we came to the conclusion that it's not a good idea to work on this or merge this before we work on the Plot update/Observable refactor #4360. Depending on how we do that refactor, the thing shared_attributes can do will change. E.g. if Notes from DiscussionCurrent Attribute priority is: (high to low)
In the future we could have To take care of renames, e.g. Replacements work the same as on master in this framework, i.e. you just pass them as a plot kwarg. To manage direct inheritance and renaming, we could add struct InheritedAttribute
name_in_parent::Symbol
end as an option for Attributes. This would effectively replace mesh.color = InheritedAttribute(:color)
# checks parent:
poly.color = InheritedAttribute(:patchcolor)
# checks parent:
scene.theme.patchcolor = some_color and if this chain does not complete we error. General Questions & Notes:
|
Description
We have
shared_attributes(parent, TargetType)
as a function that filters attributes fromparent
applicable toTargetType
but we are not using it. This pr aims to extend the function and use it consistently in recipes. That should help fix a lot of the issues about attributes not being passed along/having no effect in recipes.Some thoughts:
shared_attributes
to skip/drop a set of given attribute names means that some valid attributes will not get set. That sounds like something we should not encourage. Edit: It is quite useful in some cases, e.g. if you want to pass strokecolor to a poly but not a scatter or fxaa to a mesh but not lines.strokecolor => color
), soshared_attributes
should handle thatmap
(etc). Because of that I think it's preferable to haveattr[:name] = map(...)
instead of something likeobs = map(...); shared_attributes(..., :name => obs)
.inspector
ones. These should be automatically cleared.First Version
The usage of the first version looked something like this:
This has a couple of problems:
setindex!(::Attributes, val, name)
updates Observables if val is not an Observable. E.g.lines_attr[:fxaa] = false
would change the parent attributes fxaa value, which could also be used in another plot where it should remain true.attr[:name_in_target] = parent[:name_in_parent]
Second Version (c04f450 and after)
The second version solves the issues above:
shared_attributes
call so we can track defaulted attributes.shared_attributes
to not change values of the parent.new_name = parent[:old_name]
.Related Issues/prs
attributes_from
breaking #2206 (shared_attributes should be a preferable alternative)space
work for BarPlot #4435Type of change
Checklist