Repository navigation
Respect floatfmt and intfmt in the pretty format - #497
Open
DresdenGman wants to merge 1 commit into
Open
DresdenGman wants to merge 1 commit into
DresdenGman wants to merge 1 commit into
Conversation
The pretty format unconditionally disabled number parsing, so an explicitly given floatfmt or intfmt was silently ignored. Keep the existing by-design behaviour (numbers rendered as-is) when the default formats are in effect, but parse numbers when the user passes a custom floatfmt or intfmt. Fixes astanin#71
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.
Fixes #71.
With
tablefmt="pretty", an explicitly givenfloatfmt(orintfmt) was silently ignored: for the same data,floatfmt=".2f"renders1.23/7.80in simple, grid, pipe and fancy_grid, but1.23456/7.8in pretty.The cause is that the pretty branch unconditionally set
disable_numparse = True, so numeric columns were typed as strings and never reached the float/int formatting path. Simply removing that override would change pretty's default output, because the defaultfloatfmt="g"would then reformat values such as451.0into451, which existing tests pin down.This keeps the by-design behaviour when the default formats are in effect, and only parses numbers when the user actually passes a custom
floatfmtorintfmt(including per-column lists). An explicitdisable_numparse=Truestill takes precedence, and pretty's centered alignment is unchanged.Tests: two new tests,
test_pretty_floatfmtandtest_pretty_intfmt, which fail against the unmodified code. Full suite: 351 passed, 17 skipped, against a baseline of 349 passed, 17 skipped — the difference is exactly the two new tests.