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

Skip to content

Commit 693ecee

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

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

lib/matplotlib/tests/test_ticker.py

Lines changed: 42 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,47 @@ 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(
380+
acceptable_vmin_vmax, acceptable_vmin_vmax
381+
)
382+
if a != b
383+
],
384+
)
385+
def test_nonsingular_ok(self, lims):
386+
"""
387+
Create logit locator, and test the nonsingular method for acceptable
388+
value
389+
"""
390+
loc = mticker.LogitLocator()
391+
lims2 = loc.nonsingular(*lims)
392+
assert lims == lims2
393+
394+
395+
@pytest.mark.parametrize("okval", acceptable_vmin_vmax)
396+
def test_nonsingular_nok(self, okval):
397+
"""
398+
Create logit locator, and test the nonsingular method for non
399+
acceptable value
400+
"""
401+
loc = mticker.LogitLocator()
402+
vmin, vmax = (-1, okval)
403+
vmin2, vmax2 = loc.nonsingular(vmin, vmax)
404+
assert vmax2 == vmax
405+
assert 0 < vmin2 < vmax2
406+
vmin, vmax = (okval, 2)
407+
vmin2, vmax2 = loc.nonsingular(vmin, vmax)
408+
assert vmin2 == vmin
409+
assert vmin2 < vmax2 < 1
410+
369411

370412
class TestFixedLocator:
371413
def test_set_params(self):

0 commit comments

Comments
 (0)
0