|
1 | 1 | import warnings
|
2 | 2 | import re
|
| 3 | +import itertools |
3 | 4 |
|
4 | 5 | import numpy as np
|
5 | 6 | from numpy.testing import assert_almost_equal, assert_array_equal
|
@@ -366,6 +367,47 @@ def test_minor_attr(self):
|
366 | 367 | loc.set_params(minor=False)
|
367 | 368 | assert not loc.minor
|
368 | 369 |
|
| 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 | + |
369 | 411 |
|
370 | 412 | class TestFixedLocator:
|
371 | 413 | def test_set_params(self):
|
|
0 commit comments