Diff for /python/pyvtk/lib/Data.py between versions 1.1 and 1.2

version 1.1, 2001/05/19 22:21:49 version 1.2, 2001/05/31 17:48:54
Line 1 Line 1
 #!/usr/bin/env python  #!/usr/bin/env python
 """  """
   PointData, CellData
   """
   """
   
 Copyright 2001 Pearu Peterson all rights reserved,  Copyright 2001 Pearu Peterson all rights reserved,
 Pearu Peterson <pearu@ioc.ee>            Pearu Peterson <pearu@ioc.ee>          
Line 22  class Data(common.Common): Line 25  class Data(common.Common):
     def __init__(self,*args):      def __init__(self,*args):
         if self.__class__.__name__ not in ['PointData','CellData']:          if self.__class__.__name__ not in ['PointData','CellData']:
             raise TypeError,'use PointData or CellData instead of Data'              raise TypeError,'use PointData or CellData instead of Data'
         if not args:          self.data = []
             raise TypeError,self.__class__.__name__+'() takes at least 1 argument: Scalars|ColorScalars|LookupTable|Vectors|Normals|TextureCoordinates|Tensors|Field'          self.length = None
         args = list(args)          map(self.append,args)
         length = None      def append(self,obj):
         for a in args:          if not common.is_datasetattr(obj):
             if not common.is_datasetattr(a):              self.error('expected DataSetAttr argument but got %s'%(type(obj)))
                 self.skipping('expected DataSetAttr argument but got %s'%(type(a)))              raise TypeError
                 continue          if self.length is None:
             if length is None:              self.length = obj.get_size()
                 length = a.get_size()          if self.length != obj.get_size():
             elif length != a.get_size():              self.error('attribute data %s must be of length %s (as defined by first DataSetAttr) but got %s'%(`obj.__class__.__name__`,self.length,obj.get_size()))
                 self.skipping('attribute data %s must be of length %s (as defined by first DataSetAttr) but got %s'%(`a.__class__.__name__`,length,a.get_size()))              raise ValueError
                 continue          self.data.append(obj)
         self.length = length  
         self.data = args  
     def get_size(self):      def get_size(self):
         return self.length          return self.length
     def to_string(self,format='ascii'):      def to_string(self,format='ascii'):
Line 47  class Data(common.Common): Line 48  class Data(common.Common):
         return '\n'.join(ret)          return '\n'.join(ret)
   
 class PointData(Data):  class PointData(Data):
       """
       Usage:
         PointData(<DataSetAttr instances>)
       Attributes:
         data - list of DataSetAttr instances
       Public methods:
         get_size()
         to_string(format = 'ascii')
         append(<DataSetAttr instance>)
       """
     data_type = 'POINT_DATA'      data_type = 'POINT_DATA'
   
 class CellData(Data):  class CellData(Data):
       """
       Usage:
         CellData(<DataSetAttr instances>)
       Attributes:
         data - list of DataSetAttr instances
       Public methods:
         get_size()
         to_string(format = 'ascii')
         append(<DataSetAttr instance>)
       """
     data_type = 'CELL_DATA'      data_type = 'CELL_DATA'
   
   
   
 if __name__ == "__main__":  if __name__ == "__main__":
     import Scalars      import Scalars
     print PointData(Scalars.Scalars([2,3]))      print PointData(Scalars.Scalars([2,3]))

Removed from v.1.1  
changed lines
  Added in v.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>