Repository navigation
Ensure that always abs(time.jd2)<=0.5. - #8763
Conversation
bd27213 to
3f4921c
Compare
Codecov Report
@@ Coverage Diff @@
## master #8763 +/- ##
==========================================
+ Coverage 86.96% 86.96% +<.01%
==========================================
Files 400 400
Lines 59448 59454 +6
Branches 1100 1100
==========================================
+ Hits 51697 51703 +6
Misses 7110 7110
Partials 641 641
Continue to review full report at Codecov.
|
taldcroft
left a comment
There was a problem hiding this comment.
Looks good. Just a question about whether the testing is complete and a request to update the docstring.
| """Make jd2 approach +/-0.5, and check that it doesn't go over.""" | ||
| t1 = Time(2400000.5, [-2**-52, +2**-52], format='jd') | ||
| assert np.all(abs(t1.jd2) < 0.5) | ||
| t2 = Time(2400000., [0.5-2**-52, 0.5+2**-52], format='jd') |
There was a problem hiding this comment.
Does this also need a check for the -0.5 case [-0.5-2**-52, -0.5+2**-52]? I'm not sure if this ends up being a different case or not.
There was a problem hiding this comment.
I think it is the same, but, hey, doesn't cost anything to add it, so consider it done!
| day = np.round(sum12) | ||
| extra, frac = two_sum(sum12, -day) | ||
| frac += extra + err12 | ||
| # Our fraction can now have gotten >0.5 or <-0.5, which means we would |
There was a problem hiding this comment.
It would be nice to include something in the docstring for day_frac that specifies the range -0.5 <= frac <= 0.5 instead of just saying "fractional remainder".
There was a problem hiding this comment.
I adjusted the docstring (well, more like a rewrite...)
We used to sometimes have jd1 end in 0.5, but this was fixed quite a while ago. Now jd1 is guaranteed to be integer.
|
While looking at the tests, I realized one was from an older time where some initializations did not go through |
|
Tests passed so merging. |
Ensure that always abs(time.jd2)<=0.5.
Not sure this is strictly a bug, since we do not guarantee a particular implementation of jd1 and jd2, but this is more consistent and will make the precision very slightly better.
Found while implementing a double-precision
Phaseclass where I did want to ensure that the fractional phase in cycles was strictly in the range-0.5<=fraction<=0.5(mhvk/baseband-tasks#77)