8000 Merge pull request #26347 from oscargus/formattest · randomrahulm/matplotlib@109042c · GitHub
[go: up one dir, main page]

Skip to content

Commit 109042c

Browse files
authored
Merge pull request matplotlib#26347 from oscargus/formattest
Add tests for LogFormatter.format_data and format_data_short
2 parents ee723d9 + 644c469 commit 109042c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,20 @@ def test_pprint(self, value, domain, expected):
11311131
label = fmt._pprint_val(value, domain)
11321132
assert label == expected
11331133

1134+
@pytest.mark.parametrize('value, long, short', [
1135+
(0.0, "0", "0 "),
1136+
(0, "0", "0 "),
1137+
(-1.0, "-10^0", "-1 "),
1138+
(2e-10, "2x10^-10", "2e-10 "),
1139+
(1e10, "10^10", "1e+10 "),
1140+
])
1141+
def test_format_data(self, value, long, short):
1142+
fig, ax = plt.subplots()
1143+
ax.set_xscale('log')
1144+
fmt = ax.xaxis.get_major_formatter()
1145+
assert fmt.format_data(value) == long
1146+
assert fmt.format_data_short(value) == short
1147+
11341148
def _sub_labels(self, axis, subs=()):
11351149
"""Test whether locator marks subs to be labeled."""
11361150
fmt = axis.get_minor_formatter()

0 commit comments

Comments
 (0)
0