Changeset d1bee3f in sasview for src/sas/sascalc/realspace


Ignore:
Timestamp:
Apr 8, 2017 3:51:45 AM (8 years ago)
Author:
wojciech
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, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
d3a06ce
Parents:
6d6832e (diff), 861f1880 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of https://github.com/SasView/sasview into ticket-510

Location:
src/sas/sascalc/realspace
Files:
2 edited

Legend:

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

    rd85c194 r6435594  
    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 
     
    379379        # If a shape identifier was given, look the shape up 
    380380        # in the dictionary 
    381         if len(toks)>1: 
    382             if toks[0] in self.shapes.keys(): 
     381        if len(toks): 
     382            if toks[0] in self.shapes: 
    383383                # The shape was found, now look for the parameter 
    384384                if toks[1] in self.shapes[toks[0]].params: 
     
    387387                    self._model_changed() 
    388388                else: 
    389                     raise ValueError, "Could not find parameter %s" % name 
     389                    raise ValueError("Could not find parameter %s" % name) 
    390390            else: 
    391                 raise ValueError, "Could not find shape %s" % toks[0] 
     391                raise ValueError("Could not find shape %s" % toks[0]) 
    392392         
    393393        else: 
     
    410410        if len(toks) == 1: 
    411411            try: 
    412                 self.params.has_key(toks[0]) 
     412                value = self.params[toks[0]] 
    413413            except KeyError: 
    414                 raise ValueError, \ 
    415                     "VolumeCanvas.getParam: Could not find %s" % name 
    416  
    417             value = self.params[toks[0]] 
     414                raise ValueError("VolumeCanvas.getParam: Could not find" 
     415                                 " %s" % name) 
    418416            if isinstance(value, ShapeDescriptor): 
    419                 raise ValueError, \ 
    420                     "VolumeCanvas.getParam: Cannot get parameter value."  
     417                raise ValueError("VolumeCanvas.getParam: Cannot get parameter" 
     418                                 " value.") 
    421419            else: 
    422420                return value 
     
    424422        elif len(toks) == 2: 
    425423            try: 
    426                 self.shapes.has_key(toks[0]) 
     424                shapeinstance = self.shapes[toks[0]] 
    427425            except KeyError: 
    428                 raise ValueError, \ 
    429                     "VolumeCanvas.getParam: Could not find %s" % name 
    430  
    431             shapeinstance = self.shapes[toks[0]] 
    432  
    433             try: 
    434                 shapeinstance.params.has_key(toks[1]) 
    435             except KeyError: 
    436                 raise ValueError, \ 
    437                     "VolumeCanvas.getParam: Could not find %s" % name 
     426                raise ValueError("VolumeCanvas.getParam: Could not find " 
     427                                 "%s" % name) 
     428 
     429            if not toks[1] in shapeinstance.params: 
     430                raise ValueError("VolumeCanvas.getParam: Could not find " 
     431                                 "%s" % name) 
    438432 
    439433            return shapeinstance.params[toks[1]] 
    440434 
    441435        else: 
    442             raise ValueError, \ 
    443                 "VolumeCanvas.getParam: Could not find %s" % name 
    444              
    445     def getParamList(self, shapeid = None): 
     436            raise ValueError("VolumeCanvas.getParam: Could not find %s" % name) 
     437             
     438    def getParamList(self, shapeid=None): 
    446439        """ 
    447440               return a full list of all available parameters from  
     
    455448 
    456449        param_list = [] 
    457         if shapeid == None:         
    458             for key1 in self.params.keys(): 
     450        if shapeid is None: 
     451            for key1 in self.params: 
    459452                #value1 = self.params[key1] 
    460453                param_list.append(key1) 
    461             for key2 in self.shapes.keys(): 
     454            for key2 in self.shapes: 
    462455                value2 = self.shapes[key2] 
    463456                header = key2 + '.' 
    464                 for key3 in value2.params.keys():    
     457                for key3 in value2.params: 
    465458                    fullname = header + key3                  
    466459                    param_list.append(fullname) 
    467460      
    468461        else: 
    469             try: 
    470                 self.shapes.has_key(shapeid) 
    471             except KeyError: 
    472                 raise ValueError, \ 
    473                     "VolumeCanvas: getParamList: Could not find %s" % shapeid 
     462            if not shapeid in self.shapes: 
     463                raise ValueError("VolumeCanvas: getParamList: Could not find " 
     464                                 "%s" % shapeid) 
     465 
    474466            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  
     467            param_list = [header + param for param in self.shapes[shapeid].params] 
    479468        return param_list 
    480469 
     
    490479            @param shapeDesc: shape description 
    491480        """ 
    492         #Create the object model 
     481        # Create the object model 
    493482        shapeDesc.create() 
    494483                     
     
    605594        # type we recognize 
    606595        else: 
    607             raise ValueError, "run(q): bad type for q" 
     596            raise ValueError("run(q): bad type for q") 
    608597     
    609598    def runXY(self, q = 0): 
     
    625614        # type we recognize 
    626615        else: 
    627             raise ValueError, "runXY(q): bad type for q" 
     616            raise ValueError("runXY(q): bad type for q") 
    628617     
    629618    def _create_modelObject(self): 
  • src/sas/sascalc/realspace/__init__.py

    rd85c194 r6aad2e8  
    4242# 
    4343# \subsection behav Behavior Enumeration: 
    44 # \image html enum.gif 
     44# \image html enum.png 
    4545# 
    4646# \subsection Tutorial 
Note: See TracChangeset for help on using the changeset viewer.