|
| 1 | +#======================================================================= |
| 2 | +"""The Fill unit-test class implementation.""" |
| 3 | +#======================================================================= |
| 4 | + |
| 5 | +from mplTest import * |
| 6 | + |
| 7 | +#======================================================================= |
| 8 | +# Add import modules below. |
| 9 | +import matplotlib |
| 10 | +matplotlib.use( "Agg", warn = False ) |
| 11 | + |
| 12 | +import pylab |
| 13 | +import numpy as npy |
| 14 | +from datetime import datetime |
| 15 | +# |
| 16 | +#======================================================================= |
| 17 | + |
| 18 | +#======================================================================= |
| 19 | +class TestFill( MplTestCase ): |
| 20 | + """Test the various axes fill methods.""" |
| 21 | + |
| 22 | + # Uncomment any appropriate tags |
| 23 | + tags = [ |
| 24 | + # 'gui', # requires the creation of a gui window |
| 25 | + 'agg', # uses agg in the backend |
| 26 | + 'agg-only', # uses only agg in the backend |
| 27 | + # 'wx', # uses wx in the backend |
| 28 | + # 'qt', # uses qt in the backend |
| 29 | + # 'ps', # uses the postscript backend |
| 30 | + # 'units', # uses units in the test |
| 31 | + 'PIL', # uses PIL for image comparison |
| 32 | + ] |
| 33 | + |
| 34 | + #-------------------------------------------------------------------- |
| 35 | + def setUp( self ): |
| 36 | + """Setup any data needed for the unit test.""" |
| 37 | + units.register() |
| 38 | + |
| 39 | + #-------------------------------------------------------------------- |
| 40 | + def tearDown( self ): |
| 41 | + """Clean-up any generated files here.""" |
| 42 | + pass |
| 43 | + |
| 44 | + #-------------------------------------------------------------------- |
| 45 | + def test_fill_units( self ): |
| 46 | + """Test the fill method with unitized-data.""" |
| 47 | + |
| 48 | + fname = self.outFile( "fill_units.png" ) |
| 49 | + |
| 50 | + # generate some data |
| 51 | + t = units.Epoch( "ET", dt=datetime(2009, 4, 27) ) |
| 52 | + value = 10.0 * units.deg |
| 53 | + day = units.Duration( "ET", 24.0 * 60.0 * 60.0 ) |
| 54 | + |
| 55 | + fig = pylab.figure() |
| 56 | + |
| 57 | + # Top-Left |
| 58 | + ax1 = fig.add_subplot( 221 ) |
| 59 | + ax1.plot( [t], [value], yunits='deg', color='red' ) |
| 60 | + ax1.fill( [733525.0, 733525.0, 733526.0, 733526.0], |
| 61 | + [0.0, 0.0, 90.0, 0.0], 'b' ) |
| 62 | + |
| 63 | + # Top-Right |
| 64 | + ax2 = fig.add_subplot( 222 ) |
| 65 | + ax2.plot( [t], [value], yunits='deg', color='red' ) |
| 66 | + ax2.fill( [t, t, t+day, t+day], |
| 67 | + [0.0, 0.0, 90.0, 0.0], 'b' ) |
| 68 | + |
| 69 | + # Bottom-Left |
| 70 | + ax3 = fig.add_subplot( 223 ) |
| 71 | + ax3.plot( [t], [value], yunits='deg', color='red' ) |
| 72 | + ax1.fill( [733525.0, 733525.0, 733526.0, 733526.0], |
| 73 | + [0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], 'b' ) |
| 74 | + |
| 75 | + # Bottom-Right |
| 76 | + ax4 = fig.add_subplot( 224 ) |
| 77 | + ax4.plot( [t], [value], yunits='deg', color='red' ) |
| 78 | + ax4.fill( [t, t, t+day, t+day], |
| 79 | + [0*units.deg, 0*units.deg, 90*units.deg, 0*units.deg], |
| 80 | + facecolor="blue" ) |
| 81 | + |
| 82 | + fig.autofmt_xdate() |
| 83 | + fig.savefig( fname ) |
| 84 | + self.checkImage( fname ) |
| 85 | + |
| 86 | + #-------------------------------------------------------------------- |
| 87 | + |
0 commit comments