Skip to content

Fix set forecast unit#437

Merged
nikosbosse merged 6 commits intoadd-coverage-deviationfrom
fix-set_forecast_unit
Nov 15, 2023
Merged

Fix set forecast unit#437
nikosbosse merged 6 commits intoadd-coverage-deviationfrom
fix-set_forecast_unit

Conversation

@nikosbosse
Copy link
Copy Markdown
Collaborator

Fixes #427 where set_forecast_unit() would error if the input is not a data.table.
Also the PR

  • introduces a new helper function ensure_data.table() that makes sure that the input is a data.table
  • re-introudces run_safely() in metrics_quantile as that led to an error that I previously didn't catch.

@nikosbosse nikosbosse changed the base branch from main to create-apply-metrics November 14, 2023 21:55
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 14, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

❗ No coverage uploaded for pull request base (create-apply-metrics@6c213fc). Click here to learn what that means.

❗ Current head b204b36 differs from pull request most recent head ba9adbf. Consider uploading reports for the commit ba9adbf to get more accurate results

Additional details and impacted files
@@                   Coverage Diff                   @@
##             create-apply-metrics     #437   +/-   ##
=======================================================
  Coverage                        ?   80.11%           
=======================================================
  Files                           ?       20           
  Lines                           ?     1705           
  Branches                        ?        0           
=======================================================
  Hits                            ?     1366           
  Misses                          ?      339           
  Partials                        ?        0           

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

Copy link
Copy Markdown
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.

Why isn't this fix targeted at main as it have nothing to do with the current refactor?

Why is there random stuff for run_safely in here?

missing[[x]] <- x
}
}
missing <- unlist(missing)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This appears to be another random change not mentioned in the PR notes?

Copy link
Copy Markdown
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.

This is all fine but this should be targetted at main. Are you sure as.data.table doesn't do what you need? https://github.com/epinowcast/epinowcast/blob/d4a65aad2735be7ffa08ca605f979346f62e4212/R/check.R#L165

#' @keywords internal
#' @importFrom data.table copy is.data.table as.data.table
ensure_data.table <- function(data) {
if (!is.data.table(data)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

linting issues from CI to fix.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this function reproduces the pattern you have in several places in your code so you should go back and use it if you really need it (vs just using as.data.table which I believe always makes a copy?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I think I use it everywhere. Reason to use this over as.data.table() is that it preserves other classes. But maybe that's not necessary everywhere.

Base automatically changed from create-apply-metrics to add-coverage-deviation November 15, 2023 17:07
@nikosbosse nikosbosse merged commit ad411da into add-coverage-deviation Nov 15, 2023
@nikosbosse nikosbosse deleted the fix-set_forecast_unit branch November 15, 2023 21:16
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.

error in set_forecast_unit

2 participants