Allow any iterator over Atoms objects to be written.
The file formats that allowed writing more than one Atoms object handled it by testing explicitly for the argument being an instance of tuple or list. This patch changes the (reverse) test to check for the presence of the get_positions method; if that is not present it is not an Atoms object, and an iterator over such objects is assumed.
In particular, this allows to write an ase.io.iread
object directly to a different file format, without first reading all configurations into memory.
Examples:
ase.io.write("output.xyz", ase.io.iread("input.traj")) # Convert file format
ase.io.write("output.xyz", modifyer(ase.io.iread("input.traj")))
In the latter example, modifyer
is a generator function that reads configurations one by one, and modifies the configurations somehow.