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

Support incomplete list for sorter and renamer #384

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

haberdashPI
Copy link
Contributor

This addresses the proposal in #329 to make it possible to handle palettes a little more cleanly:

Specifically the missing piece this adds is to handle the case where sorter and renamer are provided only a partial enumeration of values.

Then, to quote @piever, the old:

# `a` and `b` entries get specified colors, for the other entries it's data-dependent
palette = (color=["a" => "red", "b" => "blue", "green", "black"],)

can now be achieved with

mapping(color=v => sorter(["a", "b"])
palette = (color=["red", "blue", "green", "black"],)

@piever
Copy link
Collaborator

piever commented Apr 28, 2022

About the implementation, instead of overloading map, I was thinking that one could try the following. renamer and sorter, rather than returning a Sorted object, would return a

struct Renamed{S, T}
    original::S
    value::T # maybe `Union{T, Nothing}` is cleaner, otherwise just a random one if the correct one is not found
    idx::UInt32 # use `0` if `original` is not found in `uniquevalues`
end

object. Then, this gets all simplified to something reasonable using rescale at the very end.

@haberdashPI
Copy link
Contributor Author

Ah yes, I see, that is probably a better way to do it!

Above is just an initial commit/sketch. It's untested, and I haven't added any new tests yet.

@haberdashPI haberdashPI marked this pull request as draft May 7, 2022 15:07
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.

2 participants