Commit 49034427 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Update documentation and rename method

parent cb14c42a
......@@ -18,6 +18,7 @@ def result_file_name(outdir, label):
def read_in_result(outdir, label):
""" Read in a saved .h5 data file """
filename = result_file_name(outdir, label)
if os.path.isfile(filename):
return Result(deepdish.io.load(filename))
......@@ -53,6 +54,7 @@ class Result(dict):
return ''
def save_to_file(self, outdir, label):
""" Writes the Result to a deepdish h5 file """
file_name = result_file_name(outdir, label)
if os.path.isdir(outdir) is False:
os.makedirs(outdir)
......@@ -215,10 +217,10 @@ class Result(dict):
(4 * self.posterior.q + 3) / (3 * self.posterior.q + 4) * self.posterior.q
* self.posterior.a_2 * np.sin(self.posterior.tilt_2))
def check_attribute_match_to_other_result(self, name, other_result):
""" Check attribute name exists in other_result and is the same """
def check_attribute_match_to_other_object(self, name, other_object):
""" Check attribute name exists in other_object and is the same """
A = getattr(self, name, False)
B = getattr(other_result, name, False)
B = getattr(other_object, name, False)
logging.debug('Checking {} value: {}=={}'.format(name, A, B))
if (A is not False) and (B is not False):
typeA = type(A)
......@@ -230,5 +232,3 @@ class Result(dict):
return np.all(A == B)
return False
......@@ -190,6 +190,7 @@ class Sampler(object):
pass
def check_cached_result(self):
""" Check if the cached data file exists and can be used """
logging.debug("Checking cached data")
self.cached_result = read_in_result(self.outdir, self.label)
if self.cached_result:
......@@ -197,7 +198,7 @@ class Sampler(object):
'kwargs']
use_cache = True
for key in check_keys:
if self.cached_result.check_attribute_match_to_other_result(
if self.cached_result.check_attribute_match_to_other_object(
key, self) is False:
logging.debug("Cached value {} is unmatched".format(key))
use_cache = False
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment