Changeset b6627d9 in sasview


Ignore:
Timestamp:
Mar 4, 2015 1:02:23 PM (9 years ago)
Author:
Doucet, Mathieu <doucetm@…>
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:
7cd87c2
Parents:
5a7d933
Message:

pylint fixes

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • build_tools/pylint.rc

    r1128bd31 rb6627d9  
    5757 
    5858# Disable the message(s) with the given id(s). 
    59 disable=W0702,W0613,W0703,W0142 
     59disable=W0702,W0613,W0703,W0142,R0201 
    6060 
    6161[REPORTS] 
  • src/sas/calculator/instrument.py

    r26500ec rb6627d9  
    8585        """ 
    8686        if len(size) == 0: 
    87             self.sample_size = 0.0 
    88         else: 
    89             self.sample_size = size 
     87            self.size = 0.0 
     88        else: 
     89            self.size = size 
    9090            validate(size[0]) 
    9191 
  • src/sas/calculator/resolution_calculator.py

    r6bd3a8d1 rb6627d9  
    1313import math 
    1414import numpy 
     15import sys 
     16import logging 
    1517 
    1618#Plank's constant in cgs unit 
     
    7779        self.detector_pix_size = [] 
    7880        self.detector_size = [] 
    79         # get all the values of the instrumental parameters 
    80         #self.intensity = self.get_intensity() 
    81         #self.wavelength = self.get_wavelength() 
    82         #self.wavelength_spread = self.get_wavelength_spread() 
    8381        self.get_all_instrument_params() 
    8482        # max q range for all lambdas 
     
    8785 
    8886    def compute_and_plot(self, qx_value, qy_value, qx_min, qx_max, 
    89                           qy_min, qy_max, coord='cartesian'): 
     87                         qy_min, qy_max, coord='cartesian'): 
    9088        """ 
    9189        Compute the resolution 
     
    120118            # make image 
    121119            image = self.get_image(qx_value, qy_value, sigma_1, sigma_2, 
    122                             sigma_r, qx_min, qx_max, qy_min, qy_max, 
    123                             coord, False) 
     120                                   sigma_r, qx_min, qx_max, qy_min, qy_max, 
     121                                   coord, False) 
    124122            if qx_min > self.qx_min: 
    125123                qx_min = self.qx_min 
     
    150148            intens = self.setup_tof(lam, dlam) 
    151149            out = self.get_image(qx_value, qy_value, sig1_list[ind], 
    152                                    sig2_list[ind], sigr_list[ind], 
    153                                    qx_min, qx_max, qy_min, qy_max, coord) 
     150                                 sig2_list[ind], sigr_list[ind], 
     151                                 qx_min, qx_max, qy_min, qy_max, coord) 
    154152            # this is the case of q being outside the detector 
    155153            #if numpy.all(out==0.0): 
     
    272270        # sigma in the radial/x direction 
    273271        # for source aperture 
    274         sigma_1  = self.get_variance(rone, l1_cor, phi, comp1) 
     272        sigma_1 = self.get_variance(rone, l1_cor, phi, comp1) 
    275273        # for sample apperture 
    276274        sigma_1 += self.get_variance(rtwo, lp_cor, phi, comp1) 
     
    279277        # for gravity term for 1d 
    280278        sigma_1grav1d = self.get_variance_gravity(l_ssa, l_sad, lamb, 
    281                             lamb_spread, phi, comp1, 'on') / tof_factor 
     279                                                  lamb_spread, phi, comp1, 'on') / tof_factor 
    282280        # for wavelength spread 
    283281        # reserve for 1d calculation 
    284282        A_value = self._cal_A_value(lamb, l_ssa, l_sad) 
    285283        sigma_wave_1, sigma_wave_1_1d = self.get_variance_wave(A_value, 
    286                                           radius, l_two, lamb_spread, 
    287                                           phi, 'radial', 'on') 
     284                                                               radius, l_two, lamb_spread, 
     285                                                               phi, 'radial', 'on') 
    288286        sigma_wave_1 /= tof_factor 
    289287        sigma_wave_1_1d /= tof_factor 
     
    300298        # sigma in the phi/y direction 
    301299        # for source apperture 
    302         sigma_2  = self.get_variance(rone, l1_cor, phi, comp2) 
     300        sigma_2 = self.get_variance(rone, l1_cor, phi, comp2) 
    303301 
    304302        # for sample apperture 
     
    310308        # for gravity term for 1d 
    311309        sigma_2grav1d = self.get_variance_gravity(l_ssa, l_sad, lamb, 
    312                                 lamb_spread, phi, comp2, 'on') / tof_factor 
     310                                                  lamb_spread, phi, comp2, 'on') / tof_factor 
    313311 
    314312        # for wavelength spread 
    315313        # reserve for 1d calculation 
    316314        sigma_wave_2, sigma_wave_2_1d = self.get_variance_wave(A_value, 
    317                                           radius, l_two, lamb_spread, 
    318                                           phi, 'phi', 'on') 
     315                                                               radius, l_two, lamb_spread, 
     316                                                               phi, 'phi', 'on') 
    319317        sigma_wave_2 /= tof_factor 
    320318        sigma_wave_2_1d /= tof_factor 
     
    377375 
    378376        # Check whether the q value is within the detector range 
    379         #msg = "Invalid input: Q value out of the detector range..." 
    380377        if qx_min < self.qx_min: 
    381378            self.qx_min = qx_min 
     
    409406            # Calculate the 2D Gaussian distribution image 
    410407            image = self._gaussian2d_polar(q_1, q_2, qc_1, qc_2, 
    411                                  sigma_1, sigma_2, sigma_r) 
     408                                           sigma_1, sigma_2, sigma_r) 
    412409        else: 
    413410            # catesian coordinate 
     
    452449        # Image 
    453450        im = plt.imshow(image, 
    454                 extent=[qx_min, qx_max, qy_min, qy_max]) 
     451                        extent=[qx_min, qx_max, qy_min, qy_max]) 
    455452 
    456453        # bilinear interpolation to make it smoother 
     
    506503            raise ValueError, " Improper input..." 
    507504        # get them squared 
    508         sigma  = x_comp * x_comp 
     505        sigma = x_comp * x_comp 
    509506        sigma += y_comp * y_comp 
    510507        # normalize by distance 
     
    918915 
    919916    def _gaussian2d_polar(self, x_val, y_val, x0_val, y0_val, 
    920                         sigma_x, sigma_y, sigma_r): 
     917                          sigma_x, sigma_y, sigma_r): 
    921918        """ 
    922919        Calculate 2D Gaussian distribution for polar coodinate 
     
    933930        sigma_x = sqrt(sigma_x * sigma_x + sigma_r * sigma_r) 
    934931        # call gaussian1d 
    935         gaussian  = self._gaussian1d(x_val, x0_val, sigma_x) 
     932        gaussian = self._gaussian1d(x_val, x0_val, sigma_x) 
    936933        gaussian *= self._gaussian1d(y_val, y0_val, sigma_y) 
    937934 
     
    974971        phi = math.atan2(qy_value, qx_value) 
    975972        return phi 
    976         # default 
    977         phi = 0 
    978         # ToDo: This is misterious - sign??? 
    979         #qy_value = -qy_value 
    980         # Take care of the singular point 
    981         if qx_value == 0: 
    982             if qy_value > 0: 
    983                 phi = pi / 2 
    984             elif qy_value < 0: 
    985                 phi = -pi / 2 
    986             else: 
    987                 phi = 0 
    988         else: 
    989             # the angle 
    990             phi = math.atan2(qy_value, qx_value) 
    991  
    992         return phi 
    993973 
    994974    def _get_detector_qxqy_pixels(self): 
     
    10261006            detector_offset = self.sample2detector_distance[1] 
    10271007        except: 
    1028             pass 
     1008            logging.error(sys.exc_value) 
    10291009 
    10301010        # detector size in [no of pix_x,no of pix_y] 
     
    10431023        # beam center position in pix number (start from 0) 
    10441024        center_x, center_y = self._get_beamcenter_position(detector_pix_nums_x, 
    1045                                     detector_pix_nums_y, offset_x, offset_y) 
     1025                                                           detector_pix_nums_y, 
     1026                                                           offset_x, offset_y) 
    10461027        # distance [cm] from the beam center on detector plane 
    10471028        detector_ind_x = numpy.arange(detector_pix_nums_x) 
     
    10881069        # i.e., edges of the last pixels. 
    10891070        self.qy_min += self._get_qx(-0.5 * pix_y_size, 
    1090                                 sample2detector_distance, wavelength) 
     1071                                    sample2detector_distance, wavelength) 
    10911072        self.qy_max += self._get_qx(0.5 * pix_y_size, 
    1092                                 sample2detector_distance, wavelength) 
     1073                                    sample2detector_distance, wavelength) 
    10931074        #if self.qx_min == self.qx_max: 
    10941075        self.qx_min += self._get_qx(-0.5 * pix_x_size, 
    1095                                 sample2detector_distance, wavelength) 
     1076                                    sample2detector_distance, wavelength) 
    10961077        self.qx_max += self._get_qx(0.5 * pix_x_size, 
    10971078                                    sample2detector_distance, wavelength) 
     
    11081089            output = Data2D() 
    11091090            inten = numpy.zeros_like(qx_value) 
    1110             output.data    = inten 
     1091            output.data = inten 
    11111092            output.qx_data = qx_value 
    11121093            output.qy_data = qy_value 
    11131094        except: 
    1114             pass 
     1095            logging.error(sys.exc_value) 
    11151096 
    11161097        return output 
  • src/sas/calculator/sas_gen.py

    re3f77d8b rb6627d9  
     1# pylint: disable=invalid-name 
    12""" 
    23SAS generic computation and sld file readers 
     
    910import os 
    1011import copy 
     12import sys 
     13import logging 
    1114 
    1215MFACTOR_AM = 2.853E-12 
     
    285288                mask = (x_dir2 + y_dir2 + z_dir2) <= 1.0 
    286289            except: 
    287                 pass 
     290                logging.error(sys.exc_value) 
    288291        self.output = MagSLD(self.pos_x[mask], self.pos_y[mask], 
    289292                             self.pos_z[mask], self.sld_n[mask], 
     
    394397                except: 
    395398                    # Skip non-data lines 
    396                     pass 
     399                    logging.error(sys.exc_value) 
    397400                #Reading Header; Segment count ignored 
    398401                s_line = line.split(":", 1) 
     
    589592                        z_lines.append(z_line) 
    590593                except: 
    591                     pass 
     594                    logging.error(sys.exc_value) 
    592595 
    593596            output = MagSLD(pos_x, pos_y, pos_z, sld_n, sld_mx, sld_my, sld_mz) 
     
    683686                    except: 
    684687                        # Skip non-data lines 
    685                         pass 
     688                        logging.error(sys.exc_value) 
    686689            output = MagSLD(pos_x, pos_y, pos_z, sld_n, 
    687690                            sld_mx, sld_my, sld_mz) 
     
    10371040 
    10381041def test_load(): 
     1042    """ 
     1043        Test code 
     1044    """ 
    10391045    from sas.plottools.arrow3d import Arrow3D 
    10401046    current_dir = os.path.abspath(os.path.curdir) 
     
    10831089    ax.add_artist(a) 
    10841090    plt.show() 
     1091 
    10851092def test(): 
     1093    """ 
     1094        Test code 
     1095    """ 
    10861096    current_dir = os.path.abspath(os.path.curdir) 
    10871097    for i in range(3): 
  • src/sas/calculator/slit_length_calculator.py

    r6bd3a8d1 rb6627d9  
    5757 
    5858        # sum 10 or more y values until getting max_y, 
    59         while (True): 
     59        while True: 
    6060            if ind >= 10 and y_max == max_y: 
    6161                break 
     
    7272        ind = 0.0 
    7373        # find indices where it crosses y = y_half. 
    74         while (True): 
     74        while True: 
    7575            # no need to check when ind == 0 
    7676            ind += 1 
Note: See TracChangeset for help on using the changeset viewer.