Changeset 083afa1 in sasview


Ignore:
Timestamp:
Apr 11, 2017 4:11:14 AM (7 years ago)
Author:
andyfaff
Children:
9c23f40
Parents:
0741804
git-author:
Andrew Nelson <andyfaff@…> (04/07/17 05:53:49)
git-committer:
Andrew Nelson <andyfaff@…> (04/11/17 04:11:14)
Message:

PEP8: replace some 'if x == True:' by 'if x'

Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/data_util/qsmearing.py

    r235f514 r083afa1  
    6565            raise ValueError('one or more of your dx values are negative, please check the data file!') 
    6666 
    67     if _found_sesans == True: 
     67    if _found_sesans: 
    6868        #Pre-compute the Hankel matrix (H) 
    6969        qmax, qunits = data.sample.zacceptance 
     
    8484            #print "data1D.dx[0]",data1D.dx[0],data1D.dxl[0] 
    8585    # If we found resolution smearing data, return a QSmearer 
    86     if _found_resolution == True: 
     86    if _found_resolution: 
    8787         return pinhole_smear(data, model) 
    8888 
     
    107107                break 
    108108    # If we found slit smearing data, return a slit smearer 
    109     if _found_slit == True: 
     109    if _found_slit: 
    110110        return slit_smear(data, model) 
    111111    return None 
  • src/sas/sascalc/dataloader/readers/abs_reader.py

    r959eb01 r083afa1  
    6969                data_conv_i = None 
    7070                 
    71                 if has_converter == True and output.x_unit != '1/A': 
     71                if has_converter and output.x_unit != '1/A': 
    7272                    data_conv_q = Converter('1/A') 
    7373                    # Test it 
    7474                    data_conv_q(1.0, output.x_unit) 
    7575                     
    76                 if has_converter == True and output.y_unit != '1/cm': 
     76                if has_converter and output.y_unit != '1/cm': 
    7777                    data_conv_i = Converter('1/cm') 
    7878                    # Test it 
     
    8282                     
    8383                    # Information line 1 
    84                     if is_info == True: 
     84                    if is_info: 
    8585                        is_info = False 
    8686                        line_toks = line.split() 
     
    8989                        try: 
    9090                            value = float(line_toks[1]) 
    91                             if has_converter == True and \ 
     91                            if has_converter and \ 
    9292                                output.source.wavelength_unit != 'A': 
    9393                                conv = Converter('A') 
     
    104104                        try: 
    105105                            value = float(line_toks[3]) 
    106                             if has_converter == True and \ 
     106                            if has_converter and \ 
    107107                                detector.distance_unit != 'm': 
    108108                                conv = Converter('m') 
     
    125125                        try: 
    126126                            value = float(line_toks[5]) 
    127                             if has_converter == True and \ 
     127                            if has_converter and \ 
    128128                                output.sample.thickness_unit != 'cm': 
    129129                                conv = Converter('cm') 
     
    142142                         
    143143                    # Find center info line 
    144                     if is_center == True: 
     144                    if is_center: 
    145145                        is_center = False 
    146146                        line_toks = line.split() 
     
    150150                         
    151151                        # Bin size 
    152                         if has_converter == True and \ 
     152                        if has_converter and \ 
    153153                            detector.pixel_size_unit != 'mm': 
    154154                            conv = Converter('mm') 
     
    163163                        # Store beam center in distance units 
    164164                        # Det 640 x 640 mm 
    165                         if has_converter == True and \ 
     165                        if has_converter and \ 
    166166                            detector.beam_center_unit != 'mm': 
    167167                            conv = Converter('mm') 
     
    187187                         
    188188                    # Parse the data 
    189                     if is_data_started == True: 
     189                    if is_data_started: 
    190190                        toks = line.split() 
    191191 
  • src/sas/sascalc/dataloader/readers/ascii_reader.py

    r235f514 r083afa1  
    147147                                pass 
    148148 
    149                         if has_error_dy == True: 
     149                        if has_error_dy: 
    150150                            tdy = np.append(tdy, _dy) 
    151                         if has_error_dx == True: 
     151                        if has_error_dx: 
    152152                            tdx = np.append(tdx, _dx) 
    153153                        tx = np.append(tx, _x) 
    154154                        ty = np.append(ty, _y) 
    155155 
    156                         #To remember the # of columns on the current line 
     156                        # To remember the # of columns on the current line 
    157157                        # for the next line of data 
    158158                        lentoks = new_lentoks 
     
    160160                    except ValueError: 
    161161                        # It is data and meet non - number, then stop reading 
    162                         if is_data == True: 
     162                        if is_data: 
    163163                            break 
    164164                        lentoks = 2 
     
    175175                    raise RuntimeError, msg 
    176176                # Sanity check 
    177                 if has_error_dy == True and not len(ty) == len(tdy): 
     177                if has_error_dy and not len(ty) == len(tdy): 
    178178                    msg = "ascii_reader: y and dy have different length" 
    179179                    raise RuntimeError, msg 
    180                 if has_error_dx == True and not len(tx) == len(tdx): 
     180                if has_error_dx and not len(tx) == len(tdx): 
    181181                    msg = "ascii_reader: y and dy have different length" 
    182182                    raise RuntimeError, msg 
     
    199199                    x[i] = tx[ind[i]] 
    200200                    y[i] = ty[ind[i]] 
    201                     if has_error_dy == True: 
     201                    if has_error_dy: 
    202202                        dy[i] = tdy[ind[i]] 
    203                     if has_error_dx == True: 
     203                    if has_error_dx: 
    204204                        dx[i] = tdx[ind[i]] 
    205205                # Zeros in dx, dy 
     
    211211                output.x = x[x != 0] 
    212212                output.y = y[x != 0] 
    213                 output.dy = dy[x != 0] if has_error_dy == True\ 
     213                output.dy = dy[x != 0] if has_error_dy\ 
    214214                    else np.zeros(len(output.y)) 
    215                 output.dx = dx[x != 0] if has_error_dx == True\ 
     215                output.dx = dx[x != 0] if has_error_dx\ 
    216216                    else np.zeros(len(output.x)) 
    217217 
     
    243243        if len(toks) < 2: 
    244244            toks = line.split() 
     245 
    245246        return toks 
  • src/sas/sascalc/dataloader/readers/cansas_reader.py

    r7432acb r083afa1  
    774774                if local_unit and default_unit and local_unit.lower() != default_unit.lower() \ 
    775775                        and local_unit.lower() != "none": 
    776                     if HAS_CONVERTER == True: 
     776                    if HAS_CONVERTER: 
    777777                        # Check local units - bad units raise KeyError 
    778778                        data_conv_q = Converter(local_unit) 
     
    11701170            pos, "z", datainfo.sample.position.z, 
    11711171            {"unit": datainfo.sample.position_unit}) 
    1172         if written == True: 
     1172        if written: 
    11731173            self.append(pos, sample) 
    11741174 
     
    11831183            ori, "yaw", datainfo.sample.orientation.z, 
    11841184            {"unit": datainfo.sample.orientation_unit}) 
    1185         if written == True: 
     1185        if written: 
    11861186            self.append(ori, sample) 
    11871187 
     
    12301230            size, "z", datainfo.source.beam_size.z, 
    12311231            {"unit": datainfo.source.beam_size_unit}) 
    1232         if written == True: 
     1232        if written: 
    12331233            self.append(size, source) 
    12341234 
     
    12861286                    size, "z", aperture.size.z, 
    12871287                    {"unit": aperture.size_unit}) 
    1288                 if written == True: 
     1288                if written: 
    12891289                    self.append(size, apert) 
    12901290 
     
    13091309            written = written | self.write_node(det, "SDD", item.distance, 
    13101310                                                {"unit": item.distance_unit}) 
    1311             if written == True: 
     1311            if written: 
    13121312                self.append(det, instr) 
    13131313 
     
    13191319            written = written | self.write_node(off, "z", item.offset.z, 
    13201320                                                {"unit": item.offset_unit}) 
    1321             if written == True: 
     1321            if written: 
    13221322                self.append(off, det) 
    13231323 
     
    13311331                                                item.orientation.z, 
    13321332                                                {"unit": item.orientation_unit}) 
    1333             if written == True: 
     1333            if written: 
    13341334                self.append(ori, det) 
    13351335 
     
    13431343                                                item.beam_center.z, 
    13441344                                                {"unit": item.beam_center_unit}) 
    1345             if written == True: 
     1345            if written: 
    13461346                self.append(center, det) 
    13471347 
     
    13531353            written = written | self.write_node(pix, "z", item.pixel_size.z, 
    13541354                                                {"unit": item.pixel_size_unit}) 
    1355             if written == True: 
     1355            if written: 
    13561356                self.append(pix, det) 
    13571357            self.write_node(det, "slit_length", item.slit_length, 
     
    14651465                exec "local_unit = storage.%s_unit" % toks[0] 
    14661466                if local_unit is not None and units.lower() != local_unit.lower(): 
    1467                     if HAS_CONVERTER == True: 
     1467                    if HAS_CONVERTER: 
    14681468                        try: 
    14691469                            conv = Converter(units) 
  • src/sas/sascalc/dataloader/readers/danse_reader.py

    r235f514 r083afa1  
    8787            data_conv_i = None 
    8888             
    89             if has_converter == True and output.Q_unit != '1/A': 
     89            if has_converter and output.Q_unit != '1/A': 
    9090                data_conv_q = Converter('1/A') 
    9191                # Test it 
    9292                data_conv_q(1.0, output.Q_unit) 
    9393                 
    94             if has_converter == True and output.I_unit != '1/cm': 
     94            if has_converter and output.I_unit != '1/cm': 
    9595                data_conv_i = Converter('1/cm') 
    9696                # Test it 
     
    162162                qx = 4.0 * math.pi / wavelength * math.sin(theta / 2.0) 
    163163                 
    164                 if has_converter == True and output.Q_unit != '1/A': 
     164                if has_converter and output.Q_unit != '1/A': 
    165165                    qx = data_conv_q(qx, units=output.Q_unit) 
    166166                 
     
    177177                qy = 4.0 * math.pi / wavelength * math.sin(theta/2.0) 
    178178                 
    179                 if has_converter == True and output.Q_unit != '1/A': 
     179                if has_converter and output.Q_unit != '1/A': 
    180180                    qy = data_conv_q(qy, units=output.Q_unit) 
    181181                 
     
    213213            # Store all data 
    214214            # Store wavelength 
    215             if has_converter == True and output.source.wavelength_unit != 'A': 
     215            if has_converter and output.source.wavelength_unit != 'A': 
    216216                conv = Converter('A') 
    217217                wavelength = conv(wavelength, 
     
    220220                 
    221221            # Store distance 
    222             if has_converter == True and detector.distance_unit != 'm': 
     222            if has_converter and detector.distance_unit != 'm': 
    223223                conv = Converter('m') 
    224224                distance = conv(distance, units=detector.distance_unit) 
     
    226226             
    227227            # Store pixel size 
    228             if has_converter == True and detector.pixel_size_unit != 'mm': 
     228            if has_converter and detector.pixel_size_unit != 'mm': 
    229229                conv = Converter('mm') 
    230230                pixel = conv(pixel, units=detector.pixel_size_unit) 
     
    242242            ymax = ymax + stepq / 2.0 
    243243             
    244             if has_converter == True and output.Q_unit != '1/A': 
     244            if has_converter and output.Q_unit != '1/A': 
    245245                xmin = data_conv_q(xmin, units=output.Q_unit) 
    246246                xmax = data_conv_q(xmax, units=output.Q_unit) 
     
    281281         
    282282        return None 
     283 
  • src/sas/sascalc/dataloader/readers/hfir1d_reader.py

    r959eb01 r083afa1  
    6262                data_conv_i = None 
    6363                 
    64                 if has_converter == True and output.x_unit != '1/A': 
     64                if has_converter and output.x_unit != '1/A': 
    6565                    data_conv_q = Converter('1/A') 
    6666                    # Test it 
    6767                    data_conv_q(1.0, output.x_unit) 
    6868                     
    69                 if has_converter == True and output.y_unit != '1/cm': 
     69                if has_converter and output.y_unit != '1/cm': 
    7070                    data_conv_i = Converter('1/cm') 
    7171                    # Test it 
  • src/sas/sascalc/dataloader/readers/red2d_reader.py

    r959eb01 r083afa1  
    107107         
    108108        # Set units: This is the unit assumed for Q and I in the data file. 
    109         if has_converter == True and output.Q_unit != '1/A': 
     109        if has_converter and output.Q_unit != '1/A': 
    110110            data_conv_q = Converter('1/A') 
    111111            # Test it 
    112112            data_conv_q(1.0, output.Q_unit) 
    113113             
    114         if has_converter == True and output.I_unit != '1/cm': 
     114        if has_converter and output.I_unit != '1/cm': 
    115115            data_conv_i = Converter('1/cm') 
    116116            # Test it 
     
    140140                    wavelength = float(line_toks[1]) 
    141141                    # Units 
    142                     if has_converter == True and \ 
     142                    if has_converter and \ 
    143143                    output.source.wavelength_unit != 'A': 
    144144                        conv = Converter('A') 
     
    152152                    distance = float(line_toks[3]) 
    153153                    # Units 
    154                     if has_converter == True and detector.distance_unit != 'm': 
     154                    if has_converter and detector.distance_unit != 'm': 
    155155                        conv = Converter('m') 
    156156                        distance = conv(distance, units=detector.distance_unit) 
     
    189189 
    190190            ## Read and get data. 
    191             if dataStarted == True: 
     191            if dataStarted: 
    192192                line_toks = line.split() 
    193193                if len(line_toks) == 0: 
     
    268268 
    269269        # units 
    270         if has_converter == True and output.Q_unit != '1/A': 
     270        if has_converter and output.Q_unit != '1/A': 
    271271            xmin = data_conv_q(xmin, units=output.Q_unit) 
    272272            xmax = data_conv_q(xmax, units=output.Q_unit) 
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    r9a5097c r083afa1  
    166166 
    167167    def _unit_conversion(self, value, value_unit, default_unit): 
    168         if has_converter == True and value_unit != default_unit: 
     168        if has_converter and value_unit != default_unit: 
    169169            data_conv_q = Converter(value_unit) 
    170170            value = data_conv_q(value, units=default_unit) 
Note: See TracChangeset for help on using the changeset viewer.