-
Notifications
You must be signed in to change notification settings - Fork 22
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
Issue #405: expose get_forecast_type()
to users
#466
Changes from all commits
16372f6
9aa85d3
59d6e9f
8e3eaee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,3 +109,39 @@ test_that("get_duplicate_forecasts() works as expected for point", { | |
22 | ||
) | ||
}) | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. random space |
||
# ============================================================================== | ||
# `get_forecast_type` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why don't these get functions just have there own test file? |
||
# ============================================================================== | ||
test_that("get_forecast_type() works as expected", { | ||
expect_equal(get_forecast_type(as.data.frame(example_quantile)), "quantile") | ||
expect_equal(get_forecast_type(example_continuous), "sample") | ||
expect_equal(get_forecast_type(example_integer), "sample") | ||
expect_equal(get_forecast_type(example_binary), "binary") | ||
expect_equal(get_forecast_type(example_point), "point") | ||
|
||
expect_error( | ||
get_forecast_type(data.frame(x = 1:10)), | ||
"Assertion on 'data' failed: Columns 'observed', 'predicted' not found in data.", | ||
fixed = TRUE | ||
) | ||
|
||
df <- data.frame(observed = 1:10, predicted = factor(1:10)) | ||
expect_error( | ||
get_forecast_type(df), | ||
"Checking `data`: input doesn't satisfy criteria for any forecast type. Are you missing a column `quantile` or `sample_id`? Please check the vignette for additional info.", | ||
fixed = TRUE | ||
) | ||
|
||
data <- validate(example_integer) | ||
attr(data, "forecast_type") <- "binary" | ||
expect_warning( | ||
get_forecast_type(data), | ||
"Object has an attribute `forecast_type`, but it looks different from what's expected based on the data. | ||
Existing: binary | ||
Expected: sample | ||
Running `validate()` again might solve the problem", | ||
fixed = TRUE | ||
) | ||
}) |
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.
Is this unrelated to this PR?
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.
Yes, but I noted this! 🥺 🐶 It's mentioned in the PR description and you asked me to fix these 🐩
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.
Why is it not its own PR?