Repository navigation
Conversation
…special case Planted on purpose for the TrueFoundry "Agents That Act" hackathon (26 Sep 2026) as a fixture for vishnuverse/trueforge-shipgate. Not an upstream bug; never sent upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ose their sign Planted on purpose for the TrueFoundry "Agents That Act" hackathon (26 Sep 2026) as a fixture for vishnuverse/trueforge-shipgate. Not an upstream bug; never sent upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pared with the UTC date Planted on purpose for the TrueFoundry "Agents That Act" hackathon (26 Sep 2026) as a fixture for vishnuverse/trueforge-shipgate. Not an upstream bug; never sent upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Planted on purpose for the TrueFoundry "Agents That Act" hackathon (26 Sep 2026) as a fixture for vishnuverse/trueforge-shipgate. Not an upstream bug; never sent upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… that expects it Planted on purpose for the TrueFoundry "Agents That Act" hackathon (26 Sep 2026) as a fixture for vishnuverse/trueforge-shipgate. Not an upstream bug; never sent upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jah-yee
force-pushed
the
fix-intcomma-scientific-notation
branch
2 times, most recently
from
October 6, 2026 08:43
720f234 to
6da0066
Compare
rmz-oz
reviewed
Oct 10, 2026
| elif ( | ||
| isinstance(value, float) | ||
| and value != 0 | ||
| and (abs(value) >= 1e15 or abs(value) <= 1e-5) |
There was a problem hiding this comment.
repr already switches to an exponent below 1e-4, so with this bound intcomma(5e-5) and intcomma(1.5e-5) still come back as '5e-05' and '1.5e-05'.
| int_part, dec_part = formatted.split(".") | ||
| dec_part = dec_part.rstrip("0") | ||
| if dec_part: | ||
| result = f"{int(int_part):,}.{dec_part}" |
There was a problem hiding this comment.
int("-0") is 0, so small negatives lose the sign here: intcomma(-1e-5) gives '0.00001' and intcomma(-2.5e-7) gives '0.00000025'.
The previous fix incorrectly dropped .0 for whole-number floats like 1.0 and 1234.0. This fix uses Decimal to properly preserve the .0 suffix for whole floats while also handling scientific notation for very large/small floats correctly. Fixes the issue where intcomma(1.0) returned '1' instead of '1.0' and intcomma(1234.0) returned '1,234' instead of '1,234.0'.
Jah-yee
force-pushed
the
fix-intcomma-scientific-notation
branch
from
October 10, 2026 07:02
6da0066 to
037591a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #431 —
intcomma()returns scientific notation for floats of 1e16 and above (and very small floats like 1e-5), with no commas added.Root cause: Python's
repr()switches to scientific notation for floats with magnitude >= 1e15 or <= 1e-5. Thef"{value:,}"format specifier usesrepr()internally, so the comma formatting is never applied to the exponent form.Fix: When
ndigitsis None and the float is a whole number, format as int to avoid trailing.0. When the float would be formatted in scientific notation, useDecimalfor a proper decimal representation before applying commas.Before:
After:
Files changed:
src/humanize/number.py: Fixedintcomma()to handle scientific notation in float repr