-
Notifications
You must be signed in to change notification settings - Fork 14
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
WIP: Implement encode_native() without going through the character vector #35
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This includes passing the colours as a data frame, with three (or four) columns. This approach avoids coercing all channels to a single matrix, (avoiding memory allocations and copying data around). Tests that cover encoding from any colour space directly to native have also been added. The handling of encoding input (matrix/list of colours and alpha vector) has been refactored into functions, as well as the parsing of the alpha colour (with its NA handling).
Useful for merging alpha information into a native colour
zeehio
added a commit
to zeehio/scales
that referenced
this pull request
Sep 12, 2022
Since there is only one context per file and it matches the file name, no confusion may arise
Closing this to make easier-to-review pull requests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Thanks for your farver package. It's nice to have efficient color conversion in R.
I am opening this pull request that improves the performance of
encode_native()
by avoiding creating an intermediate character vector with the colours.Here I compare the performance on a 10 million length vector (e.g. from a 10k x 1000 matrix):
Created on 2022-09-12 by the reprex package (v2.0.1)
The advantage on such a large vector is of a factor of 10. On a 1k long vector, my implementation is 5x faster.
I just discovered
nativeRaster
objects and I find them super useful for plotting large matrices (in a way similar to what image, filled.contour or annot_raster do). I find those functions slower than what they actually need to be, and I am trying to make a ggplot extension able to provide a nice API and an efficient implementation.This is my first step towards that goal.
I would appreciate a lot your feedback on this contribution.