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

Skip to content

Commit 3183f78

Browse files
committed
TST: add test for large case
1 parent ed1c830 commit 3183f78

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,15 +275,17 @@ class TestScalarFormatter(object):
275275

276276
use_offset_data = [True, False]
277277

278+
# (sci_type, scilimits, lim, orderOfMag, fewticks)
278279
scilimits_data = [
279-
(False, (0, 0), (10.0, 20.0), 0),
280-
(True, (-2, 2), (-10, 20), 0),
281-
(True, (-2, 2), (-20, 10), 0),
282-
(True, (-2, 2), (-110, 120), 2),
283-
(True, (-2, 2), (-120, 110), 2),
284-
(True, (-2, 2), (-.001, 0.002), -3),
285-
(True, (0, 0), (-1e5, 1e5), 5),
286-
(True, (6, 6), (-1e5, 1e5), 6),
280+
(False, (0, 0), (10.0, 20.0), 0, False),
281+
(True, (-2, 2), (-10, 20), 0, False),
282+
(True, (-2, 2), (-20, 10), 0, False),
283+
(True, (-2, 2), (-110, 120), 2, False),
284+
(True, (-2, 2), (-120, 110), 2, False),
285+
(True, (-2, 2), (-.001, 0.002), -3, False),
286+
(True, (-7, 7), (0.2e10, 0.8e10), 9, True),
287+
(True, (0, 0), (-1e5, 1e5), 5, False),
288+
(True, (6, 6), (-1e5, 1e5), 6, False),
287289
]
288290

289291
@pytest.mark.parametrize('left, right, offset', offset_data)
@@ -316,14 +318,17 @@ def test_use_offset(self, use_offset):
316318
assert use_offset == tmp_form.get_useOffset()
317319

318320
@pytest.mark.parametrize(
319-
'sci_type, scilimits, lim, orderOfMag', scilimits_data)
321+
'sci_type, scilimits, lim, orderOfMag, fewticks', scilimits_data)
320322
def test_scilimits(self, sci_type, scilimits, lim, orderOfMag):
321323
tmp_form = mticker.ScalarFormatter()
322324
tmp_form.set_scientific(sci_type)
323325
tmp_form.set_powerlimits(scilimits)
324326
fig, ax = plt.subplots()
325327
ax.yaxis.set_major_formatter(tmp_form)
326328
ax.set_ylim(*lim)
329+
if fewticks:
330+
ax.yaxis.set_major_locator(mticker.MaxNLocator(4))
331+
327332
tmp_form.set_locs(ax.yaxis.get_majorticklocs())
328333
assert orderOfMag == tmp_form.orderOfMagnitude
329334

0 commit comments

Comments
 (0)