-
Notifications
You must be signed in to change notification settings - Fork 72
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
Feat: accounting notation for fmt_number()
, fmt_percent()
, fmt_integer()
and fmt_currency()
#513
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #513 +/- ##
==========================================
+ Coverage 89.79% 89.81% +0.01%
==========================================
Files 45 45
Lines 5321 5331 +10
==========================================
+ Hits 4778 4788 +10
Misses 543 543 ☔ View full report in Codecov by Sentry. |
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 left one suggestion for a minor tweak to the docstring language, but feel free to take or leave it! (not the language is repeated in several places)
@@ -108,6 +109,9 @@ def val_fmt_number( | |||
The `use_seps` option allows for the use of digit group separators. The type of digit group | |||
separator is set by `sep_mark` and overridden if a locale ID is provided to `locale`. This | |||
setting is `True` by default. | |||
accounting | |||
An option to use accounting style for values. Normally, negative values will be shown with a |
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.
WDYT of changing these docstrings to something like "Whether to use accounting style, which wraps negative numbers in parentheses instead of using a minus sign."
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.
Sounds good, now done!
<tr> | ||
<td class="gt_row gt_right">−1.20</td> | ||
<td class="gt_row gt_right">−5.23%</td> | ||
<td class="gt_row gt_right">2,323</td> |
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.
It seems like this is not testing that fmt_integer uses accounting format on negative numbers
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.
The first four columns of this table are formatted but with accounting=False
(minus signs persist) , the last four have accounting=True
so we do get the negative values in parens there.
This introduces the
accounting=
arg tofmt_number()
,fmt_percent()
,fmt_integer()
andfmt_currency()
, allowing for accounting notation (e.g.,"-343.27"
->"(343.27)"
. This new functionality also extends to the same formatters in thevals
module.Here is an example table demonstrating usage:
Fixes: #278