-
Notifications
You must be signed in to change notification settings - Fork 5
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: evaluate integer percentage #114
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,7 @@ def lower_dict(input_dict): | |
|
||
def super_float(text): | ||
""" | ||
Like float, but with SI extensions. 1k goes to 1000. | ||
Evaluate suffixes if applicable and apply float. | ||
""" | ||
if text[-1] in SUFFIXES: | ||
return float(text[:-1]) * SUFFIXES[text[-1]] | ||
|
@@ -128,7 +128,7 @@ def eval_number(parse_result): | |
Calls super_float above. | ||
""" | ||
for item in parse_result: | ||
if "." in item or "e" in item or "E" in item: | ||
if "." in item or "e" in item or "E" in item or parse_result[-1] in SUFFIXES: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It may just be me, but this doesn't feel exactly right. First of all, it's code duplication with line 115 that I think shows there's something about the code design that's not ideal, and secondly I don't like that we have a random-looking set of conditions which result in this being evaluated as a float, and then a default case that's int. It just intuitively does not look confidence-inspiring to me. Do you have any ideas? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why not There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at this again, it looks like previously the code was to simply always apply |
||
return super_float("".join(parse_result)) | ||
|
||
return int("".join(parse_result)) | ||
|
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 would like to still see
SI extensions
mentioned and some example would also be helpful in the comment.