Skip to content

API for selecting arrays by block #3684

@mrocklin

Description

@mrocklin

It might be useful to provide an API to select Dask arrays by block. This would be useful for operations like selecting all internal blocks, selecting every other block, etc.. Presumably this would use numpy-like slicing on an attribute and return a dask array back:

>>> x = da.arange(20, chunks=(5,))
>>> x.blocks[:2] 
dask.array<getitem, shape=(10,), dtype=int64, chunksize=(5,)>

>>> x.blocks[:2] 
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

>>> x.blocks[::2].compute()
array([0, 1, 2, 3, 4, 10, 11, 12, 13, 14])

I think that this was previously mentioned by @shoyer, but I can't find the issue. cc also @jakirkham and @stuartarchibald

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions