/maybe-compute

Avoid recomputing xarray datasets

Primary LanguagePythonOtherNOASSERTION

maybe-compute

License PyPI Python Version CI codecov

to disk caching of computationally intensive functions.

I think this may be a bad idea - probably don't use this. But if you want to then use it like this:

from maybe_compute import maybe_compute, set_maybe_compute_folder
import xarray as xr
import numpy as np

def dataset_maker(a, b):
    "this docstring shows thanks to functools.wraps!"
    return xr.Dataset({"images":xr.DataArray(np.random.randn(10,20)*a +b, dims=('a','b'))})

set_maybe_compute_folder('sign-flip-cartoon')
maybe_compute(dataset_maker,  'yikes.nc')(4,5)

Install

pip install git+https://github.com/ianhi/maybe-compute