Example #1
0
    def postrun(self):
        #get gradients and save them to the pickle files for ASE
        path = self.path
        for child in self.children:
            res = child.results
            name = child.name
            # don't rely on gradients beeing numpy arrays
            f = [ npa(vec) for vec in self.get_grad(res, eUnit='eV', lUnit='Angstrom') ]
            force = -1.0 * npa(self.reorder(res, f))
            filename = osPJ(path, name+'.pckl')
            with open(filename, 'wb') as f:
                pickleDump(force, f, protocol=2)

        self.results._vib = self._vib
Example #2
0
    def postrun(self):
        #get gradients and save them to the pickle files for ASE
        forces = {}
        for name, child in self.children.items():
            res = child.results
            # don't rely on gradients beeing numpy arrays
            f = [
                npa(vec) for vec in self.get_grad(
                    res, energy_unit='eV', dist_unit='Angstrom')
            ]
            forces[name + '.pckl'] = -1.0 * npa(f)
        filename = osPJ(self.path, self.name + '.all.pckl')
        with open(filename, 'wb') as f:
            pickleDump(forces, f, protocol=2)

        self.results._vib = self._vib
Example #3
0
 def __call__(self, *args, **kwargs):
     self.handler()
     ext = Data.get('Ext', None)
     if ext == None:
         return Response(dumps({'message': 'Not Found extension'}),
                         status=404)
     else:
         txtFile = Data.get('filename', None)
         if txtFile == None:
             return Response(dumps({'message': 'Not Found text file'}),
                             status=404)
         else:
             f = open(txtFile, 'rb')
             fl = pickleDump(f.readlines())
             f.close()
             return Response(dumps({
                 'data': fl,
                 'message': 'OK',
                 'extension': ext,
                 "IP": self.GetCurrentIp()
             }),
                             status=200)
Example #4
0
from pickle import load as pickleLoad,dump as pickleDump
from json import load as jsonLoad,dumps as jsonDumps,dump as jsonDump
from csv import reader,writer,QUOTE_MINIMAL
from struct import pack,unpack
from types import FunctionType

#pickle me permite guardan la informacion tal como es escrita
#el metodo dump me permite agregar
#el metodo load cargar datos
tupla1=('led','cars')
try :
    lectura=open('orellyPython/chapter9_x/p18_1.pkl',mode='rb')
    print(pickleLoad(lectura))
except FileNotFoundError:
    with open('orellyPython/chapter9_x/p18_1.pkl',mode='wb') as f:
        pickleDump(tupla1,f)



diccionario1=dict(raza='Rotwailer',nombre='Zeus')
try :
    lectura=open('orellyPython/chapter9_x/p18_1.json',mode='r')
    print(jsonLoad(lectura))
    lectura.close()
except FileNotFoundError:
    with open('orellyPython/chapter9_x//p18_1.json',mode='w') as f:
        #LA SENTENCIA DESPUES DEL WITH puede ser declarada en fp,osea open(..)
        jsonDump(diccionario1,fp=f,indent=4)
        #print(jsonDumps(diccionario1,indent=4),file=f)
        #f.write(jsonDumps(diccionario1,indent=4))
Example #5
0
File: crypto.py Project: jm-/voiz
 def save(self):
     with open(self.path, 'wb') as fp:
         pickleDump(self.cache, fp)