Repository navigation
escape tests if NaN-NA behaviour does not match - #3364
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3364 +/- ##
=========================================
Coverage ? 94.62%
=========================================
Files ? 65
Lines ? 13366
Branches ? 0
=========================================
Hits ? 12648
Misses ? 718
Partials ? 0Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #3364 +/- ##
=========================================
Coverage ? 94.74%
=========================================
Files ? 65
Lines ? 12149
Branches ? 0
=========================================
Hits ? 11510
Misses ? 639
Partials ? 0Continue to review full report at Codecov.
|
| x = c(NA, NaN) | ||
| y = c(NaN, NA) | ||
| `&&`( | ||
| identical(mean(x), frollmean(x, 2L, algo="exact")[2L]), |
There was a problem hiding this comment.
Better to test the x and y independently against fixed known results (NA or NaN in this case). Then I for example as reader of the test can more easily see what is happening here. For example, I'm currently wondering if base R changes result depending on whether R itself has been compiled with -O0 or not, or whether it's just frollmean that changes result depending on whether data.table has been compiled with -O0 or not.
Also the emphasis that this behavior depends on -O0 seems odd. Equally, couldn't it happen on other platforms? Solaris and Power spring to mind.
How about changing the tests to test if either NA or NaN are returned? The PR currently turns off the tests, so in the event that Inf was returned (a definite error), the test wouldn't catch that because it had been turned off. Better to always test that one of the accepted values is always returned. is.na(NA) and is.na(NaN) both return TRUE, so is.na() could be used by the test. This way, the compiler_o_flag_match function can be removed and that's simpler.
There was a problem hiding this comment.
Equally, couldn't it happen on other platforms? Solaris and Power spring to mind.
NaN - NA interaction is not undefined by any standards, thus is platform specific, and what we can observe here, also -O flag specific.
How about changing the tests to test if either NA or NaN are returned?
Those particular tests are there to test algo="exact" which has to be identical to base R result. froll manual states:
When set to
"exact"... carefully handles all non-finite values.
and
It also handles NaN, +Inf, -Inf consistently to base R.
There are other tests for algo="fast" where NaN as treated as NA.
Agree on that it is better to ignore NaN-NA difference than just disabling those tests. I will amend.
BTW. slightly related #2960
Better to always test that one of the accepted values is always returned.
Best not to "always" but when that issue issue occurs, as explained above, we want to test as much exactness as possible.
|
Changes amended, R mean is compared vs constant values, same frollmean is compared against constant values. Based on that comparison we either replace NaN to NA or leave as is. |
|
As Martin wrote in #17441 : Given this, why not make frollmean return a consistent result which does not depend on the platform? In other areas of data.table we have departed from base R where it makes sense to. I don't see why you are trying to match identically the platform-specific behavior. Or, relax these tests to accept NA or NaN when mixed NA and NaN inputs are present. I don't think anyone needs to distinguish NA from NaN in the output of frollmean when mixed NA, NaN are present in the input. Especially when R doesn't guarantee a particular result in this case anyway. Put another way ... There are only two tests that are actually failing on CRAN Solaris: 9999.123 & 9999.162. These fail because mixed NA and NaN are in the input for these, iiuc. this way, test() will consider them equal because This would be a 2 line change (plus comment to each) rather than the +29-14 change of the PR currently. |
It will cost performance. We outsource that part to code generated by compiler, same as R.
Failed froll tests are not failing CRAN status in 1.12.0. There was no
Yes, those two are failing now, but on other platforms we could get failures on others amended. Using |
Here's the line that does: 38c947e#diff-83559ac036a3b9d070fc219734cf6d39L447
But the root cause is that $1.6 of R-exts contains this bullet point at the end :
We are not supposed to use identical(), see what breaks on CRAN and then change it according to platform differences. That's a lot of work for us and impacts CRAN maintainers too. We're supposed to use Thanks for relaxing these tests. Much simpler and clearer now. Will merge. Let's come back to the other tests that use identical(). |
I explicitly put that outside of function definition to use that switch as constant defined based on base R compilation flag and data.table compilation flag, and/or platform.
I explained in #3371
As mentioned above. edit: I misunderstood. Yes, seeing what breaks on CRAN and fixes that would be pain for us and maintainers. |
Closes #3353.