Changeset f3bf622 in sasview for src/sas/sascalc


Ignore:
Timestamp:
Apr 6, 2017 8:15:08 PM (8 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:
6435594
Parents:
ec8886e
Message:

MAINT: remove has_key occurences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sascalc/realspace/VolumeCanvas.py

    rd85c194 rf3bf622  
    303303        self.shapecount += 1 
    304304 
    305         #model changed, need to recalculate P(r) 
     305        # model changed, need to recalculate P(r) 
    306306        self._model_changed() 
    307307 
     
    328328            id = "shape"+str(self.shapecount) 
    329329  
    330         #shapeDesc = ShapeDescriptor(shape.lower()) 
     330        # shapeDesc = ShapeDescriptor(shape.lower()) 
    331331        if shape.lower() in shape_dict: 
    332332            shapeDesc = shape_dict[shape.lower()]() 
     
    335335            shapeDesc = PDBDescriptor(shape) 
    336336        else: 
    337             raise ValueError, "VolumeCanvas.add: Unknown shape %s" % shape 
     337            raise ValueError("VolumeCanvas.add: Unknown shape %s" % shape) 
    338338         
    339339        return self.addObject(shapeDesc, id) 
     
    345345        """ 
    346346 
    347         if self.shapes.has_key(id): 
     347        if id in self.shapes: 
    348348            del self.shapes[id] 
    349349        else: 
    350             raise KeyError, "VolumeCanvas.delete: could not find shape ID" 
    351  
    352         #model changed, need to recalculate P(r) 
     350            raise KeyError("VolumeCanvas.delete: could not find shape ID") 
     351 
     352        # model changed, need to recalculate P(r) 
    353353        self._model_changed() 
    354354 
     
    410410        if len(toks) == 1: 
    411411            try: 
    412                 self.params.has_key(toks[0]) 
     412                a = self.params[toks[0]] 
    413413            except KeyError: 
    414                 raise ValueError, \ 
    415                     "VolumeCanvas.getParam: Could not find %s" % name 
     414                raise ValueError("VolumeCanvas.getParam: Could not find" 
     415                                 " %s" % name) 
    416416 
    417417            value = self.params[toks[0]] 
    418418            if isinstance(value, ShapeDescriptor): 
    419                 raise ValueError, \ 
    420                     "VolumeCanvas.getParam: Cannot get parameter value."  
     419                raise ValueError("VolumeCanvas.getParam: Cannot get parameter" 
     420                                 " value.") 
    421421            else: 
    422422                return value 
     
    424424        elif len(toks) == 2: 
    425425            try: 
    426                 self.shapes.has_key(toks[0]) 
     426                a = self.shapes[toks[0]] 
    427427            except KeyError: 
    428                 raise ValueError, \ 
    429                     "VolumeCanvas.getParam: Could not find %s" % name 
     428                raise ValueError("VolumeCanvas.getParam: Could not find " 
     429                                 "%s" % name) 
    430430 
    431431            shapeinstance = self.shapes[toks[0]] 
    432432 
    433433            try: 
    434                 shapeinstance.params.has_key(toks[1]) 
     434                a = shapeinstance.params[toks[1]] 
    435435            except KeyError: 
    436                 raise ValueError, \ 
    437                     "VolumeCanvas.getParam: Could not find %s" % name 
     436                raise ValueError("VolumeCanvas.getParam: Could not find " 
     437                                 "%s" % name) 
    438438 
    439439            return shapeinstance.params[toks[1]] 
    440440 
    441441        else: 
    442             raise ValueError, \ 
    443                 "VolumeCanvas.getParam: Could not find %s" % name 
     442            raise ValueError("VolumeCanvas.getParam: Could not find %s" % name) 
    444443             
    445444    def getParamList(self, shapeid = None): 
     
    455454 
    456455        param_list = [] 
    457         if shapeid == None:         
     456        if shapeid is None: 
    458457            for key1 in self.params.keys(): 
    459458                #value1 = self.params[key1] 
     
    468467        else: 
    469468            try: 
    470                 self.shapes.has_key(shapeid) 
     469                a = self.shapes[shapeid] 
    471470            except KeyError: 
    472                 raise ValueError, \ 
    473                     "VolumeCanvas: getParamList: Could not find %s" % shapeid 
     471                raise ValueError("VolumeCanvas: getParamList: Could not find " 
     472                                 "%s" % shapeid) 
     473 
    474474            header = shapeid + '.' 
    475             param_list = self.shapes[shapeid].params.keys()   
    476             for i in range(len(param_list)): 
    477                 param_list[i] = header + param_list[i] 
    478  
     475            param_list = [header + param for param in self.shapes[shapeid].params] 
    479476        return param_list 
    480477 
Note: See TracChangeset for help on using the changeset viewer.