Beispiel #1
0
class MyTest(unittest.TestCase):
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.mySprSht = SpreadSheet()

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        del (self.mySprSht)

    def test_should_always_pass_cleanly(self):
        """Should always pass cleanly."""
        pass

    def test_myclass_existence(self):
        """Check that myclass exists"""
        result = self.mySprSht

        # See if the self.mySprSht object exists
        self.assertTrue(result)

    def test_save(self):
        """Check that save operates cleanly"""
        list_of_rows = ALT_DATA

        self.mySprSht.add_sheet('Alt_Data', list_of_rows)
        self.mySprSht.add_scatter(
            'Alt_Plot',
            'Alt_Data',
            title='Unittest Title',
            xlabel='Unittest X Axis',
            ylabel='Unittest Y Axis',
            y2label='Unittest Y2 Axis',
            xcol=1,
            ycolL=[2, 3, 4],
            ycol2L=None,
            showMarkerL=[1, 1, 1],
            showMarker2L=None,
            lineThkL=["0.1in", "0.01in"],
            lineStyleL=[1, 2, 3],
            colorL=None,  #['cyan','GRaY','#69a'], #['#666666'],
            labelL=None,
            label2L=None)

        self.mySprSht.setXrange(-10000, 70000, plot_sheetname=None)
        self.mySprSht.setYrange(-100, 700)
        #self.mySprSht.add_scatter( 'Alt_Plot2', 'Alt_Data')
        #self.mySprSht.add_scatter( 'Alt_Plot3', 'Alt_Data')
        self.mySprSht.save(filename=os.path.join(here, 'alt'))

    def test_save_secondary_y(self):
        """Check that save operates for a second y axis"""
        list_of_rows = ALT_DATA_WIDE

        self.mySprSht.add_sheet('Alt_Data', list_of_rows)
        self.mySprSht.add_scatter(
            'Alt_Plot',
            'Alt_Data',
            title='Unittest Title',
            xlabel='Unittest X Axis',
            ylabel='Unittest Y Axis',
            y2label='Unittest Y2 Axis',
            xcol=1,
            ycolL=[2, 5, 6],
            ycol2L=[3, 4],
            lineThkL=[1, 2, 3],
            lineThk2L=[3.5, 1.5],
            lineStyle2L=[4, 5],
            showMarkerL=[1, 1, 1],
            showMarker2L=None,
            showLineL=[0, 1, 0],
            showLine2L=[1, 1],
            #colorL=['r','g','b'], excel_colors=False, color2L=['c','dc'],
            labelL=None,
            label2L=None)

        self.mySprSht.setY2range(50, 550)
        self.mySprSht.save(filename=os.path.join(here, 'alt_y2'))

    def test_logx_save(self):
        """Check that save operates cleanly"""
        list_of_rows = ALT_DATA

        self.mySprSht.add_sheet('Alt_Data', list_of_rows)
        self.mySprSht.add_scatter('Alt_Plot',
                                  'Alt_Data',
                                  title='Unittest Title',
                                  xlabel='Unittest X Axis',
                                  ylabel='Unittest Y Axis',
                                  y2label='Unittest Y2 Axis',
                                  xcol=1,
                                  logx=True,
                                  ycolL=[3, 4],
                                  ycol2L=None,
                                  showMarkerL=[1, 1, 1],
                                  showMarker2L=None,
                                  colorL=None,
                                  labelL=None,
                                  label2L=None)

        self.mySprSht.save(filename=os.path.join(here, 'alt_logx'))

    def test_logy_save(self):
        """Check that save operates cleanly"""
        list_of_rows = ALT_DATA

        self.mySprSht.add_sheet('Alt_Data', list_of_rows)
        self.mySprSht.add_scatter('Alt_Plot',
                                  'Alt_Data',
                                  title='Unittest Title',
                                  xlabel='Unittest X Axis',
                                  ylabel='Unittest Y Axis',
                                  y2label='Unittest Y2 Axis',
                                  xcol=1,
                                  logy=True,
                                  ycolL=[3, 4],
                                  ycol2L=None,
                                  showMarkerL=[1, 1, 1],
                                  showMarker2L=None,
                                  colorL=None,
                                  labelL=None,
                                  label2L=None)

        self.mySprSht.save(filename=os.path.join(here, 'alt_logy'))

    def test_log2y_save(self):
        """Check that save operates for a second y axis"""
        list_of_rows = ALT_DATA_WIDE

        self.mySprSht.add_sheet('Alt_Data', list_of_rows)
        self.mySprSht.add_scatter('Alt_Plot',
                                  'Alt_Data',
                                  title='Unittest Title',
                                  xlabel='Unittest X Axis',
                                  ylabel='Unittest Y Axis',
                                  y2label='Unittest Y2 Axis',
                                  xcol=1,
                                  log2y=True,
                                  ycolL=[2, 5, 6],
                                  ycol2L=[3, 4],
                                  showMarkerL=[1, 1, 1],
                                  showMarker2L=None,
                                  colorL=None,
                                  labelL=None,
                                  label2L=None)

        self.mySprSht.save(filename=os.path.join(here, 'alt_log2y'))

    def test_all_log_save(self):
        """Check that save operates for a second y axis"""
        list_of_rows = ALT_DATA_WIDE

        self.mySprSht.add_sheet('Alt_Data', list_of_rows)
        self.mySprSht.add_scatter('Alt_Plot',
                                  'Alt_Data',
                                  title='Unittest Title',
                                  xlabel='Unittest X Axis',
                                  ylabel='Unittest Y Axis',
                                  y2label='Unittest Y2 Axis',
                                  xcol=1,
                                  log2y=True,
                                  logx=True,
                                  logy=True,
                                  ycolL=[2, 5, 6],
                                  ycol2L=[3, 4],
                                  showMarkerL=[1, 1, 1],
                                  showMarker2L=None,
                                  colorL=None,
                                  labelL=None,
                                  label2L=None)

        self.mySprSht.save(filename=os.path.join(here, 'alt_all_log'))
