-
Notifications
You must be signed in to change notification settings - Fork 27
Update R plotting metadata check #326
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
capnrefsmmat
left a comment
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.
Thanks; a couple suggested improvements
| "Metadata for signal mean and standard deviation not", | ||
| "available; defaulting to observed mean and standard", | ||
| "deviation to set plot range.") |
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.
Having a warning class means we don't have to match the message:
| "Metadata for signal mean and standard deviation not", | |
| "available; defaulting to observed mean and standard", | |
| "deviation to set plot range.") | |
| class = "covidcast_plot_meta_not_found") |
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.
So I tried this, but couldn't get it to work since this passes (as expected)
expect_warning(plot(fake_data), class="covidcast_plot_meta_not_found")
but this also passes
expect_warning(plot(fake_data), class="this_should_fail")
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.
wat
sigh:
> expect_warning(warn("ducks", class="duck_warning"), class="boing")
> expect_error(abort("ducks", class="duck_error"), class="boing")
Error: `abort("ducks", class = "duck_error")` threw an error with unexpected class.
Expected class: boing
Actual class: duck_error/rlang_error/error/condition
Message: ducks
So I guess the documentation is a lie for warnings. We might be able to fix this by opting in to testthat's third edition, since that unifies the handling for all three. Worth trying?
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.
Seems to work
> library(testthat)
> local_edition(3)
> expect_warning(warn("ducks", class="duck_warning"), class="boing")
Error: `warn("ducks", class = "duck_warning")` did not throw the expected warning.
In addition: Warning message:
ducks
Updated code to use 3rd ed
Co-authored-by: Alex Reinhart <alex@refsmmat.com>
Fixes #270
Summary of changes