Ignore:
Timestamp:
Jan 9, 2017 9:49:16 AM (8 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/GuiUtilsTest.py

    r27313b7 rb46f285  
    346346        self.assertFalse(os.path.isfile(file_name)) 
    347347 
     348    def testXYTransform(self): 
     349        """ Assure the unit/legend transformation is correct""" 
     350        data = Data1D(x=[1.0, 2.0, 3.0], y=[10.0, 11.0, 12.0], 
     351                      dx=[0.1, 0.2, 0.3], dy=[0.1, 0.2, 0.3]) 
     352 
     353        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="y") 
     354        self.assertEqual(xLabel, "()") 
     355        self.assertEqual(xscale, "linear") 
     356        self.assertEqual(yscale, "linear") 
     357 
     358        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x^(2)", yLabel="1/y") 
     359        self.assertEqual(xLabel, "^{2}(()^{2})") 
     360        self.assertEqual(yLabel, "1/(()^{-1})") 
     361        self.assertEqual(xscale, "linear") 
     362        self.assertEqual(yscale, "linear") 
     363 
     364        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x^(4)", yLabel="ln(y)") 
     365        self.assertEqual(xLabel, "^{4}(()^{4})") 
     366        self.assertEqual(yLabel, "\\ln{()}()") 
     367        self.assertEqual(xscale, "linear") 
     368        self.assertEqual(yscale, "linear") 
     369 
     370        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="ln(x)", yLabel="y^(2)") 
     371        self.assertEqual(xLabel, "\\ln{()}()") 
     372        self.assertEqual(yLabel, "^{2}(()^{2})") 
     373        self.assertEqual(xscale, "linear") 
     374        self.assertEqual(yscale, "linear") 
     375 
     376        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="log10(x)", yLabel="y*x^(2)") 
     377        self.assertEqual(xLabel, "()") 
     378        self.assertEqual(yLabel, " \\ \\ ^{2}(()^{2})") 
     379        self.assertEqual(xscale, "log") 
     380        self.assertEqual(yscale, "linear") 
     381 
     382        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="log10(x^(4))", yLabel="y*x^(4)") 
     383        self.assertEqual(xLabel, "^{4}(()^{4})") 
     384        self.assertEqual(yLabel, " \\ \\ ^{4}(()^{16})") 
     385        self.assertEqual(xscale, "log") 
     386        self.assertEqual(yscale, "linear") 
     387 
     388        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="1/sqrt(y)") 
     389        self.assertEqual(yLabel, "1/\\sqrt{}(()^{-0.5})") 
     390        self.assertEqual(yscale, "linear") 
     391 
     392        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="log10(y)") 
     393        self.assertEqual(yLabel, "()") 
     394        self.assertEqual(yscale, "log") 
     395 
     396        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="ln(y*x)") 
     397        self.assertEqual(yLabel, "\\ln{( \\ \\ )}()") 
     398        self.assertEqual(yscale, "linear") 
     399 
     400        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="ln(y*x^(2))") 
     401        self.assertEqual(yLabel, "\\ln ( \\ \\ ^{2})(()^{2})") 
     402        self.assertEqual(yscale, "linear") 
     403 
     404        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="ln(y*x^(4))") 
     405        self.assertEqual(yLabel, "\\ln ( \\ \\ ^{4})(()^{4})") 
     406        self.assertEqual(yscale, "linear") 
     407 
     408        xLabel, yLabel, xscale, yscale = xyTransform(data, xLabel="x", yLabel="log10(y*x^(4))") 
     409        self.assertEqual(yLabel, " \\ \\ ^{4}(()^{4})") 
     410        self.assertEqual(yscale, "log") 
     411 
    348412class FormulaValidatorTest(unittest.TestCase): 
    349413    """ Test the formula validator """ 
Note: See TracChangeset for help on using the changeset viewer.