feat(ops): Coordinate, NoMatch and isel_coords in pipekit-ops, and DimArray stores its labels as Labels coordinates
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 38/100
Research direction
Start with pipekit_ops/carriers/_coords.py, pipekit_array/named/, and pipekit_array/named/_carrier.py; use the referenced design and q1_coordinates.py as guides. Implement the coordinate protocol and migrate DimArray label handling, then update the adapter documentation. Done means the listed slicing oracle, adapter tests, import constraint, JIT behavior, lint, and type checks all pass.
Written by the indexing model from the issue text.
Description
Problem / Request
Add the coordinate protocol to pipekit-ops (Coordinate, NoMatch, isel_coords) and a Labels coordinate to pipekit-array, and make DimArray store its labels as Labels, so slicing metadata is written once for every carrier instead of in each adapter.
Motivation
Each adapter slices its own metadata in isel, rebuilds itself in rewrap, and decides what it becomes when a dim goes: DimArrayAdapter spends 65 lines on isel, rewrap and relabel. geoarray already has a better shape, a Coordinate per dim that slices itself (geoarray/_src/coords.py), and coordax has the same (Coordinate._isel). Lifting it into pipekit-ops lets gridax and geoarray share it (CP-D1).
Proposed API
# Shapes: (member, y, x) = (3, 6, 8)
# proposed (CP-D1), pipekit_ops.carriers
class Coordinate(Protocol):
@property
def dim(self) -> str: ...
@property
def size(self) -> int: ...
@property
def labels(self) -> tuple[Any, ...] | None: ...
def isel(self, index) -> Coordinate: ... # a slice or positions; an int drops it, so never called with one
# optional: defining: bool = False; to_xarray() -> dict; from_xarray(dims, coords) -> Self | NoMatch
@dataclass(frozen=True)
class NoMatch:
reason: str
# κ_d[π] for each indexed dim; the coordinate of an int-indexed dim is dropped
def isel_coords(coords: dict[str, Coordinate], indexers: dict[str, Any]) -> dict[str, Coordinate]: ...
# proposed (CP-D1), pipekit_array
@dataclass(frozen=True)
class Labels:
dim: str
values: tuple[Any, ...]
DimArray(data, dims, labels) keeps its constructor and its labels mapping; inside, each labelled dim holds a Labels.
Reuse
geoarray._src.coords.Coordinate(geotoolz-array 0.6.1): the four members to copy.DimArrayAdapter(pipekit_array/named/_carrier.py):isel,rewrap,relabelswitch toisel_coords.
References & Existing Code
- Design:
docs/design/coordax_carriers.mdin jejjohnson/geostack (merged in jejjohnson/geostack#368), "Slicing commutes with coordinates" and pattern 1. - Prototype:
q1_coordinates.py(Labels,generic_isel).
Implementation Steps
-
pipekit_ops/carriers/_coords.pywithCoordinate,NoMatch,isel_coords; export frompipekit_ops.carriers. -
Labelsinpipekit_array/named/;DimArrayandDimArrayAdapteruse it. - Docs: the adapter page says how a coordinate type joins.
Definition of Done
- Q1 oracle:
pa.iselonDimArraygives the same data, dims and labels before and after for an int, a slice, a step slice, a list and two dims at once. -
pipekit_array.testingadapter tests green;import pipekit_arrayloads neither JAX nor xarray. -
jittraces of aDimArrayunchanged (labels stay static). - Lint, type check and tests green.
Relationships
- Parent: jejjohnson/geostack#369
- Blocks: jejjohnson/gridax#627, jejjohnson/geotoolz#849, #407, #410
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 3h 50m
- Merged PRs (30d)
- 143
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from jejjohnson/pipekit
-
area:code layer:0-primitives priority:p2 type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jejjohnson/pipekit#296 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 57/100
jejjohnson/pipekit#411 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 4/5 3-5 days Newbie friendliness 48/100
jejjohnson/pipekit#410 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 5/5 Over a week Newbie friendliness 38/100
jejjohnson/pipekit#409 ·
Maintainers usually reply within 1 day
-
area:code type:feature
Difficulty 3/5 1-2 days Newbie friendliness 75/100
jejjohnson/pipekit#408 ·
Maintainers usually reply within 1 day
All issues in jejjohnson/pipekit
Similar issues
-
bug(operator): VolterraOperator built inside jax.jit with a concrete decay raises TracerBoolConversionErrorPossibly taken @jejjohnson claimed this today. Opentype:bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
jejjohnson/integrix#144 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
finos/ai-governance-framework#459 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
autowarefoundation/autoware_carla_scenario#2963 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
freelawproject/litigant-portal#1307 ·
Maintainers usually reply within 2 days
-
type/bug
Difficulty 1/5 Under an hour Newbie friendliness 86/100
h2oai/h2o-llmstudio#1163 ·
Maintainers usually reply within 1 day