[ase-users] trajectory/visualize issue

John Kitchin jkitchin at andrew.cmu.edu
Sat Mar 21 17:01:02 CET 2015


    I made a list of atoms objects to view, and I got this error:
        view(images)
      File "/Users/jkitchin/Dropbox/python/ase/ase/visualize/__init__.py",
line 49, in view
        write(fd, atoms, format=format)
      File "/Users/jkitchin/Dropbox/python/ase/ase/io/__init__.py", line
586, in write
        write(filename, images, **kwargs)
      File "/Users/jkitchin/Dropbox/python/ase/ase/io/trajectory.py", line
282, in write_trajectory
        trj = TrajectoryWriter(filename, mode='w')
      File "/Users/jkitchin/Dropbox/python/ase/ase/io/trajectory.py", line
65, in __init__
        self._open(filename, mode)
      File "/Users/jkitchin/Dropbox/python/ase/ase/io/trajectory.py", line
71, in _open
        self.backend = affopen(filename, mode, tag='ASE-Trajectory')
      File "/Users/jkitchin/Dropbox/python/ase/ase/io/aff.py", line 69, in
affopen
        return Writer(filename, mode, tag)
      File "/Users/jkitchin/Dropbox/python/ase/ase/io/aff.py", line 112, in
__init__
        fd = open(fd, 'wb')
    TypeError: coercing to Unicode: need string or buffer, file found

A fix for the issue is to add this to write_trajectory in
ase.io.trajectory

I am not sure this is the right thing to do, since a filename should be
    passed from ase.io.write but a file descriptor is getting sent to
    this .

    if isinstance(filename, file):
        filename = filename.name

alternatively to edit ase.io.__init__.py around line 576

I am not sure what is best.

John

-----------------------------------
Professor John Kitchin
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
@johnkitchin
http://kitchingroup.cheme.cmu.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20150321/c4b69bd9/attachment.html>


More information about the ase-users mailing list