Beispiel #2
0
mySprSht = SpreadSheet()
rev_orderL = list(range(10, -1, -1))

toprow = ['Line Style Index']
unitsrow = ['']
toprow.extend(['%i) %s' % (i, sL[i]) for i in rev_orderL])
unitsrow.extend(['' for i in rev_orderL])

xbegrow = [0]
xbegrow.extend([i for i in rev_orderL])
xendrow = [1]
xendrow.extend([i for i in rev_orderL])

list_of_rows = [toprow, unitsrow, xbegrow, xendrow]

mySprSht.add_sheet('Line_Style_Data', list_of_rows)

mySprSht.add_scatter('Line_Style',
                     'Line_Style_Data',
                     title='Line Styles',
                     xlabel='',
                     ylabel='Index of Line Style',
                     xcol=1,
                     ycolL=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
                     lineStyleL=[i for i in rev_orderL],
                     lineThkL=[1.5],
                     showMarkerL=[0])

mySprSht.setYrange(ymin=-1, ymax=None, plot_sheetname=None)
mySprSht.save(filename='line_style_plot', launch=True)
Beispiel #3
0
from odscharts.line_styles import LINE_STYLE_LIST as sL

mySprSht = SpreadSheet()
rev_orderL = list( range(10,-1,-1) )

toprow = ['Line Style Index']
unitsrow = ['']
toprow.extend( ['%i) %s'%(i,sL[i]) for i in rev_orderL] )
unitsrow.extend( ['' for i in rev_orderL] )

xbegrow = [0]
xbegrow.extend( [i for i in rev_orderL] )
xendrow = [1]
xendrow.extend( [i for i in rev_orderL] )

list_of_rows = [toprow, unitsrow, xbegrow, xendrow]

mySprSht.add_sheet('Line_Style_Data', list_of_rows)

mySprSht.add_scatter( 'Line_Style', 'Line_Style_Data',
                          title='Line Styles', 
                          xlabel='', 
                          ylabel='Index of Line Style', 
                          xcol=1,
                          ycolL=[2,3,4,5,6,7,8,9,10,11,12], 
                          lineStyleL=[i for i in rev_orderL],
                          lineThkL = [1.5],
                          showMarkerL=[0])

mySprSht.setYrange( ymin=-1, ymax=None, plot_sheetname=None)
mySprSht.save( filename='line_style_plot', launch=True)
Beispiel #4
0
                     ylabel='Percent of Aussie Population',
                     y2label='Percent of USA Population',
                     xcol=1,
                     ycolL=[2, 3, 4],
                     showMarkerL=[
                         0,
                     ],
                     lineStyleL=[
                         1,
                     ],
                     lineThkL=[
                         2,
                     ],
                     colorL=['r', 'g', 'b'])

mySprSht.add_curve('Combo2_Plot',
                   'USA_Data',
                   xcol=1,
                   ycol2L=[2, 3, 4],
                   showMarker2L=[
                       0,
                   ],
                   lineThk2L=[
                       2,
                   ],
                   color2L=['r', 'g', 'b'])

mySprSht.setYrange(ymin=0, ymax=80, plot_sheetname=None)
mySprSht.setY2range(ymin=0, ymax=80, plot_sheetname=None)
mySprSht.save(filename='bmi_index.ods', launch=True)
Beispiel #5
0
mySprSht.add_curve('Combo_Plot', 'Aussie_Data', 
                    xcol=1,
                    ycolL=[2,3,4],
                    showMarkerL=[0,],
                    lineStyleL=[1,],
                    lineThkL=[2,],
                    colorL=['r','g','b'])


mySprSht.add_scatter( 'Combo2_Plot', 'Aussie_Data',
                       title='Australian and USA BMI', xlabel='Year', 
                       ylabel='Percent of Aussie Population',
                       y2label='Percent of USA Population',
                       xcol=1,
                       ycolL=[2,3,4],
                       showMarkerL=[0,],
                       lineStyleL=[1,],
                       lineThkL=[2,],
                       colorL=['r','g','b'])
                          
mySprSht.add_curve('Combo2_Plot', 'USA_Data', 
                    xcol=1,
                    ycol2L=[2,3,4],
                    showMarker2L=[0,],
                    lineThk2L=[2,],
                    color2L=['r','g','b'])

mySprSht.setYrange(  ymin=0, ymax=80, plot_sheetname=None)
mySprSht.setY2range( ymin=0, ymax=80, plot_sheetname=None)
mySprSht.save( filename='bmi_index.ods', launch=True )