io
utils.io
Helper functions to handle IO operations.
Functions
| Name | Description |
|---|---|
| from_pickle | Read a pickled object from file. |
| to_pickle | Pickle an object for later reuse. |
from_pickle
utils.io.from_pickle(path)
Read a pickled object from file.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
path |
Union[str, pathlib.Path] | Path of saved pickle file. | required |
Returns
| Type | Description |
|---|---|
| object | Object in pickle file. Must have a “.pkl” or “.pickle” file extension. |
Raises
| Type | Description |
|---|---|
| TypeError | path is not a string or a pathlib.Path type. |
| FileNotFoundError | path does not exist |
| ValueError | path does not have either a “.pkl” or “.pickle” file extension. |
to_pickle
utils.io.to_pickle(picklable_object, path)
Pickle an object for later reuse.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
picklable_object |
Any | Object to be saved to pickle file. If the directory does not exist one will be generated. | required |
path |
Union[str, pathlib.Path] | Path to save pickle file. Must have a “.pkl” or “.pickle” file extension or it will be coerced to “.pkl”. | required |
Raises
| Type | Description |
|---|---|
| UserWarning | When path does not have a “.pkl” or “.pickle” file extension. The warning will signify for coercion to a path with the “.pkl” extension. |