Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Strip trailing spaces from log-formatter cursor output. #28056

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 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 5 additions & 5 deletions lib/matplotlib/tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,11 +1177,11 @@ def test_pprint(self, value, domain, expected):
assert label == expected

@pytest.mark.parametrize('value, long, short', [
(0.0, "0", "0 "),
(0, "0", "0 "),
(-1.0, "-10^0", "-1 "),
(2e-10, "2x10^-10", "2e-10 "),
(1e10, "10^10", "1e+10 "),
(0.0, "0", "0"),
(0, "0", "0"),
(-1.0, "-10^0", "-1"),
(2e-10, "2x10^-10", "2e-10"),
(1e10, "10^10", "1e+10"),
])
def test_format_data(self, value, long, short):
fig, ax = plt.subplots()
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ def format_data(self, value):

def format_data_short(self, value):
# docstring inherited
return '%-12g' % value
return ('%-12g' % value).rstrip()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the post merge comment here, but why not just:

    return f"{value:g}"

The 12 in the format is adding padding that we are then just stripping away...


def _pprint_val(self, x, d):
# If the number is not too big and it's an int, format it as an int.
Expand Down
Loading