Add palette capabilities: may_return_NA, accepts_native_output #372
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.
This pull request (on top of #371) extends the definition of a palette by adding attributes to the palette function.
These attributes may be ignored if you don't care for them, but they can be used by the palette consumer (e.g. ggplot2) to be faster.
We define two new attributes on
colour_ramp
,gradient_n_pal
,div_gradient_pal
andseq_gradient_pal
.may_return_NA
: If this attribute is set toFALSE
, the palette consumer can safely assume that the palette won't return missing values (therefore skipping any check).accepts_native_output
: if this attribute is set toTRUE
, the palette consumer can safely assume that the palette accepts an additional keyword argument namedcolor_fmt
which can take two values:"character"
and"native"
. The palette consumer can call the palette withcolor_fmt = "native"
to get colours in native format (as used in nativeRaster objects). The palette consumer can avoid the intermediate character representation of colours.This is related to:
Proposed NEWS entry: