|
| 1 | +from matplotlib import pyplot |
| 2 | + |
| 3 | +import nose.tools as nt |
| 4 | +from matplotlib.testing.decorators import cleanup |
| 5 | + |
| 6 | +from probscale import validate |
| 7 | + |
| 8 | + |
| 9 | +class Test_axes_object(object): |
| 10 | + @nt.raises(ValueError) |
| 11 | + def test_bad_value(self): |
| 12 | + validate.axes_object('junk') |
| 13 | + |
| 14 | + @cleanup |
| 15 | + def test_with_ax(self): |
| 16 | + fig, ax = pyplot.subplots() |
| 17 | + fig1, ax1 = validate.axes_object(ax) |
| 18 | + nt.assert_true(isinstance(ax1, pyplot.Axes)) |
| 19 | + nt.assert_true(isinstance(fig1, pyplot.Figure)) |
| 20 | + nt.assert_true(ax1 is ax) |
| 21 | + nt.assert_true(fig1 is fig) |
| 22 | + |
| 23 | + @cleanup |
| 24 | + def test_with_None(self): |
| 25 | + fig1, ax1 = validate.axes_object(None) |
| 26 | + nt.assert_true(isinstance(ax1, pyplot.Axes)) |
| 27 | + nt.assert_true(isinstance(fig1, pyplot.Figure)) |
| 28 | + |
| 29 | + |
| 30 | +class Test_fit_argument(object): |
| 31 | + @nt.raises(ValueError) |
| 32 | + def test_bad_fitarg(self): |
| 33 | + validate.fit_argument('junk', 'fitprobs') |
| 34 | + |
| 35 | + def test_x(self): |
| 36 | + nt.assert_equal('x', validate.fit_argument('x', 'fitprobs')) |
| 37 | + nt.assert_equal('x', validate.fit_argument('x', 'fitlogs')) |
| 38 | + |
| 39 | + def test_y(self): |
| 40 | + nt.assert_equal('y', validate.fit_argument('y', 'fitprobs')) |
| 41 | + nt.assert_equal('y', validate.fit_argument('y', 'fitlogs')) |
| 42 | + |
| 43 | + def test_both(self): |
| 44 | + nt.assert_equal('both', validate.fit_argument('both', 'fitprobs')) |
| 45 | + nt.assert_equal('both', validate.fit_argument('both', 'fitlogs')) |
| 46 | + |
| 47 | + def test_None(self): |
| 48 | + nt.assert_true(validate.fit_argument(None, 'fitprobs') is None) |
| 49 | + nt.assert_true(validate.fit_argument(None, 'fitlogs') is None) |
| 50 | + |
| 51 | + |
| 52 | +class Test_axis_name(object): |
| 53 | + @nt.raises(ValueError) |
| 54 | + def test_bad_name(self): |
| 55 | + validate.axis_name('junk', 'axname') |
| 56 | + |
| 57 | + def test_x(self): |
| 58 | + nt.assert_equal('x', validate.axis_name('x', 'axname')) |
| 59 | + |
| 60 | + def test_y(self): |
| 61 | + nt.assert_equal('y', validate.axis_name('y', 'axname')) |
| 62 | + |
| 63 | + |
| 64 | +class Test_axis_type(object): |
| 65 | + @nt.raises(ValueError) |
| 66 | + def test_bad_value(self): |
| 67 | + validate.axis_type("JUNK") |
| 68 | + |
| 69 | + def test_upper(self): |
| 70 | + nt.assert_equal('pp', validate.axis_type('PP')) |
| 71 | + nt.assert_equal('qq', validate.axis_type('QQ')) |
| 72 | + nt.assert_equal('prob', validate.axis_type('ProB')) |
0 commit comments