mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-16 23:30:24 +01:00
Merge branch 'develop' into documentation
This commit is contained in:
commit
17a435cae1
4 changed files with 36 additions and 34 deletions
|
@ -246,10 +246,10 @@ See `pyerrors.obs.Obs.export_jackknife` for details.
|
||||||
from .obs import *
|
from .obs import *
|
||||||
from .correlators import *
|
from .correlators import *
|
||||||
from .fits import *
|
from .fits import *
|
||||||
|
from .misc import *
|
||||||
from . import dirac
|
from . import dirac
|
||||||
from . import input
|
from . import input
|
||||||
from . import linalg
|
from . import linalg
|
||||||
from . import misc
|
|
||||||
from . import mpm
|
from . import mpm
|
||||||
from . import roots
|
from . import roots
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ import numpy as np
|
||||||
import autograd.numpy as anp
|
import autograd.numpy as anp
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import scipy.linalg
|
import scipy.linalg
|
||||||
from .obs import Obs, dump_object, reweight, correlate
|
from .obs import Obs, reweight, correlate
|
||||||
|
from .misc import dump_object
|
||||||
from .fits import least_squares
|
from .fits import least_squares
|
||||||
from .linalg import eigh, inv, cholesky
|
from .linalg import eigh, inv, cholesky
|
||||||
from .roots import find_root
|
from .roots import find_root
|
||||||
|
|
|
@ -1,7 +1,40 @@
|
||||||
|
import pickle
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from .obs import Obs
|
from .obs import Obs
|
||||||
|
|
||||||
|
|
||||||
|
def dump_object(obj, name, **kwargs):
|
||||||
|
"""Dump object into pickle file.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
obj : object
|
||||||
|
object to be saved in the pickle file
|
||||||
|
name : str
|
||||||
|
name of the file
|
||||||
|
path : str
|
||||||
|
specifies a custom path for the file (default '.')
|
||||||
|
"""
|
||||||
|
if 'path' in kwargs:
|
||||||
|
file_name = kwargs.get('path') + '/' + name + '.p'
|
||||||
|
else:
|
||||||
|
file_name = name + '.p'
|
||||||
|
with open(file_name, 'wb') as fb:
|
||||||
|
pickle.dump(obj, fb)
|
||||||
|
|
||||||
|
|
||||||
|
def load_object(path):
|
||||||
|
"""Load object from pickle file.
|
||||||
|
|
||||||
|
Parameters
|
||||||
|
----------
|
||||||
|
path : str
|
||||||
|
path to the file
|
||||||
|
"""
|
||||||
|
with open(path, 'rb') as file:
|
||||||
|
return pickle.load(file)
|
||||||
|
|
||||||
|
|
||||||
def gen_correlated_data(means, cov, name, tau=0.5, samples=1000):
|
def gen_correlated_data(means, cov, name, tau=0.5, samples=1000):
|
||||||
""" Generate observables with given covariance and autocorrelation times.
|
""" Generate observables with given covariance and autocorrelation times.
|
||||||
|
|
||||||
|
|
|
@ -1527,38 +1527,6 @@ def pseudo_Obs(value, dvalue, name, samples=1000):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
def dump_object(obj, name, **kwargs):
|
|
||||||
"""Dump object into pickle file.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
obj : object
|
|
||||||
object to be saved in the pickle file
|
|
||||||
name : str
|
|
||||||
name of the file
|
|
||||||
path : str
|
|
||||||
specifies a custom path for the file (default '.')
|
|
||||||
"""
|
|
||||||
if 'path' in kwargs:
|
|
||||||
file_name = kwargs.get('path') + '/' + name + '.p'
|
|
||||||
else:
|
|
||||||
file_name = name + '.p'
|
|
||||||
with open(file_name, 'wb') as fb:
|
|
||||||
pickle.dump(obj, fb)
|
|
||||||
|
|
||||||
|
|
||||||
def load_object(path):
|
|
||||||
"""Load object from pickle file.
|
|
||||||
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
path : str
|
|
||||||
path to the file
|
|
||||||
"""
|
|
||||||
with open(path, 'rb') as file:
|
|
||||||
return pickle.load(file)
|
|
||||||
|
|
||||||
|
|
||||||
def import_jackknife(jacks, name, idl=None):
|
def import_jackknife(jacks, name, idl=None):
|
||||||
"""Imports jackknife samples and returns an Obs
|
"""Imports jackknife samples and returns an Obs
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue