Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 #88 and #93: multiple decimal places and multiple decimal numbers #91
base: master
Are you sure you want to change the base?
fix #88 and #93: multiple decimal places and multiple decimal numbers #91
Changes from 2 commits
11fae0a
715fdda
951b8df
260e32a
d1d5a04
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
should this be updated to check for the new
_DECIMAL_MARKER
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.
By this point,
_DECIMAL_MARKER
has done its job. This bit is easier to look at in a debugger than it is to explain, butnumbers2
is a list ofReplaceableNumber
objects corresponding to the digits of our decimal part. It's going to be joined, then appended to a decimal point, then cast to a float and summed with the whole number part of our result.The
if
statement here goes back to Core, and it makes sure the first element ofnumbers2
doesn't already have a decimal point. It's hypothetically possible, but I can't figure out how, and removing theif
clause doesn't break any test cases. Still, I left it there, just removed a superfluous variable is all.I'll see if I can work backwards through
git blame
and ask whoever wrote the if statement. I was assuming it had something to do with the way the tokenizer handles certain input. If it's just a relic, I'm all for removing line 318 entirely.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 it doesnt break test cases, i say let's remove it or find a test case for it
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 I was calling an
extract_decimal
function I'd expect a float is returned. What's the benefit of returning an integer instead?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.
Should be
and not places
, good catch! That is, this is fundamentally a helper invoked byextract_number()
. Unless the user has asked for decimal places, I'd figured no rounding means a whole number is just that. On the other hand, you're right, that doesn't work either: "one" is a whole number. "one point zero" equals a whole number.What if
decimal_places=None
does no rounding,decimal_places=0
always returns an int, anddecimal_places > 0
does what it does?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.
👍 Yeah that sounds intuitive to me
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.
One more
int or False