aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/utils
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-13 01:12:33 +0800
committerAaron LI <aly@aaronly.me>2017-08-13 01:12:33 +0800
commit2b5b4bd00801a1c05d3a5093d4dd556ff87941ad (patch)
treeb5dd525dd8af6cec53845cb37fe9b20e8ff0e8f6 /fg21sim/utils
parent1cafdb323f88aeb4ea040ced933b62ba2b884f6a (diff)
downloadfg21sim-2b5b4bd00801a1c05d3a5093d4dd556ff87941ad.tar.bz2
utils/io.py: Improve documentations
Diffstat (limited to 'fg21sim/utils')
-rw-r--r--fg21sim/utils/io.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/fg21sim/utils/io.py b/fg21sim/utils/io.py
index 4f05e96..2ce7cda 100644
--- a/fg21sim/utils/io.py
+++ b/fg21sim/utils/io.py
@@ -93,7 +93,7 @@ def pickle_dump(obj, outfile, clobber=False):
NOTE
----
The dumped output file is in binary format, and can be loaded back
- using ``pickle.load()``.
+ using ``pickle.load()``, e.g., the ``pickle_load()`` function below.
Example
-------
@@ -105,6 +105,11 @@ def pickle_dump(obj, outfile, clobber=False):
Parameters
----------
+ outfile : str
+ The path/filename to the output file storing the pickled object.
+ clobber : bool, optional
+ Whether to overwrite the existing output file.
+ Default: False
"""
_create_dir(outfile)
_check_existence(outfile, clobber=clobber, remove=True)
@@ -113,4 +118,17 @@ def pickle_dump(obj, outfile, clobber=False):
def pickle_load(infile):
+ """
+ Load the pickled Python back from the given file.
+
+ Parameters
+ ----------
+ infile : str
+ The path/filename to the data file, e.g., dumped by the above
+ ``pickle_dump()`` function.
+
+ Returns
+ -------
+ obj : The loaded Python object from the input file.
+ """
return pickle.load(open(infile, "rb"))