feat(array): pa.shape_struct returns any carrier with ShapeDtypeStruct data, for eval_shape and planning

Open
#411 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
57/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start by reading the carrier pytree registrations and the existing adapter code in pipekit-array; the issue proposes using jax.tree.map and says the adapter’s rewrap is not needed. Check the existing tests for DimArray, CField, and jax.eval_shape to locate where to add coverage. Done means reductions on pa.shape_struct(x) preserve the expected dims and shape for both carriers, with lint, type checks, and tests green.

Written by the indexing model from the issue text.

Description

area:code type:feature

Problem / Request

Add pa.shape_struct(x), which returns the same carrier with every leaf replaced by a jax.ShapeDtypeStruct, so a pipeline can plan its outputs with jax.eval_shape before any data exists.

Motivation

The prototype built DimArray and CField on a ShapeDtypeStruct((3, 64, 64), float32) and jax.eval_shape of a mean over time gave dims ('y', 'x'). Nothing builds such a carrier from an existing one. coordax has shape_struct_field (CP-D8).

Proposed API

# Shapes: (time, y, x) = (3, 64, 64)

# proposed (CP-D8)
# carrier → the same carrier, leaves as ShapeDtypeStruct
spec = pa.shape_struct(x)

# today (pipekit-array)
# DimArray (time, y, x) → DimArray (y, x)
out = jax.eval_shape(lambda f: pa.reduce(f, jnp.mean, "time"), spec)

Reuse

  • jax.tree.map over the carrier's pytree registration; the adapter's rewrap is not needed.

References & Existing Code

  • Design: docs/design/coordax_carriers.md in jejjohnson/geostack (merged in jejjohnson/geostack#368), pattern 7.
  • Prototype: q3_q7_rest.py, section Q7.

Definition of Done

  • eval_shape of a reduction on pa.shape_struct(x) gives the dims and shape of running it, for DimArray and CField.
  • Lint, type check and tests green.

Relationships

  • Parent: jejjohnson/geostack#369
  • Blocks: jejjohnson/geotoolz#853
Dominant language
Python
Stars
0
Forks
0
Avg merge
3h 50m
Merged PRs (30d)
143

Getting set up

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 jejjohnson/pipekit

All issues in jejjohnson/pipekit

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.