def test_io(self): tempfilename = self.tempfilename tempfile = masterslave.open(tempfilename, mode='w') tempfile.write(str(masterslave.rank()) + '\n') tempfile.flush() contents = '' with open(tempfilename) as stillopen: contents = stillopen.read() assert_in(str(masterslave.rank()) + '\n', contents) tempfile.close() with open(tempfilename) as nowclosed: ranks = [int(s.strip()) for s in nowclosed] assert_equal(set(ranks), set(range(masterslave.size()))) tempfile = masterslave.open(tempfilename, 'a') tempfile.write(str(masterslave.rank()) + '\n') tempfile.close() with open(tempfilename) as nowclosed: ranks = [int(s.strip()) for s in nowclosed] assert_equal(len(ranks), masterslave.size() * 2) assert_equal(set(ranks), set(range(masterslave.size()))) if masterslave.size() != 1: masterslave._comm.Barrier()
def func(d1, d2): return d1, d2, masterslave.rank()
def func(dummy): return dummy, masterslave.rank()