Commit 79b52b78 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Improve file loading

- Adds a filename option for direct loading
- Raise an error if no information given
parent a313d514
Pipeline #19435 failed with stages
in 34 seconds
......@@ -17,13 +17,26 @@ def result_file_name(outdir, label):
return '{}/{}_result.h5'.format(outdir, label)
def read_in_result(outdir, label):
""" Read in a saved .h5 data file """
filename = result_file_name(outdir, label)
def read_in_result(outdir=None, label=None, filename=None):
""" Read in a saved .h5 data file
outdir, label: str
If given, use the default naming convention for saved results file
filename: str
If given, try to load from this filename
result: tupak.result.Result instance
if filename is None:
filename = result_file_name(outdir, label)
if os.path.isfile(filename):
return Result(
return None
raise ValueError("No information given to load file")
class Result(dict):
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