Skip to content
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 #559: Ensure output of add_coverage() is an object of class forecast_quantile #586

Merged
merged 3 commits into from
Jan 8, 2024

Conversation

nikosbosse
Copy link
Contributor

@nikosbosse nikosbosse commented Jan 7, 2024

Description

This PR closes #559.

add_coverage() used to return a data.table(), even if it was called on an object of class forecast_quantile. This was due to internal computations: the function quantile_to_interval() returns a data.table and when merging the newly computed columns with the existing data, a data.table was produced.

In addition, transform_forecasts() had a similar issue. This was due to a call to as.data.table().

This PR

  • switches the order in which the two datasets are passed to merge(), solving the issue for add_coverage()
  • replaces as.data.table() with as_forecast() for transform_forecasts()
  • Adds a unit test for both
  • Adds an additional, mostly unrelated unit test to check that running as_forecast() twice produces the same object. I added this test because add_coverage() currently runs as_forecast() and I thought it was a good idea to have a test that running as_forecast() several times is fine.
  • removes unrelated data.table:: to make the code style more consistent

Additional thoughts:

Checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have included the target issue or issues in the PR title as follows: issue-number: PR title
  • I have tested my changes locally.
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required.
  • I have built the package locally and run rebuilt docs using roxygen2.
  • My code follows the established coding standards and I have run lintr::lint_package() to check for style issues introduced by my changes.
  • I have added a news item linked to this PR.
  • I have reviewed CI checks for this PR and addressed them as far as I am able.

@nikosbosse nikosbosse requested a review from seabbs January 7, 2024 12:50
Copy link

codecov bot commented Jan 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (61905cf) 85.15% compared to head (14de707) 85.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #586      +/-   ##
==========================================
- Coverage   85.15%   85.14%   -0.01%     
==========================================
  Files          21       21              
  Lines        1711     1710       -1     
==========================================
- Hits         1457     1456       -1     
  Misses        254      254              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@seabbs seabbs merged commit 2d82369 into main Jan 8, 2024
11 checks passed
@seabbs seabbs deleted the fix-add_coverage branch January 8, 2024 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

After passing a forecast object through the add_coverage function, it is re-transformed into a data.table.
2 participants