epiforecasts / scoringutils

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

More robust message wording test #862

Closed MichaelChirico closed 3 months ago

MichaelChirico commented 3 months ago

Part of https://github.com/Rdatatable/data.table/issues/6284.

The message upstream has been improved (here):

'fun.aggregate' is NULL, but found duplicate row/column combinations, so defaulting to length(). That is, the variables [date, model, observed, interval_range, boundary] used in 'formula' do not uniquely identify rows in the input 'data'. In such cases, 'fun.aggregate' is used to derive a single representative value for each combination in the output data.table, for example by summing or averaging (fun.aggregate=sum or fun.aggregate=mean, respectively). Check the resulting table for values larger than 1 to see which combinations were not unique. See ?dcast.data.table for more details.

This will be released to CRAN soon. In general, it is a bit fragile to rely on the exact wording of another package's errors/warnings/messages. See here for how we try and be a bit more flexible in {data.table} when relying on {base} message text:

https://github.com/Rdatatable/data.table/blob/a01f00f7438daf4612280d6886e6929fa8c8f76e/inst/tests/tests.Rraw#L160-L202

Eventually, we'd like to offer you custom condition classes you can more reliably depend on instead:

https://github.com/Rdatatable/data.table/issues/5913

In fact we already do so for the particular message you're relying on: dt_missing_fun_aggregate_warning:

https://github.com/Rdatatable/data.table/blob/0030b15d1ebc9242e30159351388ef3cc114e344/R/fcast.R#L185

nikosbosse commented 3 months ago

@MichaelChirico thanks a lot for your recent contributions - much appreciate it. If you like, please add yourself as a contributor to the package DESCRIPTION.

MichaelChirico commented 3 months ago

If you like, please add yourself as a contributor to the package DESCRIPTION.

Don't feel I've contributed all that much, but thank you for the offer! And thanks for using data.table 👍

MichaelChirico commented 3 months ago

FYI data.table will release to CRAN in August, so expect to need a {scoringutils} update in the near future. Thanks again!