feat(ops): render_html draws any carrier from its adapter and coordinates, and DimArray gets _repr_html_

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
jupyter, python

Research direction

Read pipekit_ops/carriers/_adapters.py and the referenced docs/design/coordax_carriers.md pattern 6, then check the DimArray implementation and existing display tests. Implement the renderer in pipekit_ops/carriers/_display.py using the adapter and coordinates, and connect DimArray._repr_html_ to it. Done means the NumPy and JAX snapshots pass, traced carriers are identified without reading values, and lint and type checks pass.

Written by the indexing model from the issue text.

Description

area:code type:feature

Problem / Request

Add pipekit_ops.carriers.render_html(x), which draws any registered carrier as an HTML table (dims with sizes, dtype, backend, then one row per coordinate), and give DimArray a _repr_html_ that calls it.

Motivation

The prototype found no _repr_html_, __treescope_repr__ or _repr_mimebundle_ on any of the three carriers; Jupyter shows only DimArray[band x](3, 4), labels=['band']. coordax renders its Field through treescope (CP-D7). One renderer that reads only the adapter and the coordinates keeps the three carriers consistent.

Proposed API

# proposed (CP-D7)
# any carrier → an HTML string; imports nothing
def render_html(x: Any) -> str: ...

class DimArray:
    def _repr_html_(self) -> str:
        return render_html(self)

A coordinate may add a _repr_row_() -> str for its own row; otherwise its repr is used.

Reuse

  • The adapter registry in pipekit_ops/carriers/_adapters.py for dims, data and labels.

References & Existing Code

  • Design: docs/design/coordax_carriers.md in jejjohnson/geostack (merged in jejjohnson/geostack#368), pattern 6 and question CP-O3.

Implementation Steps

  • pipekit_ops/carriers/_display.py.
  • DimArray._repr_html_.

Definition of Done

  • A snapshot test of the HTML for a labelled DimArray on NumPy and on JAX data.
  • Rendering a traced carrier says so instead of reading values.
  • The module imports nothing beyond the standard library.
  • Lint, type check and tests green.

Relationships

  • Parent: jejjohnson/geostack#369
  • Blocked by: #406
  • Blocks: jejjohnson/geotoolz#852, jejjohnson/gridax#630
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.