Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mdickinson merged 34 commits intopython:mainfrommdickinson:fraction-format
Jan 22, 2023
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
34 commits
Select commitHold shift + click to select a range
8cf8d31
Add '.f' formatting for Fraction objects
mdickinsonDec 3, 2022
e9db697
Add support for % and F format specifiers
mdickinsonDec 3, 2022
6491b04
Add support for 'z' flag
mdickinsonDec 4, 2022
4551468
Tidy up of business logic
mdickinsonDec 4, 2022
43d34fc
Add support for 'e' presentation type
mdickinsonDec 4, 2022
f8dfcb9
Add support for 'g' presentation type; tidy
mdickinsonDec 4, 2022
6bfbc6c
Tidying
mdickinsonDec 10, 2022
48629b7
Add news entry
mdickinsonDec 10, 2022
3d21af2
Add documentation
mdickinsonDec 10, 2022
c86a57e
Add what's new entry
mdickinsonDec 10, 2022
b521efb
Fix backticks:
mdickinsonDec 10, 2022
aac576e
Fix more missing backticks
mdickinsonDec 10, 2022
b9ee0ff
Fix indentation
mdickinsonDec 10, 2022
1c8b8a9
Wordsmithing for consistency with other method definitions
mdickinsonDec 10, 2022
9dbde3b
Add link to the format specification mini-language
mdickinsonDec 10, 2022
2dd48bb
Fix: not true that thousands separators cannot have an effect for the…
mdickinsonDec 10, 2022
983726f
Fix typo in comment
mdickinsonDec 10, 2022
b7e5129
Tweak docstring and comments for _round_to_exponent
mdickinsonDec 21, 2022
cb5e234
Second pass on docstring and comments for _round_to_figures
mdickinsonDec 21, 2022
907487e
Add tests for the corner case of zero minimum width + alignment
mdickinsonDec 21, 2022
aba35f3
Tests for the case of zero padding _and_ a zero minimum width
mdickinsonDec 21, 2022
fc4d3b5
Cleanup of __format__ method
mdickinsonDec 21, 2022
4ccdf94
Add test cases from original issue and discussion thread
mdickinsonDec 21, 2022
b358b37
Merge branch 'main' into fraction-format
mdickinsonDec 21, 2022
67e020c
Tighten up the regex - extra leading zeros not permitted
mdickinsonDec 21, 2022
e240c70
Merge remote-tracking branch 'mdickinson/fraction-format' into fracti…
mdickinsonDec 21, 2022
111c41f
Add tests for a few more fill character corner cases
mdickinsonDec 21, 2022
d8cc3d6
Merge remote-tracking branch 'upstream/main' into fraction-format
mdickinsonJan 22, 2023
fff3751
Add testcases for no presentation type with an integral fraction
mdickinsonJan 22, 2023
0b8bfa6
Rename the regex to allow for future API expansion
mdickinsonJan 22, 2023
54ed402
Tweak comment
mdickinsonJan 22, 2023
e3a5fd2
Tweak algorithm comments
mdickinsonJan 22, 2023
098d34c
Fix incorrect acceptance of Z instead of z
mdickinsonJan 22, 2023
2c476a2
Use consistent quote style in tests
mdickinsonJan 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
PrevPrevious commit
NextNext commit
Fix incorrect acceptance of Z instead of z
  • Loading branch information
@mdickinson
mdickinson committedJan 22, 2023
commit098d34c9118cbe2a880d3c204dd29d2954373440
4 changes: 2 additions & 2 deletionsLib/fractions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,8 +155,8 @@ def _round_to_figures(n, d, figures):
(?P<minimumwidth>0|[1-9][0-9]*)?
(?P<thousands_sep>[,_])?
(?:\.(?P<precision>0|[1-9][0-9]*))?
(?P<presentation_type>[efg%])
""", re.DOTALL | re.IGNORECASE | re.VERBOSE).fullmatch
(?P<presentation_type>[eEfFgG%])
""", re.DOTALL | re.VERBOSE).fullmatch


class Fraction(numbers.Rational):
Expand Down
2 changes: 2 additions & 0 deletionsLib/test/test_fractions.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1211,6 +1211,8 @@ def test_invalid_formats(self):
".f",
".g",
".%",
# Z instead of z for negative zero suppression
'Z.2f'
]
for spec in invalid_specs:
with self.subTest(spec=spec):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp