Skip to content
Snippets Groups Projects
Commit 8bba093c authored by Colm Talbot's avatar Colm Talbot
Browse files

Merge branch 'master' into improve_conversion

parents 77202e84 b0382bfd
No related branches found
No related tags found
1 merge request!195Improve conversion / change internal parameter logic
......@@ -29,6 +29,8 @@ Changes currently on master, but not under a tag.
- Modified how sampling in non-standard parameters is done, the
`non_standard_sampling_parameter_keys` kwarg has been removed
- .prior files are no longer created. The prior is stored in the result object.
- Users can now choose to overwrite existing result files, rather than creating
a .old file.
### Removed
- Removes the "--detectors" command line argument (not a general CLI requirement)
......
......@@ -167,15 +167,27 @@ class Result(dict):
item = [Result._standardise_a_string(i) for i in item]
return item
def save_to_file(self):
""" Writes the Result to a deepdish h5 file """
def save_to_file(self, overwrite=False):
"""
Writes the Result to a deepdish h5 file
Parameters
----------
overwrite: bool, optional
Whether or not to overwrite an existing result file.
default=False
"""
file_name = result_file_name(self.outdir, self.label)
utils.check_directory_exists_and_if_not_mkdir(self.outdir)
if os.path.isfile(file_name):
logger.debug(
'Renaming existing file {} to {}.old'.format(file_name,
file_name))
os.rename(file_name, file_name + '.old')
if overwrite:
logger.debug('Removing existing file {}'.format(file_name))
os.remove(file_name)
else:
logger.debug(
'Renaming existing file {} to {}.old'.format(file_name,
file_name))
os.rename(file_name, file_name + '.old')
logger.debug("Saving result to {}".format(file_name))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment