Skip to content

BUG: dask.array.clip fails with missing attribute broadcast_shapes #176

Closed
@lucascolley

Description

@lucascolley
In [2]: from scipy._lib.array_api_compat.dask.array import clip

In [3]: import dask.array as da

In [4]: clip(da.asarray(0), max=7)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[4], line 1
----> 1 clip(da.asarray(0), max=7)

File ~/dev/pixi-dev-scipystack/scipy/scipy/build-install/lib/python3.12/site-packages/scipy/_lib/array_api_compat/_internal.py:28, in get_xp.<locals>.inner.<locals>.wrapped_f(*args, **kwargs)
     26 @wraps(f)
     27 def wrapped_f(*args, **kwargs):
---> 28     return f(*args, xp=xp, **kwargs)

File ~/dev/pixi-dev-scipystack/scipy/scipy/build-install/lib/python3.12/site-packages/scipy/_lib/array_api_compat/common/_aliases.py:284, in clip(x, min, max, xp, out)
    282 min_shape = () if _isscalar(min) else min.shape
    283 max_shape = () if _isscalar(max) else max.shape
--> 284 result_shape = xp.broadcast_shapes(x.shape, min_shape, max_shape)
    286 wrapped_xp = array_namespace(x)
    288 # np.clip does type promotion but the array API clip requires that the
    289 # output have the same dtype as x. We do this instead of just downcasting
    290 # the result of xp.clip() to handle some corner cases better (e.g.,
   (...)
    306 # At least handle the case of Python integers correctly (see
    307 # https://github.com/numpy/numpy/pull/26892).

AttributeError: module 'dask.array' has no attribute 'broadcast_shapes'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions