c4dynamics.datasets.clear_cache#
- c4dynamics.datasets.clear_cache(dataset: str | None = None) None [source]#
Deletes datasets from the local cache.
If a dataset name is provided, the function deletes this alone. Otherwise, clears all the cache.
- Parameters:
dataset (str, optional) – The name of the dataset to delete.
Examples
>>> import c4dynamics as c4d >>> from matplotlib import pyplot as plt >>> import matplotlib.image as mpimg >>> import os
Delete a dataset file
>>> # download and verify >>> impath = c4d.datasets.image('planes') Fetched successfully >>> print(os.path.exists(impath)) True >>> # clear and verify >>> c4d.datasets.clear_cache('planes') >>> print(os.path.exists(impath)) False
Clear all
>>> # download all >>> c4d.datasets.download_all() Fetched successfully Fetched successfully Fetched successfully Fetched successfully Fetched successfully Fetched successfully Fetched successfully >>> # clear all and verify >>> c4d.datasets.clear_cache() >>> for root, dirs, files in os.walk(CACHE_DIR): ... for file in files: ... print(os.path.join(root, file)) ... for dir in dirs: ... print(os.path.join(root, dir))