8000 Make LogFormatterExponent tests check more non-integer ticks and bases · matplotlib/matplotlib@03af950 · GitHub
[go: up one dir, main page]

Skip to content

Commit 03af950

Browse files
committed
Make LogFormatterExponent tests check more non-integer ticks and bases
1 parent 1eb8aca commit 03af950

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def get_view_interval(self):
5858

5959
i = np.arange(-3, 4, dtype=float)
6060
expected_result = ['-3', '-2', '-1', '0', '1', '2', '3']
61-
for base in [2, 5, 10, np.pi]:
61+
for base in [2, 5, 10, np.pi, np.e]:
6262
formatter = mticker.LogFormatterExponent(base=base)
6363
formatter.axis = FakeAxis()
6464
vals = base**i
@@ -71,11 +71,15 @@ def get_view_interval(self):
7171
nose.tools.assert_equal(formatter(10**0.1), '')
7272

7373
# Otherwise, non-integer powers should be nicely formatted
74-
formatter = mticker.LogFormatterExponent(base=10, labelOnlyBase=False)
75-
formatter.axis = FakeAxis()
76-
nose.tools.assert_equal(formatter(10**0.1), '0.1')
77-
nose.tools.assert_equal(formatter(10**0.00001), '1e-05')
78-
nose.tools.assert_equal(formatter(10**-0.2), '-0.2')
74+
locs = np.array([0.1, 0.00001, np.pi, 0.2, -0.2, -0.00001])
75+
i = range(len(locs))
76+
expected_result = ['0.1', '1e-05', '3.14', '0.2', '-0.2', '-1e-05']
77+
for base in [2, 5, 10, np.pi, np.e]:
78+
formatter = mticker.LogFormatterExponent(base=base, labelOnlyBase=False)
79+
formatter.axis = FakeAxis()
80+
vals = base**locs
81+
labels = [formatter(x, pos) for (x, pos) in zip(vals, i)]
82+
nose.tools.assert_equal(labels, expected_result)
7983

8084
def test_use_offset():
8185
for use_offset in [True, False]:

0 commit comments

Comments
 (0)
0