[ase-users] bug in read traj file

Jens Jørgen Mortensen jjmo at dtu.dk
Thu Nov 21 15:10:09 CET 2019


Den 21.11.2019 kl. 09.40 skrev Jens Jørgen Mortensen via ase-users:
> Den 18.11.2019 kl. 18.07 skrev GENG SUN via ase-users:
>> Dear ASE users,
>>
>> I encounter a problem when read the traj file generated by two 
>> different versions of python ase.
>>
>> The struct.traj is generated by python-3.7.3 and ase-3.19.0b1 ( I 
>> don't know why conda installed this version for me).
>>
>> Then when I move the file "struct.traj" to another computer (which has 
>> python3.6 and ase 3.18.1 installed), and try to read it by simply:
> 
> I can reproduce that.  We should fix this before releasing 3.19.

Fixed in https://gitlab.com/ase/ase/merge_requests/1505/diffs

Jens Jørgen

> 
> Thanks for letting us know.
> 
> Jens Jørgen
> 
>>
>> from ase.io <http://ase.io> import read
>> atoms=read("struct.traj")
>>
>> The line complains that:
>>
>> Traceback (most recent call last):
>>    File "read_traj.py", line 2, in <module>
>>      atoms=read("struct.traj")
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/io/formats.py", 
>> line 498, in read
>>      parallel=parallel, **kwargs))
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/io/formats.py", 
>> line 556, in _iread
>>      for dct in io.read(fd, *args, **kwargs):
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/io/trajectory.py", 
>> line 356, in read_traj
>>      yield trj[i]
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/io/trajectory.py", 
>> line 256, in __getitem__
>>      atoms = read_atoms(b)
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/io/trajectory.py", 
>> line 319, in read_atoms
>>      for d in decode(constraints)],
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/io/trajectory.py", 
>> line 319, in <listcomp>
>>      for d in decode(constraints)],
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/constraints.py", 
>> line 20, in dict2constraint
>>      return globals()[dct['name']](**dct['kwargs'])
>> *File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/ase/constraints.py", 
>> line 138, in __init__
>>      srt = np.sort(indices)*
>>    File "<__array_function__ internals>", line 6, in sort
>>    File 
>> "/home/gengsun/anaconda3/envs/py36/lib/python3.6/site-packages/numpy/core/fromnumeric.py", 
>> line 970, in sort
>>      a.sort(axis=axis, kind=kind, order=order)
>>
>>
>> Then I print the "indices" before the line of "srt=np.sort(indices)"
>> and I found that the value of "indices" are:
>>
>> {'__ndarray__': [array([120]), 'int64', array([  0,   1,   2,   3,   
>> 4,    5,   6,   7,   8,   9,  10,  11,  17,
>>          16,  15,  14,  13,  12,  18,  19,  20,  21,  22,  23,  35,  33,
>>          32,  31,  30,  34,  28,  27,  26,  25,  29,  24,  47,  46,  45,
>>          44,  43,  42,  41,  40,  39,  38,  37,  36,  58,  59,  57,  56,
>>          55,  54,  49,  52,  51,  50,  48,  53,  60,  61,  62,  63,  64,
>>          65,  70,  71,  69,  67,  66,  68,  82,  72,  73,  74,  75,  76,
>>          77,  78,  79,  80,  81,  83,  89,  87,  88,  85,  84,  86,  97,
>>         101,  99,  98,  96, 100,  94,  93,  92,  91,  90,  95, 113, 109,
>>         112, 111, 110, 108, 102, 106, 105, 104, 103, 107, 118, 117, 119,
>>         115, 114, 116])]}
>>
>> It seems that "indices" here is a dictionary rather than a numpy array.
>>
>> I wonder how to fix this problem?
>> Since I already have quite a lot of data from the ase 3.19.0b1, hence 
>> I would like to find a method to make them compatible.
>>
>>
>> Thanks so much.
>>
>> Best,
>>
>> Geng
>>
>>
>>
>>
>> _______________________________________________
>> ase-users mailing list
>> ase-users at listserv.fysik.dtu.dk
>> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
>>
> 
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users



More information about the ase-users mailing list