Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ overrides.matrix.extras.dependencies = [
overrides.matrix.resolution.features = [
{ if = [ "lowest" ], value = "min-reqs" }, # feature added by hatch-min-requirements
]
overrides.matrix.resolution.dependencies = [
# TODO: move to min dep once this is fixed: https://github.com/tlambert03/hatch-min-requirements/issues/5
{ if = [ "lowest" ], value = "dask==2023.5.1" },
]

[[tool.hatch.envs.hatch-test.matrix]]
python = [ "3.13", "3.11" ]
Expand Down
13 changes: 10 additions & 3 deletions src/fast_array_utils/_plugins/dask.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
# SPDX-License-Identifier: MPL-2.0
from __future__ import annotations

from dask.array.dispatch import concatenate_lookup, take_lookup, tensordot_lookup
from dask.array.dispatch import concatenate_lookup, tensordot_lookup
from scipy.sparse import sparray, spmatrix


try:
from dask.array.dispatch import take_lookup
except ImportError:
take_lookup = None


# TODO(flying-sheep): upstream
# https://github.com/dask/dask/issues/11749
def patch() -> None: # pragma: no cover
Expand All @@ -13,9 +19,10 @@ def patch() -> None: # pragma: no cover
See <https://github.com/dask/dask/blob/d9b5c5b0256208f1befe94b26bfa8eaabcd0536d/dask/array/backends.py#L239-L241>
"""
# Avoid patch if already patched or upstream support has been added
if concatenate_lookup.dispatch(sparray) is not concatenate_lookup.dispatch(spmatrix):
if concatenate_lookup.dispatch(sparray) is concatenate_lookup.dispatch(spmatrix):
return

concatenate_lookup.register(sparray, concatenate_lookup.dispatch(spmatrix))
tensordot_lookup.register(sparray, tensordot_lookup.dispatch(spmatrix))
take_lookup.register(sparray, take_lookup.dispatch(spmatrix))
if take_lookup is not None:
take_lookup.register(sparray, take_lookup.dispatch(spmatrix))
Loading