Skip to content

Add __repr__ and _repr_html_ methods to DimensionInterval and NDIndex#12

Open
ianhi wants to merge 8 commits into
mainfrom
claude/improve-index-repr-Kf6Zg
Open

Add __repr__ and _repr_html_ methods to DimensionInterval and NDIndex#12
ianhi wants to merge 8 commits into
mainfrom
claude/improve-index-repr-Kf6Zg

Conversation

@ianhi
Copy link
Copy Markdown
Owner

@ianhi ianhi commented Dec 20, 2025

Implement informative representations for both index classes:

DimensionInterval repr shows:

  • Continuous dimension (name, size, value range)
  • Interval dimensions with their coords and labels
  • Interval properties (size, range, closed)
  • Indication for onset/duration-derived intervals

NDIndex repr shows:

  • Slice method configuration
  • N-D coordinates (name, dims, shape, value range)

Both classes also provide HTML representations for Jupyter notebooks
with styled tables showing dimension and coordinate information.

Includes comprehensive test coverage for all repr methods.

Implement informative representations for both index classes:

DimensionInterval repr shows:
- Continuous dimension (name, size, value range)
- Interval dimensions with their coords and labels
- Interval properties (size, range, closed)
- Indication for onset/duration-derived intervals

NDIndex repr shows:
- Slice method configuration
- N-D coordinates (name, dims, shape, value range)

Both classes also provide HTML representations for Jupyter notebooks
with styled tables showing dimension and coordinate information.

Includes comprehensive test coverage for all repr methods.
@netlify
Copy link
Copy Markdown

netlify Bot commented Dec 20, 2025

Deploy Preview for xarray-linked-indexes ready!

Name Link
🔨 Latest commit 1960386
🔍 Latest deploy log https://app.netlify.com/projects/xarray-linked-indexes/deploys/6946062e3d18b40008e3e515
😎 Deploy Preview https://deploy-preview-12--xarray-linked-indexes.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

pre-commit-ci Bot and others added 7 commits December 20, 2025 01:55
Create docs/index_repr_demo.ipynb that demonstrates the __repr__ and
_repr_html_ methods for DimensionInterval and NDIndex directly,
outside of xarray's dataset representation context.

The notebook covers:
- DimensionInterval text and HTML repr
- DimensionInterval with onset/duration format
- NDIndex text and HTML repr
- NDIndex with different slice methods
- NDIndex with multiple coordinates
- NDIndex with 3D coordinates
- Repr updates after slicing operations
Updates to DimensionInterval and NDIndex _repr_html_:
- Add dark/light mode CSS with prefers-color-scheme media query
- Add JupyterLab theme detection via [data-jp-theme-light] attribute
- Add expandable "Show interval details" section for DimensionInterval
- Add expandable "Selection examples" section with copy-paste code
- Add expandable "Value preview" section for NDIndex
- Improve color scheme for better readability in both modes

Update docs/index_repr_demo.ipynb:
- Add interactive selection demos for both index types
- Add DimensionInterval selection examples (time, word, part_of_speech)
- Add NDIndex selection examples (scalar, slice, step)
- Document dark mode support
- Fix word label references to match example data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants