Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit966cca4

Browse files
committed
TestLogitLocator: append a test on nonsingular to avoid issues as#14743
1 parentb676ca1 commit966cca4

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

‎lib/matplotlib/tests/test_ticker.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
importwarnings
22
importre
3+
importitertools
34

45
importnumpyasnp
56
fromnumpy.testingimportassert_almost_equal,assert_array_equal
@@ -366,6 +367,46 @@ def test_minor_attr(self):
366367
loc.set_params(minor=False)
367368
assertnotloc.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)initertools.product(
380+
acceptable_vmin_vmax,acceptable_vmin_vmax
381+
)
382+
ifa!=b
383+
],
384+
)
385+
deftest_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+
assertlims==lims2
393+
394+
@pytest.mark.parametrize("okval",acceptable_vmin_vmax)
395+
deftest_nonsingular_nok(self,okval):
396+
"""
397+
Create logit locator, and test the nonsingular method for non
398+
acceptable value
399+
"""
400+
loc=mticker.LogitLocator()
401+
vmin,vmax= (-1,okval)
402+
vmin2,vmax2=loc.nonsingular(vmin,vmax)
403+
assertvmax2==vmax
404+
assert0<vmin2<vmax2
405+
vmin,vmax= (okval,2)
406+
vmin2,vmax2=loc.nonsingular(vmin,vmax)
407+
assertvmin2==vmin
408+
assertvmin2<vmax2<1
409+
369410

370411
classTestFixedLocator:
371412
deftest_set_params(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp