define a chunked array protocol

Open
#100 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Quiet
Tech stack
numpy, python
Domain
api, data

Research direction

Start with the issue's assumptions about abstract chunked arrays and the proposed chunked_array and async_chunked_array signatures. Compare the mentioned array and dlpack protocols and the Zarr array metadata model, then establish agreed synchronous and asynchronous protocol contracts. Done means the abstract representation and both protocol signatures are clearly specified.

Written by the indexing model from the issue text.

Description

dunders like __array__ and __dlpack__ are useful for extracting an array into a numpy array or a dlpack capsule. I'm not aware of a community-supported analog for extracting a chunked array into a chunked array container, like a dask array or a cubed array. This means we need to define an abstract chunked array, and then define a protocol that an implementation of that abstract chunked array would use to instantiate a real chunked array instance.

A few of my assumptions about the abstract chunked array:

  • each chunk has the same data type
  • the chunks are represented on a finite rectilinear grid (regular is a special case)
  • each chunk decodes to the same in-memory array type(s)
  • the grid of chunks must not be dense, so a fill value is required

As data, these assumptions are basically a subset of the Zarr array metadata document, with information about what in-memory array(s) the chunks decode into (e.g., which dunder methods does each decoded chunk define).

So if If we define __chunked_array__ and __async_chunked_array__ protocols for an object that decodes into an arbitrary chunked array, what should their signatures be? Something like __chunked_array__(self) -> Mapping[tuple[int, ...], Callable[[], ArrayLike]], i.e. it returns a mapping from chunk indices to functions that produce chunks? And for the async case, the callable would return a coroutine?

Dominant language
Python
Stars
52
Forks
3
Avg merge
36m
Merged PRs (30d)
5

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from developmentseed/zarrista

All issues in developmentseed/zarrista

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.