Skip to content

BUG: Ensure |jd2|<=0.5 - #9577

Merged
taldcroft merged 6 commits into
astropy:masterfrom
aarchiba:enforce-jd2
Nov 11, 2019
Merged

taldcroft merged 6 commits into
astropy:masterfrom
aarchiba:enforce-jd2

Conversation

@aarchiba

@aarchiba aarchiba commented Nov 9, 2019 •

Copy link
Copy Markdown
Contributor

Description

Ensures format conversion leaves abs(jd2)<=0.5

EDIT: Fix #9533

@astropy-bot astropy-bot Bot added the time label Nov 9, 2019
@bsipocz bsipocz changed the title Fix #9533 BUG: Ensure |jd2|<=0.5 Nov 9, 2019
@bsipocz bsipocz added Affects-dev PRs and issues that do not impact an existing Astropy release Bug labels Nov 9, 2019
@bsipocz bsipocz added this to the v4.0 milestone Nov 9, 2019
@bsipocz
bsipocz requested a review from mhvk November 9, 2019 21:54
@bsipocz bsipocz added Affects-release and removed Affects-dev PRs and issues that do not impact an existing Astropy release labels Nov 9, 2019
@bsipocz

bsipocz commented Nov 9, 2019

Copy link
Copy Markdown
Member

test failures are related

@mhvk

mhvk commented Nov 10, 2019

Copy link
Copy Markdown
Contributor

This looks good, though I'm a bit puzzled at the error - maybe it is just a matter of increasing atol in this case... I think we also need a test case that checks that the PR does what it intends to (can just be the example you found in #9533)

cc @taldcroft - this PR ensures abs(jd2)<=0.5 always - this was not something we ever guaranteed though we definitely have been trying to make it true, at least on input, on addition/subtraction, etc. Here, it adds a bit of time to every scale change; on balance, I think this is worth it, but would be good to have your input as well.

@aarchiba

Copy link
Copy Markdown
Contributor Author

This looks good, though I'm a bit puzzled at the error - maybe it is just a matter of increasing atol in this case... I think we also need a test case that checks that the PR does what it intends to (can just be the example you found in #9533)

No, that's not it. You'll notice that the difference being raised is between -0.4999... and +0.5. The problem is that the code there (as in many other places) assumes that jd1 is an integer and jd2 the fractional part, and does the comparison on jd2 only. (jd1_a-jd1_b) + (jd2_a-jd2_b) would be fine - but I'm not sure that the rest of the test will still work, because it may well rely on assumptions about jd1 and jd2. I'll chase it down but it demonstrates the sort of way people build in assumptions about the possible values for jd1 and jd2 - so whether we actually made the guarantees or not, people - us! - have built them into code that uses astropy. So allowing scale conversion to subtly violate the conditions on jd2 is just asking for trouble. It is only efficiency concerns, and other assumptions about sharing of data, that keep me from wanting to make day_frac part of the jd1/jd2 validation applied to all time formats.

@aarchiba

Copy link
Copy Markdown
Contributor Author

Should this have a changelog entry?

@mhvk

mhvk commented Nov 11, 2019

Copy link
Copy Markdown
Contributor

I don't think a changelog entry is needed - I'm happy to move this direction but perhaps best to keep it an "implementation detail" for now.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, looks all good!

@mhvk

mhvk commented Nov 11, 2019

Copy link
Copy Markdown
Contributor

@taldcroft - are you OK with this?

@taldcroft taldcroft left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@taldcroft
taldcroft merged commit 9635f7a into astropy:master Nov 11, 2019
@aarchiba
aarchiba deleted the enforce-jd2 branch November 11, 2019 15:26
bsipocz pushed a commit that referenced this pull request Nov 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Time scale conversion violates |jd2|<=0.5

4 participants