Author: bugman Date: Mon Jun 11 22:35:57 2012 New Revision: 16874 URL: http://svn.gna.org/viewcvs/relax?rev=16874&view=rev Log: Created the generic_fns.interatomic.interatomic_loop() generator function. Modified: branches/interatomic/generic_fns/interatomic.py Modified: branches/interatomic/generic_fns/interatomic.py URL: http://svn.gna.org/viewcvs/relax/branches/interatomic/generic_fns/interatomic.py?rev=16874&r1=16873&r2=16874&view=diff ============================================================================== --- branches/interatomic/generic_fns/interatomic.py (original) +++ branches/interatomic/generic_fns/interatomic.py Mon Jun 11 22:35:57 2012 @@ -52,6 +52,25 @@ return cdp.interatomic.add_item(spin_id1=spin_id1, spin_id2=spin_id2) +def interatomic_loop(pipe=None): + """Generator function for looping over all the interatomic data containers. + + @keyword pipe: The data pipe containing the spin. Defaults to the current data pipe. + @type pipe: str + """ + + # The data pipe. + if pipe == None: + pipe = pipes.cdp_name() + + # Get the data pipe. + dp = pipes.get_pipe(pipe) + + # Loop over the containers, yielding them. + for i in range(len(dp.interatomic)): + yield dp.interatomic[i] + + def return_interatom(spin_id1=None, spin_id2=None, pipe=None): """Return the interatomic data container for the two spins.