epiforecasts / scoringutils

Utilities for Scoring and Assessing Predictions
https://epiforecasts.io/scoringutils/
Other
48 stars 21 forks source link

Remove function that resulted in an error when called from within print.data.table() #956

Closed nikosbosse closed 3 weeks ago

nikosbosse commented 3 weeks ago

Description

This PR mostly gives up on #935.

Previously, just calling example_nominal caused an error due to the subsetting that's happening within print.data.table.

This function just removes the function that's responsible for it and adds a test. The issue that manipulating columns of a dt causes random printing still persists, sadly. But at least on error anymore.

Checklist

sbfnk commented 3 weeks ago

Do we need to make such a drastic change? Can't we allow people to manipulate forecast objects as data.tables but then remove class membership, i.e. replace this warning https://github.com/epiforecasts/scoringutils/blob/bf566e40cb7702341914f35cf872d031c4050ebf/R/class-forecast.R#L341 with

      return(as.data.table(out))
nikosbosse commented 3 weeks ago

Can't we allow people to manipulate forecast objects as data.tables but then remove class membership

Great idea, will try this!

nikosbosse commented 3 weeks ago

Can't we allow people to manipulate forecast objects as data.tables but then remove class membership

One downside is that then randomly, at some point, your object will stop being a forecast object and you have no idea when and why that happened...

My impression is that this introduces additional errors (it also causes a whole new set of tests to fail)

nikosbosse commented 3 weeks ago

Hm. overall I don't have a better idea than removing the subsetting trigger for re-validation. At least assert_forecast() is still exported, so people can still re-validate their forecast objects

nikosbosse commented 3 weeks ago

@sbfnk let me know if you disagree? Otherwise I'm going to merge this soon-ish

nikosbosse commented 3 weeks ago

We could do something reaaally hacky and add a filter within [.forecast to only check the content if nrow > 10... or whatever the maximum is that a data.table would print out in any default setting. We'd get weird behaviour, but at least some checking as opposed to none

seabbs commented 3 weeks ago

Haha I think the print check might on number of rows could be a good partial solution. It's a mega hack as you say obviously.

nikosbosse commented 3 weeks ago

I implemented a cutoff of 30 now + added a sentence that issues might be due to print and that users should confirm the issue using assert_forecast