mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
fix: Obs.dump can now be provided with a description for the json.gz
file
This commit is contained in:
parent
698d1a7d57
commit
e80fde6630
1 changed files with 4 additions and 2 deletions
|
@ -597,7 +597,7 @@ class Obs:
|
|||
|
||||
return dict(zip(self.e_names, sizes))
|
||||
|
||||
def dump(self, filename, datatype="json.gz", **kwargs):
|
||||
def dump(self, filename, datatype="json.gz", description="", **kwargs):
|
||||
"""Dump the Obs to a file 'name' of chosen format.
|
||||
|
||||
Parameters
|
||||
|
@ -607,6 +607,8 @@ class Obs:
|
|||
datatype : str
|
||||
Format of the exported file. Supported formats include
|
||||
"json.gz" and "pickle"
|
||||
description : str
|
||||
Description for output file, only relevant for json.gz format.
|
||||
path : str
|
||||
specifies a custom path for the file (default '.')
|
||||
"""
|
||||
|
@ -617,7 +619,7 @@ class Obs:
|
|||
|
||||
if datatype == "json.gz":
|
||||
from .input.json import dump_to_json
|
||||
dump_to_json([self], file_name)
|
||||
dump_to_json([self], file_name, description=description)
|
||||
elif datatype == "pickle":
|
||||
with open(file_name + '.p', 'wb') as fb:
|
||||
pickle.dump(self, fb)
|
||||
|
|
Loading…
Add table
Reference in a new issue