Skip to content

gh-67790: Support float-style formatting for Fraction instances #100161

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

Merged
merged 34 commits into from
Jan 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8cf8d31
Add '.f' formatting for Fraction objects
mdickinson Dec 3, 2022
e9db697
Add support for % and F format specifiers
mdickinson Dec 3, 2022
6491b04
Add support for 'z' flag
mdickinson Dec 4, 2022
4551468
Tidy up of business logic
mdickinson Dec 4, 2022
43d34fc
Add support for 'e' presentation type
mdickinson Dec 4, 2022
f8dfcb9
Add support for 'g' presentation type; tidy
mdickinson Dec 4, 2022
6bfbc6c
Tidying
mdickinson Dec 10, 2022
48629b7
Add news entry
mdickinson Dec 10, 2022
3d21af2
Add documentation
mdickinson Dec 10, 2022
c86a57e
Add what's new entry
mdickinson Dec 10, 2022
b521efb
Fix backticks:
mdickinson Dec 10, 2022
aac576e
Fix more missing backticks
mdickinson Dec 10, 2022
b9ee0ff
Fix indentation
mdickinson Dec 10, 2022
1c8b8a9
Wordsmithing for consistency with other method definitions
mdickinson Dec 10, 2022
9dbde3b
Add link to the format specification mini-language
mdickinson Dec 10, 2022
2dd48bb
Fix: not true that thousands separators cannot have an effect for the…
mdickinson Dec 10, 2022
983726f
Fix typo in comment
mdickinson Dec 10, 2022
b7e5129
Tweak docstring and comments for _round_to_exponent
mdickinson Dec 21, 2022
cb5e234
Second pass on docstring and comments for _round_to_figures
mdickinson Dec 21, 2022
907487e
Add tests for the corner case of zero minimum width + alignment
mdickinson Dec 21, 2022
aba35f3
Tests for the case of zero padding _and_ a zero minimum width
mdickinson Dec 21, 2022
fc4d3b5
Cleanup of __format__ method
mdickinson Dec 21, 2022
4ccdf94
Add test cases from original issue and discussion thread
mdickinson Dec 21, 2022
b358b37
Merge branch 'main' into fraction-format
mdickinson Dec 21, 2022
67e020c
Tighten up the regex - extra leading zeros not permitted
mdickinson Dec 21, 2022
e240c70
Merge remote-tracking branch 'mdickinson/fraction-format' into fracti…
mdickinson Dec 21, 2022
111c41f
Add tests for a few more fill character corner cases
mdickinson Dec 21, 2022
d8cc3d6
Merge remote-tracking branch 'upstream/main' into fraction-format
mdickinson Jan 22, 2023
fff3751
Add testcases for no presentation type with an integral fraction
mdickinson Jan 22, 2023
0b8bfa6
Rename the regex to allow for future API expansion
mdickinson Jan 22, 2023
54ed402
Tweak comment
mdickinson Jan 22, 2023
e3a5fd2
Tweak algorithm comments
mdickinson Jan 22, 2023
098d34c
Fix incorrect acceptance of Z instead of z
mdickinson Jan 22, 2023
2c476a2
Use consistent quote style in tests
mdickinson Jan 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests for the case of zero padding _and_ a zero minimum width
  • Loading branch information
mdickinson committed Dec 21, 2022
commit aba35f37bed36c160ff3ecf1c04e1ad07d77ebcf
4 changes: 4 additions & 0 deletions Lib/test/test_fractions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ def test_format_f_presentation_type(self):
(F(2, 3), '<0.2f', '0.67'),
(F(2, 3), '^0.2f', '0.67'),
(F(2, 3), '=0.2f', '0.67'),
# Corner case: zero-padding _and_ a zero minimum width.
(F(2, 3), '00.2f', '0.67'),
# Thousands separator (only affects portion before the point)
(F(2, 3), ',.2f', '0.67'),
(F(2, 3), ',.7f', '0.6666667'),
Expand Down Expand Up @@ -1169,6 +1171,8 @@ def test_invalid_formats(self):
"=010f",
"=010g",
"=010%",
'>00.2f',
'>00f',
# Missing precision
".e",
".f",
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy