def get_string(self):
"""
Returns:
String representation of YAML type
"""
d = Counter(self.atoms_name_list)
ordered_atoms = OrderedDict(sorted(d.items(),
key=lambda x: Specie(x[0]).Z))
if 'G' in ordered_atoms:
del ordered_atoms['G']
comment = ''.join(['{}{}'.format(k, v)
for k, v in ordered_atoms.items()])
output = {'comment': comment,
'lattice': self.lattice.tolist(),
'positions': self.positions.tolist(),
'numbers': self.numbers.tolist(),
'zoom': self.zoom}
return yaml.dump(output)
评论列表
文章目录