Add HERD repr/_repr_html_ surfacing references as a flattened table#1510
Merged
Conversation
A HERD (especially one read back from a file) rendered its six child tables as nested collapsibles that can appear empty in Jupyter. Add a HERD-specific __repr__ and _repr_html_ that show a one-line summary plus the flattened to_dataframe() view, falling back gracefully when there are no references (to_dataframe raises when empty) or the backing file is closed. Addresses #1508. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #1510 +/- ##
=======================================
Coverage 93.19% 93.19%
=======================================
Files 41 41
Lines 10191 10221 +30
Branches 2107 2110 +3
=======================================
+ Hits 9497 9525 +28
- Misses 416 418 +2
Partials 278 278 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
oruebel
approved these changes
Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Fixes #1508.
HERDinherits the genericContainer._repr_html_, which renders its six child tables as nested collapsibles. For aHERDread back from a file these can appear empty at first glance, even though the data is present and accessible viato_dataframe()and the individual tables. The PyNWB HERD tutorial (NeurodataWithoutBorders/pynwb#2200) currently has to warn users about this. The underlying need was raised in NeurodataWithoutBorders/nwb-schema#652.Solution
Add a
HERD-specific__repr__and_repr_html_that show a one-line summary (table sizes) plus the flattenedto_dataframe()view (one row per object/key/entity association). The display falls back gracefully:to_dataframeraises when there are no object-key rows, so the helper guards on that);to_dataframefailure: the existing closed-file warning banner is preserved and the table is omitted rather than raising (a repr must never raise).Display only; no change to stored data or table APIs.
Screenshot
The
_repr_html_of a populatedHERD, rendered as a Jupyter output cell:How to test the behavior
Added
test_repr_emptyandtest_repr_populatedintests/unit/common/test_resources.py(empty HERD reprs do not raise and say "No external resource references"; a populated HERD surfaces the summary line and the entity content in the HTML repr). Fulltests/unit/common/test_resources.pypasses (63 passed, 10 skipped).Checklist
🤖 Generated with Claude Code