Skip to content

Print heterogeneous data collections as a tree - #92

Merged
atrabattoni merged 2 commits into
devfrom
feature/collection-repr
Oct 16, 2026
Merged

atrabattoni merged 2 commits into
devfrom
feature/collection-repr

Conversation

@atrabattoni

@atrabattoni atrabattoni commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

The flat table repr breaks down as soon as a collection mixes structures, e.g. DAS (node/cable/record) next to seismic stations (network/station/location/channel): unrelated keys end up in the same columns and the headers disappear.

Now the flat table is only used when every level is named, and named the same way across branches. Otherwise the collection prints as a tree, and each well-defined branch collapses into a two-line summary. Index into it to see its table.

<xdas.DataCollection: 6 arrays, 1 table, 19.1 MB>
├── das  (time, distance)  13.4 MB
│   ╰─ node › cable › record  (3 arrays)
├── seismic  (time)  23.4 KB
│   ╰─ network › station › location › channel  (2 arrays)
├── picks  (rows: 2, columns: 2)  32 B
└── stack  (time: 3000, distance: 500)  5.7 MB

Also: empty branches are shown instead of silently dropped, and leaves are counted as arrays and tables rather than "leaves".

A flat table only works for a well-defined collection: every level named,
and named alike across branches. Otherwise the collection prints as a tree
and each homogeneous branch collapses into its dimensions and size, with
its levels and leaf count hooked below; indexing into it shows its table.
Empty branches force the tree so they are never dropped from the output.

Leaves are now counted as arrays and tables, and an empty collection
prints as <xdas.DataCollection: empty>.
@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ddfdf1d) to head (02bba10).

Additional details and impacted files
@@            Coverage Diff            @@
##               dev       #92   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           49        49           
  Lines         9391      9427   +36     
  Branches      1694      1699    +5     
=========================================
+ Hits          9391      9427   +36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@atrabattoni
atrabattoni merged commit c7204ea into dev Oct 16, 2026
9 checks passed
@atrabattoni
atrabattoni deleted the feature/collection-repr branch October 16, 2026 11:43
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.

1 participant