-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add function convert_to_int_float_str #49
Conversation
I'd just note in passing that I disagree a bit that the original implementation is a bug. Honestly, maybe obsids should just be strings, but I can see the need for different supporting code if the calling code expects that '01234' -> 1234. |
@jeanconn - our code base assumes in many places that So obsid is an integer (or maybe a float in the non-compliant real world), not a string. |
And of course the serious bug is an inconsistent return type for obsid, depending on whether it happens to have a leading |
Also note that the original |
While our code does assume many places that obsid is an integer, if we like to represent it as '01234' that is not an integer. And for OP19, I assume '01234' would be non-compliant. But I'm not arguing that we make a change to go through and change all of our "< 38000" bits of code to "< '38000'" , I'm just saying that it looks to me like "Coerce the supplied |
I also wonder @taldcroft if you read my "I can see the need" as "I can't see the need". Because I can see the need for this code change and I think it is the right thing. I was mostly just commenting that obsids are annoying and the previous code isn't entirely to blame. |
I added a note. |
I'm fine with this change. The name of the function bugs me a bit though. Instead of |
Description
This adds a function
convert_to_int_float_str()
to replace various versions of_coerce_type
that exist in Ska3 code. I discovered that the canonical version inparse_cm.common
has a serious bug:The issue is that
01234
is not a valid int literal because of the leading0
. The new function here handles all the test cases correctly.The intent is to replace all calls to various flavors of
_coerce_type
with a call toconvert_to_int_float_str
.https://github.com/search?q=org%3Asot+_coerce_type&type=code
Though in fact the different flavors seem to mostly be in deprecrated / unused code apart from
parse_cm
itself.Interface impacts
None.
Testing
Unit tests
Independent check of unit tests by Javier
Functional tests