Skip to content

dms declinations with -00 not treated correctly - #875

Merged
embray merged 2 commits into
astropy:masterfrom
astrofrog:fix-issue-875
Apr 3, 2013
Merged

embray merged 2 commits into
astropy:masterfrom
astrofrog:fix-issue-875

Conversation

@astrofrog

Copy link
Copy Markdown
Member

When parsing declinations from dms strings, astropy.coordinates doesn't deal with "-00" correctly. For example:

In [56]: print coord.Dec('00 30 00.0', unit=units.degree)
0d30m00.00000s

In [57]: print coord.Dec('01 30 00.0', unit=units.degree)
1d30m00.00000s

In [58]: print coord.Dec('-00 30 00.0', unit=units.degree)
0d30m00.00000s

In [59]: print coord.Dec('-01 30 00.0', unit=units.degree)
-1d30m00.00000s

The third output should be '-0d30m00.00000s', with a minus sign. The underlying problem is that the degrees string is converted to an integer before checking for a minus sign, so '00' and '-00' become the same thing.

@astrofrog

Copy link
Copy Markdown
Member

This is a pretty bad bug, and should be fixed for 0.2.1 IMHO. I'll take a quick look now.

@embray

embray commented Apr 2, 2013

Copy link
Copy Markdown
Member

Hm. I could've sworn there was something in there for dealing with -0, but I might be thinking of the formatting code, not the parsing code.

…itive. The issue is that while float('-00') returns a negative zero, int('-00') does not, so we need to take care of always using float rather than int when converting degrees or hours to numerical values.
@astrofrog

Copy link
Copy Markdown
Member

Fixed in the attached code - let's check Travis passes.

@astrofrog

Copy link
Copy Markdown
Member

The output for the original code in the issue is now:

In [4]: print coord.Dec('00 30 00.0', unit=units.degree)
0d30m00.00000s

In [5]: print coord.Dec('01 30 00.0', unit=units.degree)
1d30m00.00000s

In [6]: print coord.Dec('-00 30 00.0', unit=units.degree)
-0d30m00.00000s

In [7]: print coord.Dec('-01 30 00.0', unit=units.degree)
-1d30m00.00000s

@eteq

eteq commented Apr 2, 2013

Copy link
Copy Markdown
Member

I thought this was fixed too, although I also may be confusing it with output. Anyway, this looks good to merge to me (Assuming tests pass).

@embray

embray commented Apr 2, 2013

Copy link
Copy Markdown
Member

I'm g oing to wait for the tests to pass on this, then I will merge it and do the release.

@astrofrog

Copy link
Copy Markdown
Member

@iguananaut - there's a failure in the docs build related to WCSBase (I think this is addressed in another ticket) but other than that, the tests are passing.

embray added a commit that referenced this pull request Apr 3, 2013
dms declinations with -00 not treated correctly
@embray
embray merged commit 9fe83e1 into astropy:master Apr 3, 2013
embray added a commit that referenced this pull request Apr 3, 2013
embray added a commit that referenced this pull request Apr 3, 2013
dms declinations with -00 not treated correctly
embray added a commit that referenced this pull request Apr 3, 2013
@astrofrog
astrofrog deleted the fix-issue-875 branch July 5, 2016 15:47
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.

3 participants