Changeset 235f514 in sasview for src/sas/sascalc/dataloader


Ignore:
Timestamp:
Apr 9, 2017 5:46:10 AM (7 years ago)
Author:
andyfaff
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.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
ac07a3a
Parents:
5b2b04d
Message:

MAINT: replace '== None' by 'is None'

Location:
src/sas/sascalc/dataloader
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/data_info.py

    r959eb01 r235f514  
    806806            # create zero vector 
    807807            dy_other = other.dy 
    808             if other.dy == None or (len(other.dy) != len(other.y)): 
     808            if other.dy is None or (len(other.dy) != len(other.y)): 
    809809                dy_other = np.zeros(len(other.y)) 
    810810 
    811811        # Check that we have errors, otherwise create zero vector 
    812812        dy = self.dy 
    813         if self.dy == None or (len(self.dy) != len(self.y)): 
     813        if self.dy is None or (len(self.dy) != len(self.y)): 
    814814            dy = np.zeros(len(self.y)) 
    815815 
     
    822822        dy, dy_other = self._validity_check(other) 
    823823        result = self.clone_without_data(len(self.x)) 
    824         if self.dxw == None: 
     824        if self.dxw is None: 
    825825            result.dxw = None 
    826826        else: 
    827827            result.dxw = np.zeros(len(self.x)) 
    828         if self.dxl == None: 
     828        if self.dxl is None: 
    829829            result.dxl = None 
    830830        else: 
     
    884884        self._validity_check_union(other) 
    885885        result = self.clone_without_data(len(self.x) + len(other.x)) 
    886         if self.dy == None or other.dy is None: 
     886        if self.dy is None or other.dy is None: 
    887887            result.dy = None 
    888888        else: 
    889889            result.dy = np.zeros(len(self.x) + len(other.x)) 
    890         if self.dx == None or other.dx is None: 
     890        if self.dx is None or other.dx is None: 
    891891            result.dx = None 
    892892        else: 
    893893            result.dx = np.zeros(len(self.x) + len(other.x)) 
    894         if self.dxw == None or other.dxw is None: 
     894        if self.dxw is None or other.dxw is None: 
    895895            result.dxw = None 
    896896        else: 
    897897            result.dxw = np.zeros(len(self.x) + len(other.x)) 
    898         if self.dxl == None or other.dxl is None: 
     898        if self.dxl is None or other.dxl is None: 
    899899            result.dxl = None 
    900900        else: 
     
    10301030            # Check that the scales match 
    10311031            err_other = other.err_data 
    1032             if other.err_data == None or \ 
     1032            if other.err_data is None or \ 
    10331033                (len(other.err_data) != len(other.data)): 
    10341034                err_other = np.zeros(len(other.data)) 
     
    10361036        # Check that we have errors, otherwise create zero vector 
    10371037        err = self.err_data 
    1038         if self.err_data == None or \ 
     1038        if self.err_data is None or \ 
    10391039            (len(self.err_data) != len(self.data)): 
    10401040            err = np.zeros(len(other.data)) 
     
    10511051        dy, dy_other = self._validity_check(other) 
    10521052        result = self.clone_without_data(np.size(self.data)) 
    1053         if self.dqx_data == None or self.dqy_data == None: 
     1053        if self.dqx_data is None or self.dqy_data is None: 
    10541054            result.dqx_data = None 
    10551055            result.dqy_data = None 
     
    11251125        result.ymin = self.ymin 
    11261126        result.ymax = self.ymax 
    1127         if self.dqx_data == None or self.dqy_data == None or \ 
    1128                 other.dqx_data == None or other.dqy_data == None: 
     1127        if self.dqx_data is None or self.dqy_data is None or \ 
     1128                other.dqx_data is None or other.dqy_data is None: 
    11291129            result.dqx_data = None 
    11301130            result.dqy_data = None 
  • src/sas/sascalc/dataloader/manipulations.py

    r959eb01 r235f514  
    210210            y[i_q] += frac * data[npts] 
    211211 
    212             if err_data == None or err_data[npts] == 0.0: 
     212            if err_data is None or err_data[npts] == 0.0: 
    213213                if data[npts] < 0: 
    214214                    data[npts] = -data[npts] 
     
    333333                continue 
    334334            y += frac * data[npts] 
    335             if err_data == None or err_data[npts] == 0.0: 
     335            if err_data is None or err_data[npts] == 0.0: 
    336336                if data[npts] < 0: 
    337337                    data[npts] = -data[npts] 
     
    462462 
    463463        #q_data_max = numpy.max(q_data) 
    464         if len(data2D.q_data) == None: 
     464        if len(data2D.q_data) is None: 
    465465            msg = "Circular averaging: invalid q_data: %g" % data2D.q_data 
    466466            raise RuntimeError, msg 
     
    502502            # Take dqs from data to get the q_average 
    503503            x[i_q] += frac * q_value 
    504             if err_data == None or err_data[npt] == 0.0: 
     504            if err_data is None or err_data[npt] == 0.0: 
    505505                if data_n < 0: 
    506506                    data_n = -data_n 
     
    623623            phi_bins[i_phi] += frac * data[npt] 
    624624 
    625             if err_data == None or err_data[npt] == 0.0: 
     625            if err_data is None or err_data[npt] == 0.0: 
    626626                if data_n < 0: 
    627627                    data_n = -data_n 
     
    888888            y[i_bin] += frac * data_n 
    889889            x[i_bin] += frac * q_value 
    890             if err_data[n] == None or err_data[n] == 0.0: 
     890            if err_data[n] is None or err_data[n] == 0.0: 
    891891                if data_n < 0: 
    892892                    data_n = -data_n 
  • src/sas/sascalc/dataloader/readers/ascii_reader.py

    r959eb01 r235f514  
    128128                        if new_lentoks > 2: 
    129129                            _dy = float(toks[2]) 
    130                         has_error_dy = False if _dy == None else True 
     130                        has_error_dy = False if _dy is None else True 
    131131 
    132132                        # If a 4th row is present, consider it dx 
    133133                        if new_lentoks > 3: 
    134134                            _dx = float(toks[3]) 
    135                         has_error_dx = False if _dx == None else True 
     135                        has_error_dx = False if _dx is None else True 
    136136 
    137137                        # Delete the previously stored lines of data candidates if 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r63d773c r235f514  
    807807        :param data1d: presumably a Data1D object 
    808808        """ 
    809         if self.current_dataset == None: 
     809        if self.current_dataset is None: 
    810810            x_vals = np.empty(0) 
    811811            y_vals = np.empty(0) 
     
    895895        # Write the file 
    896896        file_ref = open(filename, 'w') 
    897         if self.encoding == None: 
     897        if self.encoding is None: 
    898898            self.encoding = "UTF-8" 
    899899        doc.write(file_ref, encoding=self.encoding, 
     
    10151015        :param entry_node: lxml node ElementTree object to be appended to 
    10161016        """ 
    1017         if datainfo.run == None or datainfo.run == []: 
     1017        if datainfo.run is None or datainfo.run == []: 
    10181018            datainfo.run.append(RUN_NAME_DEFAULT) 
    10191019            datainfo.run_name[RUN_NAME_DEFAULT] = RUN_NAME_DEFAULT 
     
    12131213                                 str(datainfo.source.name)) 
    12141214        self.append(source, instr) 
    1215         if datainfo.source.radiation == None or datainfo.source.radiation == '': 
     1215        if datainfo.source.radiation is None or datainfo.source.radiation == '': 
    12161216            datainfo.source.radiation = "neutron" 
    12171217        self.write_node(source, "radiation", datainfo.source.radiation) 
     
    12541254        :param instr: lxml node ElementTree object to be appended to 
    12551255        """ 
    1256         if datainfo.collimation == [] or datainfo.collimation == None: 
     1256        if datainfo.collimation == [] or datainfo.collimation is None: 
    12571257            coll = Collimation() 
    12581258            datainfo.collimation.append(coll) 
     
    12991299        :param inst: lxml instrument node to be appended to 
    13001300        """ 
    1301         if datainfo.detector == None or datainfo.detector == []: 
     1301        if datainfo.detector is None or datainfo.detector == []: 
    13021302            det = Detector() 
    13031303            det.name = "" 
  • src/sas/sascalc/dataloader/readers/danse_reader.py

    r959eb01 r235f514  
    166166                 
    167167                x_vals.append(qx) 
    168                 if xmin == None or qx < xmin: 
     168                if xmin is None or qx < xmin: 
    169169                    xmin = qx 
    170                 if xmax == None or qx > xmax: 
     170                if xmax is None or qx > xmax: 
    171171                    xmax = qx 
    172172             
     
    181181                 
    182182                y_vals.append(qy) 
    183                 if ymin == None or qy < ymin: 
     183                if ymin is None or qy < ymin: 
    184184                    ymin = qy 
    185                 if ymax == None or qy > ymax: 
     185                if ymax is None or qy > ymax: 
    186186                    ymax = qy 
    187187             
  • src/sas/sascalc/dataloader/readers/xml_reader.py

    r463e7ffc r235f514  
    240240        :param name: The name of the element to be created 
    241241        """ 
    242         if attrib == None: 
     242        if attrib is None: 
    243243            attrib = {} 
    244244        return etree.Element(name, attrib, nsmap) 
     
    299299        """ 
    300300        text = str(text) 
    301         if attrib == None: 
     301        if attrib is None: 
    302302            attrib = {} 
    303303        elem = E(elementname, attrib, text) 
Note: See TracChangeset for help on using the changeset viewer.