8000 TestLogitLocator: append a test on nonsingular to avoid issues as #14743 · matplotlib/matplotlib@787f6b8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 787f6b8

Browse files
committed
TestLogitLocator: append a test on nonsingular to avoid issues as #14743
1 parent b676ca1 commit 787f6b8

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import warnings
22
import re
3+
import itertools
34

45
import numpy as np
56
from numpy.testing import assert_almost_equal, assert_array_equal
@@ -366,6 +367,44 @@ def test_minor_attr(self):
366367
loc.set_params(minor=False)
367368
assert not loc.minor
368369

370+
acceptable_vmin_vmax = [
371+
*(2.5 ** np.arange(-3, 0)),
372+
*(1 - 2.5 ** np.arange(-3, 0)),
373+
]
374+
375+
@pytest.mark.parametrize(
376+
"lims",
377+
[
378+
(a, b)
379+
for (a, b) in itertools.product(acceptable_vmin_vmax, repeat=2)
380+
if a != b
381+
],
382+
)
383+
def test_nonsingular_ok(self, lims):
384+
"""
385+
Create logit locator, and test the nonsingular method for acceptable
386+
value
387+
"""
388+
loc = mticker.LogitLocator()
389+
lims2 = loc.nonsingular(*lims)
390+
assert lims == lims2
391+
392+
@pytest.mark.parametrize("okval", acceptable_vmin_vmax)
393+
def test_nonsingular_nok(self, okval):
394+
"""
395+
Create logit locator, and test the nonsingular method for non
396+
acceptable value
397+
"""
398+
loc = mticker.LogitLocator()
399+
vmin, vmax = (-1, okval)
400+
vmin2, vmax2 = loc.nonsingular(vmin, vmax)
401+
assert vmax2 == vmax
402+
assert 0 < vmin2 < vmax2
403+
vmin, vmax = (okval, 2)
404+
vmin2, vmax2 = loc.nonsingular(vmin, vmax)
405+
assert vmin2 == vmin
406+
assert vmin2 < vmax2 < 1
407+
369408

370409
class TestFixedLocator:
371410
def test_set_params(self):

0 commit comments

Comments
 (0)
0