Changeset 730 for trunk/src/common.py

Show
Ignore:
Timestamp:
03/12/10 10:14:48 (2 years ago)
Author:
pierre
Message:

Add a method to save Positions into a file. Polish and test the new Connector2 module, by adding a connectors_benchmark script in the unittest that allow to plot graphs of the connections for all the connectors and according to all the parameters. Need to play a bit with, but everything seems to be OK. Andrew, maybe please have a small look, and as soon as you consider that the progress bar, the connections are ok for you, you can commit the new connectors2 module and erase the old one.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common.py

    r720 r730  
    898898        raise NotImplementedError() 
    899899     
     900    def savePositions(self, filename, gather=True, compatible_output=True): 
     901        """ 
     902        Save positions to file. The output format is id x y z 
     903        """ 
     904        fmt = "%s\t%s\t%s\t%s\n" % ("%d", "%g", "%g", "%g") 
     905        lines = [] 
     906        for cell in self.all():   
     907            x,y,z = cell.position 
     908            line = fmt  % (cell, x, y, z) 
     909            lines.append(line) 
     910        if rank() == 0: 
     911            f = open(filename, 'w') 
     912            f.writelines(lines) 
     913            f.close() 
     914     
    900915# ============================================================================== 
    901916