-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix parsing of fixed point numbers #28
Conversation
👉 View analysis in DeepCode’s Dashboard | Configure the bot |
Do you have an example of this bug? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this makes sense to me. I was worried it was going to get complicated and this definitely leans that way, but still not quite as bad as I thought it'd be. Nice job.
For your tests, what do you think about using pytest.mark.parameterize? You'd have to move the test function(s) outside the unittest class as regular functions or create a separate test class (ex. class TestParser:
) that isn't based on unittest.TestCase.
Sure, this is with the current master:
Good idea! I'll update the tests. |
I also refactored the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If tests pass then LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR fixes the following problems with the parsing of fixed point numbers:
As suggested by @djhoese I added a new regular expression that is used if the format specifier includes width or precision. Finally, I updated the converter method to return floats.
Examples:
Width is considered minimum width, so that longer strings will also be matched (as long as the decimals match). This is to facilitate roundtrips with
compose
.The following cases will not be matched because the string is too short or the number of decimals is incorrect: