Input/Output¶
Input/Output operations.
All the loading functions have the interface load(path, **kwargs)
where kwargs are loader-specific keyword arguments.
Similarly, all the saving functions have the interface save(value, path, **kwargs).
- class dpipe.io.ConsoleArguments[source]¶
Bases:
objectA class that simplifies access to console arguments.
- dpipe.io.load_or_create(path: ~typing.Union[~pathlib.Path, str], create: ~typing.Callable, *args, save: ~typing.Callable = <function save>, load: ~typing.Callable = <function load>, **kwargs)[source]¶
loada file frompathif it exists. Otherwisecreatethe value,saveit topath, and return it.argsandkwargsare passed tocreateas additional arguments.
- dpipe.io.choose_existing(*paths: Union[Path, str]) Path[source]¶
Returns the first existing path from a list of
paths.
- dpipe.io.load(path: Union[Path, str], ext: Optional[str] = None, **kwargs)[source]¶
Load a file located at
path.kwargsare format-specific keyword arguments.- The following extensions are supported:
npy, tif, png, jpg, bmp, hdr, img, csv, dcm, nii, nii.gz, json, mhd, csv, txt, pickle, pkl, config
- dpipe.io.save(value, path: Union[Path, str], **kwargs)[source]¶
Save
valueto a file located atpath.kwargsare format-specific keyword arguments.- The following extensions are supported:
npy, npy.gz, tif, png, jpg, bmp, hdr, img, csv nii, nii.gz, json, mhd, csv, txt, pickle, pkl
- dpipe.io.save_json(value, path: Union[Path, str], *, indent: Optional[int] = None)[source]¶
Dump a json-serializable object to a json file.
- dpipe.io.load_numpy(path: Union[Path, str], *, allow_pickle: bool = True, fix_imports: bool = True, decompress: bool = False)[source]¶
A wrapper around
np.loadwithallow_pickleset to True by default.
- dpipe.io.save_numpy(value, path: Union[Path, str], *, allow_pickle: bool = True, fix_imports: bool = True, compression: Optional[int] = None, timestamp: Optional[int] = None)[source]¶
A wrapper around
np.savethat matches the interfacesave(what, where).