Skip to content

Fix get_chunked_array_type rejecting arrays of the same chunk manager - #11565

Open
IMGillusion wants to merge 2 commits into
pydata:mainfrom
IMGillusion:fix-11539-chunked-array-subclass
Open

Fix get_chunked_array_type rejecting arrays of the same chunk manager#11565
IMGillusion wants to merge 2 commits into
pydata:mainfrom
IMGillusion:fix-11539-chunked-array-subclass

Conversation

@IMGillusion

Copy link
Copy Markdown

What this PR does

get_chunked_array_type compared the exact type() of each array, so two
array classes handled by the same chunk manager (e.g. dask.Array and a
subclass of it, or any manager whose is_chunked_array is an
isinstance check against several classes) were reported as a mix of
chunked array types:

TypeError: Mixing chunked array types is not supported, but received
multiple types: {<class 'dask.array.core.Array'>, <class 'MyDaskArray'>}

The check now resolves which chunk manager recognises each array and
requires all arrays to be handled by the same manager. A genuine mix of
frameworks (e.g. a dask array together with a cubed array) still raises
TypeError.

What the PR achieves

Fixes #11539

To test this PR

import dask.array as da
import numpy as np
import xarray as xr

class MyDaskArray(da.Array):
    pass

plain = da.from_array(np.array([1, 2, 3]), chunks=(1,))
subclass = MyDaskArray(plain.dask, plain.name, plain.chunks, plain.dtype)

xr.Dataset({"a": ("x", plain), "b": ("x", subclass)}).load()  # now works

Compare the chunk managers that recognise each array instead of the
exact array types, so a dask array and a subclass of dask.Array are no
longer reported as a mix of chunked array types. A real mix of
frameworks (e.g. dask and cubed) still raises TypeError.

Fixes pydata#11539
@welcome

welcome Bot commented Sep 5, 2026

Copy link
Copy Markdown

Thank you for opening this pull request! It may take us a few days to respond here, so thank you for being patient.
If you have questions, some answers may be found in our contributing guidelines.

@github-actions github-actions Bot added the topic-NamedArray Lightweight version of Variable label Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-NamedArray Lightweight version of Variable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_chunked_array_type rejects two array classes handled by the same chunk manager

1 participant