Add parsing of single digit angles#4
Conversation
|
So it seems like astropy uses two different conventions, for their standard tuples the sign is propagated through all the constituents and for the signed tuples they add a fourth field with the sign. What is the benefit to having the sign in each token? How does that affect user inputs? e.g., currently the following three are equivalent in sort of a "most significant sign" arrangement in the function that combines the constituents, so there's no need to carry the sign in all the tokens. dms2rad((-1, 2, 3))
dms2rad((-1, -2, -3))
dms2rad(-1, -2, 3)) |
|
I think — but I'm likely wrong too — that users that input an angle with a sign ( FWIW, I don't think there are users out there that input things like |
Fixes #2?
This PR is a WIP and adds parsing for strings with a single digit such as
"1'W".Since this is a WIP, this first commit only changed the degree parsing function
parse_dms(not the hour parsing one,parse_hms).This PR is breaking the current tests. In particular, my interpretation (maybe wrong, asked in the linked issue) is that the sign at the front should be broadcast to all the digits. Having only edited
parse_dmsand notparse_hms, we can see the difference in behavior:This PR essentially splits the regex for parsing in a regex for each component to allow to grab each individual item. For example, these now work as expected (IMHO):
Finally, there are plenty of corner cases that this PR still gets wrong I'm sure. I just thought it might be useful to publish it here for more knowledgable eyes to look at it! 🙂