-
Notifications
You must be signed in to change notification settings - Fork 21
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
Make boolean vector explicitly numeric when computing interval scores #274
Conversation
Codecov Report
@@ Coverage Diff @@
## master #274 +/- ##
==========================================
+ Coverage 90.80% 90.82% +0.01%
==========================================
Files 21 21
Lines 1284 1286 +2
==========================================
+ Hits 1166 1168 +2
Misses 118 118
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Will circle back but just to reiterate my point from the original issue - I think having some input checking is very in scope for here. Also did you have any luck determining how local this was? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code wise this looks fine.
Do we want any code changes for inputting checking (i.e higher up in the code somewhere) or changes to documentation?
This change also needs to be flagged in the news and the dev version needs to be incrmented.
The original "issue" is with something in I'm also not sure how to do more input testing for the specific case: I could check for whether the input is numeric, but the epinowcast example would pass that test, yet the code as is would still fail. Agree that more input testing is always good and I can add more tests, but that wouldn't have prevented this specific error. |
That is only the case if it doesn't replicate to other use cases right? We aren't doing anything particularly strange here so I see no reason why it wouldn't. As I said there is no input checking here so at the moment if this happens again it either 1. just works. or 2. fails in a strangely cryptic way. Ideally, it would either 1. just work or 2. fail meaningfully hence the need for input checking? Is this in fact a bug with
Even if this passes in this case it still seems like something we should have for such a key input. Wait in the code are you doing number * logical? Is that a good pattern? |
ah so you code is as..numeric(summarised_nowcast$q95 > value) so not quite written as in your example and not a bad pattern I would say |
The original code was |
Ah okay. Yes then I think Can you replicate this with a simple |
Just looked into this - simply checking for is.numeric doesn't even work, because sometimes inputs can be NA.
Maybe checkmate is the way to go |
reprex would be
Do you think this is a bug or desired behaviour on their end? |
Have no idea. I would have thought they want to it behave in the same way as |
created an issue. r-lib/pillar#630. We are good bings. |
In terms of input checking |
I also thought about writing a custom check function, but this seems like reinventing the wheel a bit. Also there are all kinds of complicated things that happen when you test for NA values as a vector of NA values is deemed to be a logical in R. Here is what I came up with as a first quick draft (could be improved a lot), but again not sure how deep we want to go
|
Maybe we should merge this for now and create another issue for improving input checks |
Agree. I often write my own checks as all the tools aren't ideal but as you say its a lot of work. |
Addresses #273
Ultimately the issue seems to be outside scoringutils, however adding
as.numeric
to the code doesn't add much complexity and just makes explicit what is happening implicitly anyway.Discussion here: epinowcast/epinowcast#198