Issue #559: Ensure output of add_coverage()
is an object of class forecast_quantile
#586
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.
Description
This PR closes #559.
add_coverage()
used to return adata.table()
, even if it was called on an object of classforecast_quantile
. This was due to internal computations: the functionquantile_to_interval()
returns adata.table
and when merging the newly computed columns with the existing data, adata.table
was produced.In addition,
transform_forecasts()
had a similar issue. This was due to a call toas.data.table()
.This PR
merge()
, solving the issue foradd_coverage()
as.data.table()
withas_forecast()
fortransform_forecasts()
as_forecast()
twice produces the same object. I added this test becauseadd_coverage()
currently runsas_forecast()
and I thought it was a good idea to have a test that runningas_forecast()
several times is fine.data.table::
to make the code style more consistentAdditional thoughts:
as.data.table()
in the code. All of these would make an object lose its classes. I opened Check all calls to `as.data.table() to make sure they are not dropping classes we want to keep #587 for this.Checklist
lintr::lint_package()
to check for style issues introduced by my changes.I have added a news item linked to this PR.