Changeset 1e96a66 in sasview


Ignore:
Timestamp:
Dec 7, 2010 5:43:12 PM (14 years ago)
Author:
Gervaise Alina <gervyh@…>
Branches:
master, 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
1aaa579
Parents:
a1f2002
Message:

edit unittest

Location:
calculatorview
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • calculatorview/perspectives/calculator/sld_panel.py

    r66bfacf r1e96a66  
    5959        self.density_ctl = None 
    6060        self.wavelength_ctl = None 
    61         self.neutron_sld_reel_ctl = None 
     61        self.neutron_sld_real_ctl = None 
    6262        self.neutron_sld_im_ctl = None 
    63         self.mo_ka_sld_reel_ctl = None 
     63        self.mo_ka_sld_real_ctl = None 
    6464        self.mo_ka_sld_im_ctl = None 
    65         self.cu_ka_sld_reel_ctl = None 
     65        self.cu_ka_sld_real_ctl = None 
    6666        self.cu_ka_sld_im_ctl = None 
    6767        self.neutron_abs_ctl = None 
     
    139139        i_complex = '- i' 
    140140        neutron_sld_txt = wx.StaticText(self, -1, 'Neutron SLD') 
    141         self.neutron_sld_reel_ctl = wx.TextCtrl(self, -1, 
     141        self.neutron_sld_real_ctl = wx.TextCtrl(self, -1, 
    142142                                                 size=(_BOX_WIDTH, -1)) 
    143         self.neutron_sld_reel_ctl.SetEditable(False) 
    144         self.neutron_sld_reel_ctl.SetToolTipString("Neutron SLD real.") 
     143        self.neutron_sld_real_ctl.SetEditable(False) 
     144        self.neutron_sld_real_ctl.SetToolTipString("Neutron SLD real.") 
    145145        self.neutron_sld_im_ctl = wx.TextCtrl(self, -1,  
    146146                                              size=(_BOX_WIDTH, -1)) 
     
    150150         
    151151        cu_ka_sld_txt = wx.StaticText(self, -1, 'Cu Ka SLD') 
    152         self.cu_ka_sld_reel_ctl = wx.TextCtrl(self, -1, 
     152        self.cu_ka_sld_real_ctl = wx.TextCtrl(self, -1, 
    153153                                               size=(_BOX_WIDTH, -1)) 
    154         self.cu_ka_sld_reel_ctl.SetEditable(False) 
    155         self.cu_ka_sld_reel_ctl.SetToolTipString("Cu Ka SLD real.") 
     154        self.cu_ka_sld_real_ctl.SetEditable(False) 
     155        self.cu_ka_sld_real_ctl.SetToolTipString("Cu Ka SLD real.") 
    156156        self.cu_ka_sld_im_ctl = wx.TextCtrl(self, -1,  
    157157                                            size=(_BOX_WIDTH, -1)) 
     
    161161         
    162162        mo_ka_sld_txt = wx.StaticText(self, -1, 'Mo Ka SLD') 
    163         self.mo_ka_sld_reel_ctl = wx.TextCtrl(self, -1, 
     163        self.mo_ka_sld_real_ctl = wx.TextCtrl(self, -1, 
    164164                                               size=(_BOX_WIDTH, -1)) 
    165         self.mo_ka_sld_reel_ctl.SetEditable(False) 
    166         self.mo_ka_sld_reel_ctl.SetToolTipString("Mo Ka SLD real.") 
     165        self.mo_ka_sld_real_ctl.SetEditable(False) 
     166        self.mo_ka_sld_real_ctl.SetToolTipString("Mo Ka SLD real.") 
    167167        self.mo_ka_sld_im_ctl = wx.TextCtrl(self, -1, 
    168168                                             size=(_BOX_WIDTH, -1)) 
     
    197197                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    198198        ix += 1 
    199         sizer_output.Add(self.neutron_sld_reel_ctl, (iy, ix), (1, 1), 
     199        sizer_output.Add(self.neutron_sld_real_ctl, (iy, ix), (1, 1), 
    200200                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    201201        ix += 1 
     
    213213                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    214214        ix += 1 
    215         sizer_output.Add(self.cu_ka_sld_reel_ctl, (iy, ix), (1, 1), 
     215        sizer_output.Add(self.cu_ka_sld_real_ctl, (iy, ix), (1, 1), 
    216216                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    217217        ix += 1 
     
    229229                             wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
    230230        ix += 1 
    231         sizer_output.Add(self.mo_ka_sld_reel_ctl,(iy, ix), (1, 1), 
     231        sizer_output.Add(self.mo_ka_sld_real_ctl,(iy, ix), (1, 1), 
    232232                            wx.EXPAND|wx.ADJUST_MINSIZE, 0)  
    233233        ix += 1 
     
    393393            # set neutron sld values 
    394394            val = format_number(sld_real * _SCALE) 
    395             self.neutron_sld_reel_ctl.SetValue(val) 
     395            self.neutron_sld_real_ctl.SetValue(val) 
    396396            val = format_number(math.fabs(sld_im) * _SCALE) 
    397397            self.neutron_sld_im_ctl.SetValue(val) 
    398398            # Compute the Cu SLD 
    399             self.cu_ka_sld_reel_ctl.SetValue(format_number(cu_real *_SCALE)) 
     399            self.cu_ka_sld_real_ctl.SetValue(format_number(cu_real *_SCALE)) 
    400400            val = format_number(math.fabs(cu_im )* _SCALE) 
    401401            self.cu_ka_sld_im_ctl.SetValue(val) 
    402402            # Compute the Mo SLD 
    403             self.mo_ka_sld_reel_ctl.SetValue(format_number(mo_real *_SCALE)) 
     403            self.mo_ka_sld_real_ctl.SetValue(format_number(mo_real *_SCALE)) 
    404404            val = format_number(math.fabs(mo_im)* _SCALE) 
    405405            self.mo_ka_sld_im_ctl.SetValue(val) 
     
    422422        Clear the outputs textctrl 
    423423        """ 
    424         self.neutron_sld_reel_ctl.SetValue("") 
     424        self.neutron_sld_real_ctl.SetValue("") 
    425425        self.neutron_sld_im_ctl.SetValue("") 
    426         self.mo_ka_sld_reel_ctl.SetValue("") 
     426        self.mo_ka_sld_real_ctl.SetValue("") 
    427427        self.mo_ka_sld_im_ctl.SetValue("") 
    428         self.cu_ka_sld_reel_ctl.SetValue("") 
     428        self.cu_ka_sld_real_ctl.SetValue("") 
    429429        self.cu_ka_sld_im_ctl.SetValue("") 
    430430        self.neutron_abs_ctl.SetValue("") 
  • calculatorview/test/utest_gui_sld.py

    r66bfacf r1e96a66  
    9292        self.sld_frame.panel.wavelength_ctl.SetValue("") 
    9393        self.sld_frame.panel.ProcessEvent(clickEvent) 
    94         bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 
     94        cp_bkg = self.sld_frame.panel.compound_ctl.GetBackgroundColour() 
     95        self.assert_(cp_bkg.GetAsString() == 'white') 
     96        ds_bkg = self.sld_frame.panel.density_ctl.GetBackgroundColour() 
     97        self.assert_(ds_bkg.GetAsString() == 'white') 
     98        wv_bkg = self.sld_frame.panel.wavelength_ctl.GetBackgroundColour() 
    9599        value = self.sld_frame.panel.wavelength_ctl.GetValue() 
    96         self.assert_(bkg.GetAsString() == 'white') 
     100        self.assert_(wv_bkg.GetAsString() == 'white') 
    97101        self.assert_(float(value) == WAVELENGTH) 
     102        sld_real = self.sld_frame.panel.neutron_sld_real_ctl.GetValue() 
     103        sld_im = self.sld_frame.panel.neutron_sld_im_ctl.GetValue() 
     104        mo_real = self.sld_frame.panel.mo_ka_sld_real_ctl.GetValue() 
     105        mo_im = self.sld_frame.panel.mo_ka_sld_im_ctl.GetValue() 
     106        cu_real = self.sld_frame.panel.cu_ka_sld_real_ctl.GetValue() 
     107        cu_im = self.sld_frame.panel.cu_ka_sld_im_ctl.GetValue() 
     108        abs = self.sld_frame.panel.neutron_abs_ctl.GetValue() 
     109        incoh = self.sld_frame.panel.neutron_inc_ctl.GetValue() 
     110        length = self.sld_frame.panel.neutron_length_ctl.GetValue() 
     111         
     112        self.assertAlmostEquals(float(sld_real), 1.04e-6, 1) 
     113        self.assertAlmostEquals(float(sld_im), -1.5e-7, 1) 
     114        #test absorption value 
     115        self.assertAlmostEquals(float(abs) , 0.0741, 2) 
     116        self.assertAlmostEquals(float(incoh), 5.62, 2) 
     117        #Test length 
     118        self.assertAlmostEquals(float(length), 0.1755, 2) 
     119        #test Cu sld 
     120        self.assertAlmostEquals(float(cu_real), 9.46e-6, 1) 
     121        self.assertAlmostEquals(float(cu_im), 3.01e-8) 
     122        # test Mo sld 
     123        self.assertAlmostEquals(float(mo_real), 9.43e-6) 
     124        self.assertAlmostEquals(float(mo_im), 5.65e-7, 1) 
    98125        #compute invariant with all correct inputs value 
    99126        self.sld_frame.panel.compound_ctl.SetValue("H2O") 
  • calculatorview/test/utest_sld.py

    r66bfacf r1e96a66  
    4646        (sld_real,sld_im,sld_inc), (coh,abs,incoh), length = neutron_scattering(self.compound, 
    4747                                       density=self.density, wavelength=self.wavelength)  
    48         cu_reel, cu_im = calculate_xray_sld(element="Cu", density=self.density, 
     48        cu_real, cu_im = calculate_xray_sld(element="Cu", density=self.density, 
    4949                                  molecule_formula=self.sld_formula) 
    50         mo_reel, mo_im = calculate_xray_sld(element="Mo", density=self.density, 
     50        mo_real, mo_im = calculate_xray_sld(element="Mo", density=self.density, 
    5151                                  molecule_formula=self.sld_formula) 
    5252        #test sld  
     
    5959        self.assertAlmostEquals(length, 0.1755, 3) 
    6060        #test Cu sld 
    61         self.assertAlmostEquals(cu_reel * _SCALE, 9.46e-6, 1) 
     61        self.assertAlmostEquals(cu_real * _SCALE, 9.46e-6, 1) 
    6262        self.assertAlmostEquals(cu_im * _SCALE, 3.01e-8) 
    6363        # test Mo sld 
    64         self.assertAlmostEquals(mo_reel * _SCALE, 9.43e-6) 
     64        self.assertAlmostEquals(mo_real * _SCALE, 9.43e-6) 
    6565        self.assertAlmostEquals(mo_im * _SCALE, 5.65e-7,1) 
    6666     
     
    8686        (sld_real,sld_im,sld_inc), (coh,abs,incoh), length = neutron_scattering(self.compound, 
    8787                                       density=self.density, wavelength=self.wavelength)  
    88         cu_reel, cu_im = calculate_xray_sld(element="Cu", density=self.density, 
     88        cu_real, cu_im = calculate_xray_sld(element="Cu", density=self.density, 
    8989                                  molecule_formula=self.sld_formula) 
    90         mo_reel, mo_im = calculate_xray_sld(element="Mo", density=self.density, 
     90        mo_real, mo_im = calculate_xray_sld(element="Mo", density=self.density, 
    9191                                  molecule_formula=self.sld_formula) 
    9292        #test sld  
     
    9999        self.assertAlmostEquals(length, 1.549, 3) 
    100100        #test Cu sld 
    101         self.assertAlmostEquals(cu_reel * _SCALE, 9.36e-6, 1) 
     101        self.assertAlmostEquals(cu_real * _SCALE, 9.36e-6, 1) 
    102102        self.assertAlmostEquals(cu_im * _SCALE, 2.98e-8) 
    103103        # test Mo sld 
    104         self.assertAlmostEquals(mo_reel * _SCALE, 9.33e-6) 
     104        self.assertAlmostEquals(mo_real * _SCALE, 9.33e-6) 
    105105        self.assertAlmostEquals(mo_im * _SCALE, 5.59e-9,1) 
    106106     
     
    126126        (sld_real,sld_im,sld_inc), (coh,abs,incoh), length = neutron_scattering(self.compound, 
    127127                                density=self.density, wavelength=self.wavelength)  
    128         cu_reel, cu_im = calculate_xray_sld(element="Cu", density=self.density, 
     128        cu_real, cu_im = calculate_xray_sld(element="Cu", density=self.density, 
    129129                                  molecule_formula=self.sld_formula) 
    130         mo_reel, mo_im = calculate_xray_sld(element="Mo", density=self.density, 
     130        mo_real, mo_im = calculate_xray_sld(element="Mo", density=self.density, 
    131131                                  molecule_formula=self.sld_formula) 
    132132        #test sld  
     
    139139        self.assertAlmostEquals(length, 0.005551, 4) 
    140140        #test Cu sld 
    141         self.assertAlmostEquals(cu_reel * _SCALE, 2.89e-5, 1) 
     141        self.assertAlmostEquals(cu_real * _SCALE, 2.89e-5, 1) 
    142142        self.assertAlmostEquals(cu_im * _SCALE, 2.81e-6) 
    143143        # test Mo sld 
    144         self.assertAlmostEquals(mo_reel * _SCALE, 2.84e-5, 1) 
     144        self.assertAlmostEquals(mo_real * _SCALE, 2.84e-5, 1) 
    145145        self.assertAlmostEquals(mo_im * _SCALE, 7.26e-7,1) 
    146146   
Note: See TracChangeset for help on using the changeset viewer.