Skip to content

Instantly share code, notes, and snippets.

@raybellwaves
Created March 17, 2021 01:35
Show Gist options
  • Save raybellwaves/fe5c941eea0a885616c3c1cb3d8627b3 to your computer and use it in GitHub Desktop.
Save raybellwaves/fe5c941eea0a885616c3c1cb3d8627b3 to your computer and use it in GitHub Desktop.
import dask
import dask.array as da
import numpy as np
from ..core import histogram
def empty_dask_array(shape, dtype=float, chunks=None):
# a dask array that errors if you try to compute it
def raise_if_computed():
raise ValueError('Triggered forbidden computation')
a = da.from_delayed(dask.delayed(raise_if_computed)(), shape, dtype)
if chunks is not None:
a = a.rechunk(chunks)
return a
shape = 10, 15, 12, 20
b = empty_dask_array(shape, chunks=(1,) + shape[1:])
bins = np.linspace(-4, 4, 27)
block_size = None
c = histogram(b, bins=bins, block_size=block_size)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment