/[escript]/trunk/escript/py_src/modelframe.py
ViewVC logotype

Diff of /trunk/escript/py_src/modelframe.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 950 by gross, Tue Feb 6 07:01:11 2007 UTC revision 952 by gross, Wed Feb 7 23:53:24 2007 UTC
# Line 479  class ParameterSet(LinkableObject): Line 479  class ParameterSet(LinkableObject):
479    
480      def checkLinkTargets(self, models, hash):      def checkLinkTargets(self, models, hash):
481          """          """
482          returns a list of (paramter set,parameter, target model ) if the the parameter of model          returns a set of tuples ("<self>(<name>)", <target model>) if the parameter <name> is linked to model <target model>
483          is linking to the target_model which is not in list of models.          but <target model> is not in the list models. If the a parameter is linked to another parameter set which is not in the hash list
484            the parameter set is checked for its models. hash gives the call history.
485          """          """
486          out=[]          out=set()
487          for name, value in self:          for name, value in self:
488              if isinstance(value, Link):              if isinstance(value, Link):
                print str(self), name, value  
489                 m=value.getTarget()                 m=value.getTarget()
490                 if (m,name) in hash:                 if isinstance(m, Model):
491                   raise RuntimeError("recursive link: %s"%(hash+[ (m,name) ]))                     if not m in models: out.add( (str(self)+"("+name+")",m) )
492                 if isinstance(m, Model) and not m in models: out.append( (self,name,m) )                 elif isinstance(m, ParameterSet) and not m in hash:
493                 if isinstance(m, ParameterSet):                       out|=set( [ (str(self)+"("+name+")."+f[0],f[1]) for f in m.checkLinkTargets(models, hash+[ self ] ) ] )
494                    try:          return out
                      out+=m.checkLinkTargets(models, hash+[ (self,name) ] )  
                   except RuntimeError, e:  
                      print str(e), str(self), name  
                      raise e  
         return list(set(out))  
495            
496      def __iter__(self):      def __iter__(self):
497          """          """
# Line 608  class ParameterSet(LinkableObject): Line 603  class ParameterSet(LinkableObject):
603                      dic.appendChild(i)                      dic.appendChild(i)
604                   param.appendChild(dic)                   param.appendChild(dic)
605              else:              else:
                 print value  
606                  raise ValueError("cannot serialize %s type to XML."%str(value.__class__))                  raise ValueError("cannot serialize %s type to XML."%str(value.__class__))
607    
608              node.appendChild(param)              node.appendChild(param)
# Line 935  class Simulation(Model): Line 929  class Simulation(Model):
929          returns a list of (model,parameter, target model ) if the the parameter of model          returns a list of (model,parameter, target model ) if the the parameter of model
930          is linking to the target_model which is not in list of models.          is linking to the target_model which is not in list of models.
931          """          """
932          out=self.checkLinkTargets(models, hash)          out=self.checkLinkTargets(models, hash + [self])
933          for m in self.iterModels():          for m in self.iterModels():
934              if isinstance(m, Simulation):              if isinstance(m, Simulation):
935                   out+=[ (m,) + f for f in  m.checkModels(models, hash) ]                   out|=m.checkModels(models, hash)
936              else:              else:
937                   out+=[ (m,) + f for f in  m.checkLinkTargets(models, hash) ]                   out|=m.checkLinkTargets(models, hash + [self])
938          return out          return set( [ (str(self)+"."+f[0],f[1]) for f in out ] )
939    
940            
941      def getSafeTimeStepSize(self,dt):      def getSafeTimeStepSize(self,dt):
# Line 1075  class Simulation(Model): Line 1069  class Simulation(Model):
1069          if len(missing)>0:          if len(missing)>0:
1070              msg=""              msg=""
1071              for l in missing:              for l in missing:
1072                   msg+="\n\t"+str(l[-1])+" at "+str(self)                   msg+="\n\t"+str(l[1])+" at "+l[0]
                  for i in xrange(len(l)-1): msg+="."+str(l[i])  
1073              raise MissingLink("link targets missing in the Simulation: %s"%msg)              raise MissingLink("link targets missing in the Simulation: %s"%msg)
1074          #==============================          #==============================
1075          self.doInitialization()          self.doInitialization()

Legend:
Removed from v.950  
changed lines
  Added in v.952

  ViewVC Help
Powered by ViewVC 1.1.26