Changeset def97a0 in sasview


Ignore:
Timestamp:
Apr 4, 2017 9:11:22 AM (7 years ago)
Author:
Adam Washington <adam.washington@…>
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:
388bd51
Parents:
ecc8d1a8
git-author:
Adam Washington <adam.washington@…> (04/04/17 08:44:01)
git-committer:
Adam Washington <adam.washington@…> (04/04/17 09:11:22)
Message:

Pass flake8 on sesans_reader.py

Imrpove the code in sesans reader by ensuring that everything passes
the flake8 tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/dataloader/readers/sesans_reader.py

    recc8d1a8 rdef97a0  
    1818_ZERO = 1e-16 
    1919 
     20 
    2021class Reader: 
    2122    """ 
    2223    Class to load sesans files (6 columns). 
    2324    """ 
    24     ## File type 
     25    # File type 
    2526    type_name = "SESANS" 
    2627 
    27     ## Wildcards 
     28    # Wildcards 
    2829    type = ["SESANS files (*.ses)|*.ses", 
    2930            "SESANS files (*..sesans)|*.sesans"] 
    30     ## List of allowed extensions 
     31    # List of allowed extensions 
    3132    ext = ['.ses', '.SES', '.sesans', '.SESANS'] 
    3233 
    33     ## Flag to bypass extension check 
     34    # Flag to bypass extension check 
    3435    allow_all = True 
    3536 
    3637    def read(self, path): 
    37  
    38 #        print "reader triggered" 
    39  
    4038        """ 
    4139        Load data file 
     
    7977                    if lam_unit == "AA": 
    8078                        lam_unit = "A" 
    81                     p_unit = headers["polarisation"] 
    8279 
    83                     x, x_unit = self._unit_conversion(x, lam_unit, 
    84                                                       _fetch_unit(headers, 
    85                                                                   "spin echo length")) 
    86                     dx, dx_unit = self._unit_conversion(dx, lam_unit, 
    87                                                         _fetch_unit(headers, 
    88                                                                     "error SEL")) 
    89                     dlam, dlam_unit = self._unit_conversion(dlam, lam_unit, 
    90                                                             _fetch_unit(headers, 
    91                                                                         "error wavelength")) 
     80                    x, x_unit = self._unit_conversion( 
     81                        x, lam_unit, 
     82                        _fetch_unit(headers, "spin echo length")) 
     83                    dx, dx_unit = self._unit_conversion( 
     84                        dx, lam_unit, 
     85                        _fetch_unit(headers, "error SEL")) 
     86                    dlam, dlam_unit = self._unit_conversion( 
     87                        dlam, lam_unit, 
     88                        _fetch_unit(headers, "error wavelength")) 
    9289                    y_unit = r'\AA^{-2} cm^{-1}' 
    9390 
    94                     output = Data1D(x=x, y=y, lam=lam, dy = dy, dx=dx, dlam=dlam, isSesans=True) 
     91                    output = Data1D(x=x, y=y, lam=lam, dy=dy, dx=dx, dlam=dlam, 
     92                                    isSesans=True) 
    9593                    self.filename = output.filename = basename 
    9694                    output.xaxis(r"\rm{z}", x_unit) 
    97                     output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit)  # Adjust label to ln P/(lam^2 t), remove lam column refs 
     95                    # Adjust label to ln P/(lam^2 t), remove lam column refs 
     96                    output.yaxis(r"\rm{ln(P)/(t \lambda^2)}", y_unit) 
    9897                    # Store loading process information 
    9998                    output.meta_data['loader'] = self.type_name 
    100                     #output.sample.thickness = float(paramvals[6]) 
    10199                    output.sample.name = params["Sample"] 
    102100                    output.sample.ID = params["DataFileTitle"] 
    103101 
    104                     output.sample.zacceptance = (float(_header_fetch(params, "Q_zmax")), 
    105                                                  _fetch_unit(params, "Q_zmax")) 
     102                    output.sample.zacceptance = ( 
     103                        float(_header_fetch(params, "Q_zmax")), 
     104                        _fetch_unit(params, "Q_zmax")) 
    106105 
    107                     output.sample.yacceptance = (float(_header_fetch(params, "Q_ymax")), 
    108                                                  _fetch_unit(params, "Q_ymax")) 
     106                    output.sample.yacceptance = ( 
     107                        float(_header_fetch(params, "Q_ymax")), 
     108                        _fetch_unit(params, "Q_ymax")) 
    109109 
    110110                if len(output.x) < 1: 
    111                     raise RuntimeError, "%s is empty" % path 
     111                    raise RuntimeError("%s is empty" % path) 
    112112                return output 
    113113 
    114114        else: 
    115             raise RuntimeError, "%s is not a file" % path 
     115            raise RuntimeError("%s is not a file" % path) 
    116116        return None 
    117117 
    118118    def _unit_conversion(self, value, value_unit, default_unit): 
    119         if has_converter == True and value_unit != default_unit: 
     119        if has_converter and value_unit != default_unit: 
    120120            data_conv_q = Converter(value_unit) 
    121121            value = data_conv_q(value, units=default_unit) 
     
    131131    return headers[index] 
    132132 
     133 
    133134def _fetch_unit(params, key): 
    134135    index = [k for k in params.keys() 
Note: See TracChangeset for help on using the changeset viewer.