Ignore:
Timestamp:
Jan 9, 2017 9:49:16 AM (7 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
87cc73a
Parents:
a66ff280
Message:

Unit tests for linear fit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/UnitTesting/PlotterTest.py

    raadf0af1 rb46f285  
    6969        self.assertTrue(FigureCanvas.draw.called) 
    7070 
    71     def testContextMenuQuickPlot(self): 
     71    def testCreateContextMenuQuick(self): 
    7272        """ Test the right click menu """ 
    7373        self.plotter.createContextMenuQuick() 
     
    112112        self.assertTrue(self.plotter.properties.exec_.called) 
    113113 
    114     def testXYTransform(self): 
    115         """ Assure the unit/legend transformation is correct""" 
    116         self.plotter.plot(self.data) 
    117  
    118         self.plotter.xyTransform(xLabel="x", yLabel="y") 
     114    def testXyTransform(self): 
     115        """ Tests the XY transformation and new chart update """ 
     116        self.plotter.plot(self.data) 
     117 
     118        # Transform the points 
     119        self.plotter.xyTransform(xLabel="x", yLabel="log10(y)") 
     120 
     121        # Assure new plot has correct labels 
    119122        self.assertEqual(self.plotter.ax.get_xlabel(), "$()$") 
    120123        self.assertEqual(self.plotter.ax.get_ylabel(), "$()$") 
    121  
    122         self.plotter.xyTransform(xLabel="x^(2)", yLabel="1/y") 
    123         self.assertEqual(self.plotter.ax.get_xlabel(), "$^{2}(()^{2})$") 
    124         self.assertEqual(self.plotter.ax.get_ylabel(), "$1/(()^{-1})$") 
    125  
    126         self.plotter.xyTransform(xLabel="x^(4)", yLabel="ln(y)") 
    127         self.assertEqual(self.plotter.ax.get_xlabel(), "$^{4}(()^{4})$") 
    128         self.assertEqual(self.plotter.ax.get_ylabel(), "$\\ln{()}()$") 
    129  
    130         self.plotter.xyTransform(xLabel="ln(x)", yLabel="y^(2)") 
    131         self.assertEqual(self.plotter.ax.get_xlabel(), "$\\ln{()}()$") 
    132         self.assertEqual(self.plotter.ax.get_ylabel(), "$^{2}(()^{2})$") 
    133  
    134         self.plotter.xyTransform(xLabel="log10(x)", yLabel="y*x^(2)") 
    135         self.assertEqual(self.plotter.ax.get_xlabel(), "$()$") 
    136         self.assertEqual(self.plotter.ax.get_ylabel(), "$ \\ \\ ^{2}(()^{2})$") 
    137  
    138         self.plotter.xyTransform(xLabel="log10(x^(4))", yLabel="y*x^(4)") 
    139         self.assertEqual(self.plotter.ax.get_xlabel(), "$^{4}(()^{4})$") 
    140         self.assertEqual(self.plotter.ax.get_ylabel(), "$ \\ \\ ^{4}(()^{16})$") 
    141  
    142         self.plotter.xyTransform(xLabel="x", yLabel="1/sqrt(y)") 
    143         self.assertEqual(self.plotter.ax.get_ylabel(), "$1/\\sqrt{}(()^{-0.5})$") 
    144  
    145         self.plotter.xyTransform(xLabel="x", yLabel="log10(y)") 
    146         self.assertEqual(self.plotter.ax.get_ylabel(), "$()$") 
    147  
    148         self.plotter.xyTransform(xLabel="x", yLabel="ln(y*x)") 
    149         self.assertEqual(self.plotter.ax.get_ylabel(), "$\\ln{( \\ \\ )}()$") 
    150  
    151         self.plotter.xyTransform(xLabel="x", yLabel="ln(y*x^(2))") 
    152         self.assertEqual(self.plotter.ax.get_ylabel(), "$\\ln ( \\ \\ ^{2})(()^{2})$") 
    153  
    154         self.plotter.xyTransform(xLabel="x", yLabel="ln(y*x^(4))") 
    155         self.assertEqual(self.plotter.ax.get_ylabel(), "$\\ln ( \\ \\ ^{4})(()^{4})$") 
    156  
    157         self.plotter.xyTransform(xLabel="x", yLabel="log10(y*x^(4))") 
    158         self.assertEqual(self.plotter.ax.get_ylabel(), "$ \\ \\ ^{4}(()^{4})$") 
     124        # ... and scale 
     125        self.assertEqual(self.plotter.xscale, "linear") 
     126        self.assertEqual(self.plotter.yscale, "log") 
     127        # See that just one plot is present 
     128        self.assertEqual(len(self.plotter.plot_dict), 1) 
     129        self.assertEqual(len(self.plotter.ax.collections), 1) 
    159130 
    160131    def testAddText(self): 
     
    250221        self.assertNotEqual(self.plotter.ax.get_ylim(), new_y) 
    251222 
     223    def testOnLinearFit(self): 
     224        """ Checks the response to LinearFit call """ 
     225        pass 
     226 
     227    def testOnRemovePlot(self): 
     228        """ Assure plots get removed when requested """ 
     229        pass 
     230 
     231    def testRemovePlot(self): 
     232        """ Test plot removal """ 
     233        pass 
     234 
     235    def testOnToggleHideError(self): 
     236        """ Test the error bar toggle on plots """ 
     237        pass 
     238 
     239    def testOnFitDisplay(self): 
     240        """ Test the fit line display on the chart """ 
     241        pass 
     242 
    252243if __name__ == "__main__": 
    253244    unittest.main() 
Note: See TracChangeset for help on using the changeset viewer.