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

Commit693ecee

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

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
importwarnings
22
importre
3+
importitertools
34

45
importnumpyasnp
56
fromnumpy.testingimportassert_almost_equal,assert_array_equal
@@ -366,6 +367,47 @@ 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+
395+
@pytest.mark.parametrize("okval",acceptable_vmin_vmax)
396+
deftest_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+
assertvmax2==vmax
405+
assert0<vmin2<vmax2
406+
vmin,vmax= (okval,2)
407+
vmin2,vmax2=loc.nonsingular(vmin,vmax)
408+
assertvmin2==vmin
409+
assertvmin2<vmax2<1
410+
369411

370412
classTestFixedLocator:
371413
deftest_set_params(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp