/usr/share/pyshared/ase/io/vnl.py is in python-ase 3.6.0.2515-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import numpy as np
from ase.atoms import Atoms
class VNL:
def __setstate__(self, data):
self.data = data
def ac(shape, typecode, data, endian):
x = np.fromstring(data, typecode)
try:
x.shape = shape
except ValueError:
x = x[::2].copy()
x.shape = shape
if np.LittleEndian != endian:
return x.byteswap()
else:
return x
class VNLUnpickler(pickle.Unpickler):
def find_class(self, module, name):
if module == 'VNLATKStorage.Core.Sample':
return VNL
if name == 'array_constructor':
return ac
return pickle.Unpickler.find_class(self, module, name)
def read_vnl(filename):
from cStringIO import StringIO
vnl = VNLUnpickler(StringIO(ZipFile(filename).read('0_object'))).load()
conf = vnl.data['__properties__']['Atomic Configuration'].data
numbers = conf['_dataarray_']
positions = conf['_positions_'].data['_dataarray_']
return Atoms(numbers=numbers, positions=positions)
|