-
Notifications
You must be signed in to change notification settings - Fork 38
fix mod CI test #78
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
fix mod CI test #78
Conversation
Codecov Report
@@ Coverage Diff @@
## master #78 +/- ##
==========================================
- Coverage 95.74% 94.70% -1.05%
==========================================
Files 2 2
Lines 141 151 +10
==========================================
+ Hits 135 143 +8
- Misses 6 8 +2
Continue to review full report at Codecov.
|
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.
This function is discontinuous at integer values, so actually I don't understand why tests were passing in previous versions of Julia.
It's not discontinuous at integers in the tests here since we use a floating point number as second argument.
In Julia v1.7 the random stream changed and it could be that the issue was just by chance not erroring before, but now it is.
The RNG change is the actual reason, we are just unlucky and end up with random numbers where the very very primitive finite differencing algorithm fails. Maybe we should just use FiniteDifferences.jl instead.
Here is a plot of using GLMakie
xs = 0:0.001:10; lines(xs, mod.(xs, 2)) It is discontinuous in the first argument, with a discontinuity every It so happens that the random (float) value of the first argument used in the (previously failing) test is very near such a point, and the test fails. I thin relying on the ability of the finite difference algorithm near a singularity like this is not the right approach here. |
If I'm not mistaken the floating point value is the second argument of |
I assume the problem is that the second argument is too close to 0. A better FD algorithm would already help (and be helpful and more accurate in general) but probably also shifting values to >= 0.5 might help in this specific test. |
I have tried with For reference, the test that's failing is at using GLMakie
ys = 0.3:0.0001:0.5
lines(ys, mod.(2, ys)) |
Did you try this? This is a plot of Maybe I don't understand but I don't see why the shift would help here. Also, that's just the case of So in this case you would need a larger shift. |
It's the main point that it becomes less likely - it means that test failures are less likely. If necessary, we can also restrict the first argument to smaller values. But intuitively I would assume that it becomes sufficiently unlikely by changing the second argument. |
|
Seems much easier to pick values where you are certain there will be no discontinuities nearby, instead of wondering about probabilities and hoping the seed works out. Maybe |
Yes, I agree. I just pushed this change 😄 . Can you take a look at the current code? |
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.
I agree, it's probably even better to ensure that it can never cause these problems.
Actually I was using different values, which made the test trivial as @devmotion noticed. With the values suggested by @mcabbott , we guarantee while also guaranteeing that the test is not trivial. |
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.
Looks good to me, thanks @cossio!
CI is failing on Julia v1.7.
The failure is ocurring when testing the rule for
Base.mod
. This function is discontinuous at integer values, so actually I don't understand why tests were passing in previous versions of Julia. In Julia v1.7 the random stream changed and it could be that the issue was just by chance not erroring before, but now it is.So here I just test
mod
separately, on non-integer arguments.