-
Notifications
You must be signed in to change notification settings - Fork 214
Error early if rows could not resolve to anything in data_color() #1660
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative PR! (would not be a breaking change, since this currently errors)
Maybe less suprising this way.. I think I prefer the alternative solution, what do you think?
This is a bit tricky API-wise. I like the erroring if you supply a specific row index, row name, or set of them. However, if providing an expression it would be nice to no-op, which is just like the behavior for columns. For rows, I don't know that we currently make the distinction between expression and explicit selection. Also, I don't know if this is the current behavior for other functions with a So, it's worth discussing this a little! I know what I proposed would be a breaking change but I hope it would be a welcome one that fixes some inconsistencies. |
Good idea! In this case, let's go with the alternative PR (that is the status quo with more informative error)? and I will open a new issue to do that in a folow-up PR. |
Disregard the above suggestion, as we're going with a different PR (feel free to close this one). |
Will you open a new PR? The "alternative" PR is this PR in its current state, after I accepted the suggestions #1660 (review). My suggestion would be to merge this which basically just changes # before
mtcars |>
gt() |>
data_color(rows = cyl == 5)
Error in `get_contrast_ratio()`:
! At least one color defined for each of
`color_1` and `color_2`.
# this PR
mtcars |>
gt() |>
data_color(rows = cyl == 5)
Error in `data_color()`:
! `rows` resulted in an empty selection. And address outstanding issue in a follow-up (issue #1665 )? Does that make sense? |
Co-authored-by: Richard Iannone <riannone@me.com>
Yes, it makes sense! (Sorry for the confusion here.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Summary
Consider this,
Currently, this errors with a cryptic error:
I have left a review with an alternative approach! Please let me know which one you think is better
Related GitHub Issues and PRs
Discovered while answering #1659
Checklist
testthat
unit tests totests/testthat
for any new functionality.