def broadcast_trick(func):
    '\n    Provide a decorator to wrap common numpy function with a broadcast trick.\n\n    Dask arrays are currently immutable; thus when we know an array is uniform,\n    we can replace the actual data by a single value and have all elements point\n    to it, thus reducing the size.\n\n    >>> x = np.broadcast_to(1, (100,100,100))\n    >>> x.base.nbytes\n    8\n\n    Those array are not only more efficient locally, but dask serialisation is\n    aware of the _real_ size of those array and thus can send them around\n    efficiently and schedule accordingly.\n\n    Note that those array are read-only and numpy will refuse to assign to them,\n    so should be safe.\n    '
    inner = _broadcast_trick_inner(func)
    if (func.__doc__ is not None):
        inner.__doc__ = func.__doc__
        inner.__name__ = func.__name__
        if inner.__name__.endswith('_like_safe'):
            inner.__name__ = inner.__name__[:(- 10)]
    return inner
Provide a decorator to wrap common numpy function with a broadcast trick.

Dask arrays are currently immutable; thus when we know an array is uniform,
we can replace the actual data by a single value and have all elements point
to it, thus reducing the size.

>>> x = np.broadcast_to(1, (100,100,100))
>>> x.base.nbytes
8

Those array are not only more efficient locally, but dask serialisation is
aware of the _real_ size of those array and thus can send them around
efficiently and schedule accordingly.

Note that those array are read-only and numpy will refuse to assign to them,
so should be safe.
def broadcast_trick(func):
    '\n    Provide a decorator to wrap common numpy function with a broadcast trick.\n\n    Dask arrays are currently immutable; thus when we know an array is uniform,\n    we can replace the actual data by a single value and have all elements point\n    to it, thus reducing the size.\n\n    >>> x = np.broadcast_to(1, (100,100,100))\n    >>> x.base.nbytes\n    8\n\n    Those array are not only more efficient locally, but dask serialisation is\n    aware of the _real_ size of those array and thus can send them around\n    efficiently and schedule accordingly.\n\n    Note that those array are read-only and numpy will refuse to assign to them,\n    so should be safe.\n    '
    inner = _broadcast_trick_inner(func)
    if (func.__doc__ is not None):
        inner.__doc__ = func.__doc__
        inner.__name__ = func.__name__
        if inner.__name__.endswith('_like_safe'):
            inner.__name__ = inner.__name__[:(- 10)]
    return inner