Skip to content

Commit 358c9c1

Browse files
ryanbeltleeonadoh
authored andcommitted
added testcases for the set_params change
1 parent 6775327 commit 358c9c1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

lib/matplotlib/tests/test_ticker.py

+18
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@ def test_formatstrformatter():
111111
tmp_form = mticker.StrMethodFormatter('{x:05d}')
112112
nose.tools.assert_equal('00002', tmp_form(2))
113113

114+
@cleanup
115+
def test_set_params():
116+
loc = mticker.LogLocator(numticks = 2)
117+
118+
assert_raises(ValueError, loc.tick_values, 0, 1000)
119+
#this should return number of ticks as 5
120+
test_value = np.array([ 1.0000000e-10, 1.0000000e-03, 1.0000000e+04, 1.0000000e+11,
121+
1.0000000e+18])
122+
assert_almost_equal(loc.tick_values(0.001, 1.1e5), test_value)
123+
#after the set_params(numticks=8), it should have 7 extra which should have 7 extra
124+
#numticks. Also it won't casue to thrown the exception for bugs # #3658
125+
loc.set_params(numticks = 8)
126+
test_value = np.array([ 1.0000000e-04, 1.0000000e-03, 1.0000000e-02, 1.0000000e-01,
127+
1.0000000e+00, 1.0000000e+01, 1.0000000e+02, 1.0000000e+03,
128+
1.0000000e+04, 1.0000000e+05, 1.0000000e+06, 1.0000000e+07])
129+
assert_almost_equal(loc.tick_values(0.001, 1.1e5), test_value)
130+
131+
114132

115133
if __name__ == '__main__':
116134
import nose

0 commit comments

Comments
 (0)