def test_general(self): traj = pt.iterload(fn('Tc5b.x'), fn('Tc5b.top')) # with mask saved_data = pt.radgyr(traj, '@CA') data = pt.pmap(pt.radgyr, traj, '@CA') data = pt.tools.dict_to_ndarray(data) aa_eq([saved_data], data) # with a series of functions func_list = [pt.radgyr, pt.molsurf, pt.rmsd] ref = traj[-3] for n_cores in [2, 3]: for func in func_list: if func in [ pt.rmsd, ]: pout = pt.tools.dict_to_ndarray( pt.pmap( func=func, traj=traj, ref=ref, n_cores=n_cores)) serial_out = flatten(func(traj, ref=ref)) else: pout = pt.tools.dict_to_ndarray( pt.pmap(n_cores=n_cores, func=func, traj=traj)) serial_out = flatten(func(traj)) aa_eq(pout[0], serial_out) # test worker # need to test this since coverages seems not recognize partial func data = worker_by_func( rank=2, n_cores=8, func=pt.radgyr, traj=traj, args=(), kwargs={'mask': '@CA'}, iter_options={}) assert data[ 1] == 1, 'n_frames for rank=2 should be 1 (only 10 frames in total)'
def test_different_references(self): traj = self.traj func = pt.rmsd for i in range(0, 8, 2): ref = self.traj[i] for n_cores in [ 2, 3, ]: pout = pt.tools.dict_to_ndarray( pt.pmap(n_cores=n_cores, func=func, traj=traj, ref=ref)) serial_out = flatten(func(traj, ref=ref)) aa_eq(pout[0], serial_out)