mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 23:00: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))
|
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.
|
"""Dump the Obs to a file 'name' of chosen format.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
@ -607,6 +607,8 @@ class Obs:
|
||||||
datatype : str
|
datatype : str
|
||||||
Format of the exported file. Supported formats include
|
Format of the exported file. Supported formats include
|
||||||
"json.gz" and "pickle"
|
"json.gz" and "pickle"
|
||||||
|
description : str
|
||||||
|
Description for output file, only relevant for json.gz format.
|
||||||
path : str
|
path : str
|
||||||
specifies a custom path for the file (default '.')
|
specifies a custom path for the file (default '.')
|
||||||
"""
|
"""
|
||||||
|
@ -617,7 +619,7 @@ class Obs:
|
||||||
|
|
||||||
if datatype == "json.gz":
|
if datatype == "json.gz":
|
||||||
from .input.json import dump_to_json
|
from .input.json import dump_to_json
|
||||||
dump_to_json([self], file_name)
|
dump_to_json([self], file_name, description=description)
|
||||||
elif datatype == "pickle":
|
elif datatype == "pickle":
|
||||||
with open(file_name + '.p', 'wb') as fb:
|
with open(file_name + '.p', 'wb') as fb:
|
||||||
pickle.dump(self, fb)
|
pickle.dump(self, fb)
|
||||||
|
|
Loading…
Add table
Reference in a new issue