Ignore:
Timestamp:
Mar 9, 2017 8:43:25 AM (7 years ago)
Author:
krzywon
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
c94280c
Parents:
082239e
Message:

PEP 8 cleanup as Paul K suggested.

File:
1 edited

Legend:

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

    r082239e r54544637  
    5555    ext = ['.h5', '.H5'] 
    5656    # Flag to bypass extension check 
    57     allow_all = False 
     57    allow_all = True 
    5858    # List of files to return 
    5959    output = None 
     
    193193                    continue 
    194194                # Transmission Spectrum 
    195                 elif key == u'T' and self.parent_class == \ 
    196                         u'SAStransmission_spectrum': 
     195                elif (key == u'T') \ 
     196                        and (self.parent_class == u'SAStransmission_spectrum'): 
    197197                    self.trans_spectrum.transmission = data_set.flatten() 
    198198                    continue 
    199                 elif key == u'Tdev' and self.parent_class == \ 
    200                         u'SAStransmission_spectrum': 
     199                elif (key == u'Tdev') \ 
     200                        and (self.parent_class == u'SAStransmission_spectrum'): 
    201201                    self.trans_spectrum.transmission_deviation = \ 
    202202                        data_set.flatten() 
    203203                    continue 
    204                 elif key == u'lambda' and self.parent_class == \ 
    205                         u'SAStransmission_spectrum': 
     204                elif (key == u'lambda') \ 
     205                        and (self.parent_class == u'SAStransmission_spectrum'): 
    206206                    self.trans_spectrum.wavelength = data_set.flatten() 
    207207                    continue 
     
    234234                    elif key == u'ID' and self.parent_class == u'SASsample': 
    235235                        self.current_datainfo.sample.name = data_point 
    236                     elif key == u'thickness' and self.parent_class == \ 
    237                             u'SASsample': 
     236                    elif (key == u'thickness') and (self.parent_class == 
     237                                                    u'SASsample'): 
    238238                        self.current_datainfo.sample.thickness = data_point 
    239                     elif key == u'temperature' and self.parent_class == \ 
    240                             u'SASsample': 
     239                    elif (key == u'temperature') and (self.parent_class == 
     240                                                      u'SASsample'): 
    241241                        self.current_datainfo.sample.temperature = data_point 
    242                     elif key == u'transmission' and self.parent_class == \ 
    243                             u'SASsample': 
     242                    elif (key == u'transmission') and (self.parent_class == 
     243                                                       u'SASsample'): 
    244244                        self.current_datainfo.sample.transmission = data_point 
    245                     elif key == u'x_position' and self.parent_class == \ 
    246                             u'SASsample': 
     245                    elif (key == u'x_position') and (self.parent_class == 
     246                                                     u'SASsample'): 
    247247                        self.current_datainfo.sample.position.x = data_point 
    248                     elif key == u'y_position' and self.parent_class == \ 
    249                             u'SASsample': 
     248                    elif (key == u'y_position') and (self.parent_class == 
     249                                                     u'SASsample'): 
    250250                        self.current_datainfo.sample.position.y = data_point 
    251251                    elif key == u'pitch' and self.parent_class == u'SASsample': 
     
    255255                    elif key == u'roll' and self.parent_class == u'SASsample': 
    256256                        self.current_datainfo.sample.orientation.z = data_point 
    257                     elif key == u'details' and self.parent_class == \ 
    258                             u'SASsample': 
     257                    elif (key == u'details') and (self.parent_class == 
     258                                                  u'SASsample'): 
    259259                        self.current_datainfo.sample.details.append(data_point) 
    260260 
    261261                    # Instrumental Information 
    262                     elif key == u'name' and self.parent_class == \ 
    263                             u'SASinstrument': 
     262                    elif (key == u'name') and (self.parent_class == 
     263                                               u'SASinstrument'): 
    264264                        self.current_datainfo.instrument = data_point 
    265265                    elif key == u'name' and self.parent_class == u'SASdetector': 
     
    268268                        self.detector.distance = float(data_point) 
    269269                        self.detector.distance_unit = unit 
    270                     elif key == u'slit_length' and self.parent_class == \ 
    271                             u'SASdetector': 
     270                    elif (key == u'slit_length') and (self.parent_class == 
     271                                                      u'SASdetector'): 
    272272                        self.detector.slit_length = float(data_point) 
    273273                        self.detector.slit_length_unit = unit 
    274                     elif key == u'x_position' and self.parent_class == \ 
    275                             u'SASdetector': 
     274                    elif (key == u'x_position') and (self.parent_class == 
     275                                                     u'SASdetector'): 
    276276                        self.detector.offset.x = float(data_point) 
    277277                        self.detector.offset_unit = unit 
    278                     elif key == u'y_position' and self.parent_class == \ 
    279                             u'SASdetector': 
     278                    elif (key == u'y_position') and (self.parent_class == 
     279                                                     u'SASdetector'): 
    280280                        self.detector.offset.y = float(data_point) 
    281281                        self.detector.offset_unit = unit 
    282                     elif key == u'pitch' and self.parent_class == \ 
    283                             u'SASdetector': 
     282                    elif (key == u'pitch') and (self.parent_class == 
     283                                                u'SASdetector'): 
    284284                        self.detector.orientation.x = float(data_point) 
    285285                        self.detector.orientation_unit = unit 
     
    290290                        self.detector.orientation.y = float(data_point) 
    291291                        self.detector.orientation_unit = unit 
    292                     elif key == u'beam_center_x' and self.parent_class == \ 
    293                             u'SASdetector': 
     292                    elif (key == u'beam_center_x') and (self.parent_class == 
     293                                                        u'SASdetector'): 
    294294                        self.detector.beam_center.x = float(data_point) 
    295295                        self.detector.beam_center_unit = unit 
    296                     elif key == u'beam_center_y' and self.parent_class == \ 
    297                             u'SASdetector': 
     296                    elif (key == u'beam_center_y') and (self.parent_class == 
     297                                                        u'SASdetector'): 
    298298                        self.detector.beam_center.y = float(data_point) 
    299299                        self.detector.beam_center_unit = unit 
    300                     elif key == u'x_pixel_size' and self.parent_class == \ 
    301                             u'SASdetector': 
     300                    elif (key == u'x_pixel_size') and (self.parent_class == 
     301                                                       u'SASdetector'): 
    302302                        self.detector.pixel_size.x = float(data_point) 
    303303                        self.detector.pixel_size_unit = unit 
    304                     elif key == u'y_pixel_size' and self.parent_class == \ 
    305                             u'SASdetector': 
     304                    elif (key == u'y_pixel_size') and (self.parent_class == 
     305                                                       u'SASdetector'): 
    306306                        self.detector.pixel_size.y = float(data_point) 
    307307                        self.detector.pixel_size_unit = unit 
    308                     elif key == u'distance' and self.parent_class == \ 
    309                             u'SAScollimation': 
     308                    elif (key == u'distance') and (self.parent_class == 
     309                                                   u'SAScollimation'): 
    310310                        self.collimation.length = data_point 
    311311                        self.collimation.length_unit = unit 
    312                     elif key == u'name' and self.parent_class == \ 
    313                             u'SAScollimation': 
     312                    elif (key == u'name') and (self.parent_class == 
     313                                               u'SAScollimation'): 
    314314                        self.collimation.name = data_point 
    315                     elif key == u'shape' and self.parent_class == \ 
    316                             u'SASaperture': 
     315                    elif (key == u'shape') and (self.parent_class == 
     316                                                u'SASaperture'): 
    317317                        self.aperture.shape = data_point 
    318                     elif key == u'x_gap' and self.parent_class == \ 
    319                             u'SASaperture': 
     318                    elif (key == u'x_gap') and (self.parent_class == 
     319                                                u'SASaperture'): 
    320320                        self.aperture.size.x = data_point 
    321                     elif key == u'y_gap' and self.parent_class == \ 
    322                             u'SASaperture': 
     321                    elif (key == u'y_gap') and (self.parent_class == 
     322                                                u'SASaperture'): 
    323323                        self.aperture.size.y = data_point 
    324324 
    325325                    # Process Information 
    326                     elif key == u'Title' and self.parent_class == \ 
    327                             u'SASprocess': # CanSAS 2.0 format 
     326                    elif (key == u'Title') and (self.parent_class == 
     327                                                u'SASprocess'): # CanSAS 2.0 
    328328                        self.process.name = data_point 
    329                     elif key == u'name' and self.parent_class == \ 
    330                             u'SASprocess': # NXcanSAS format 
     329                    elif (key == u'name') and (self.parent_class == 
     330                                               u'SASprocess'): # NXcanSAS 
    331331                        self.process.name = data_point 
    332                     elif key == u'description' and self.parent_class == \ 
    333                             u'SASprocess': 
     332                    elif (key == u'description') and (self.parent_class == 
     333                                                      u'SASprocess'): 
    334334                        self.process.description = data_point 
    335335                    elif key == u'date' and self.parent_class == u'SASprocess': 
     
    341341 
    342342                    # Source 
    343                     elif key == u'wavelength' and self.parent_class == \ 
    344                             u'SASdata': 
     343                    elif (key == u'wavelength') and (self.parent_class == 
     344                                                     u'SASdata'): 
    345345                        self.current_datainfo.source.wavelength = data_point 
    346346                        self.current_datainfo.source.wavelength_unit = unit 
    347                     elif key == u'incident_wavelength' and self.parent_class == \ 
    348                             u'SASsource': 
     347                    elif (key == u'incident_wavelength') and \ 
     348                        (self.parent_class == 'SASsource'): 
    349349                        self.current_datainfo.source.wavelength = data_point 
    350350                        self.current_datainfo.source.wavelength_unit = unit 
    351                     elif key == u'wavelength_max' and self.parent_class == \ 
    352                             u'SASsource': 
     351                    elif (key == u'wavelength_max') and (self.parent_class == 
     352                                                         u'SASsource'): 
    353353                        self.current_datainfo.source.wavelength_max = data_point 
    354354                        self.current_datainfo.source.wavelength_max_unit = unit 
    355                     elif key == u'wavelength_min' and self.parent_class == \ 
    356                             u'SASsource': 
     355                    elif (key == u'wavelength_min') and (self.parent_class == 
     356                                                         u'SASsource'): 
    357357                        self.current_datainfo.source.wavelength_min = data_point 
    358358                        self.current_datainfo.source.wavelength_min_unit = unit 
    359359                    elif key == u'incident_wavelength_spread' and \ 
    360                                     self.parent_class == u'SASsource': 
     360                            (self.parent_class == u'SASsource'): 
    361361                        self.current_datainfo.source.wavelength_spread = \ 
    362362                            data_point 
    363363                        self.current_datainfo.source.wavelength_spread_unit = \ 
    364364                            unit 
    365                     elif key == u'beam_size_x' and self.parent_class == \ 
    366                             u'SASsource': 
     365                    elif (key == u'beam_size_x') and (self.parent_class == 
     366                                                      u'SASsource'): 
    367367                        self.current_datainfo.source.beam_size.x = data_point 
    368368                        self.current_datainfo.source.beam_size_unit = unit 
    369                     elif key == u'beam_size_y' and self.parent_class == \ 
    370                             u'SASsource': 
     369                    elif (key == u'beam_size_y') and (self.parent_class == 
     370                                                      u'SASsource'): 
    371371                        self.current_datainfo.source.beam_size.y = data_point 
    372372                        self.current_datainfo.source.beam_size_unit = unit 
    373                     elif key == u'beam_shape' and self.parent_class == \ 
    374                             u'SASsource': 
     373                    elif (key == u'beam_shape') and (self.parent_class == 
     374                                                     u'SASsource'): 
    375375                        self.current_datainfo.source.beam_shape = data_point 
    376                     elif key == u'radiation' and self.parent_class == \ 
    377                             u'SASsource': 
     376                    elif (key == u'radiation') and (self.parent_class == 
     377                                                    u'SASsource'): 
    378378                        self.current_datainfo.source.radiation = data_point 
    379                     elif key == u'transmission' and self.parent_class == \ 
    380                             u'SASdata': 
     379                    elif (key == u'transmission') and (self.parent_class == 
     380                                                       u'SASdata'): 
    381381                        self.current_datainfo.sample.transmission = data_point 
    382382 
     
    477477            try: 
    478478                if dataset.q_data.size <= 1: 
    479                     dataset.q_data = np.sqrt(dataset.qx_data * dataset.qx_data + 
    480                                              dataset.qy_data * dataset.qy_data) 
     479                    dataset.q_data = np.sqrt(dataset.qx_data 
     480                                             * dataset.qx_data 
     481                                             + dataset.qy_data 
     482                                             * dataset.qy_data) 
    481483            except: 
    482484                dataset.q_data = None 
     
    594596        """ 
    595597        unit = value.attrs.get(u'units') 
    596         if unit == None: 
     598        if unit is None: 
    597599            unit = value.attrs.get(u'unit') 
    598600        # Convert the unit formats 
Note: See TracChangeset for help on using the changeset viewer.