Skip to content

Commit d812baa

Browse files
authored
Create NDCoord Index + Big Doc improvemntes (#11)
* initial absrel index * update docs for new index * image and coverage * execute * update * doc improvements * ndindex + docs * better test cov * demo notebook fixes * remove old * more doc * performance notebook
1 parent 07da9c1 commit d812baa

18 files changed

+11259
-144
lines changed

AGENTS.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,43 @@ Custom xarray Index implementations for keeping multiple coordinates in sync acr
2020
```bash
2121
uv run pytest # Run tests
2222
uv run jupyter execute <notebook> # Execute a notebook in place
23-
uv run jupyter-book build docs/ # Build docs
24-
uv run jupyter-book start docs/ # Preview docs locally
23+
```
24+
25+
## Documentation
26+
27+
Documentation uses [MyST](https://mystmd.org/) and is located in `docs/`.
28+
29+
### Structure
30+
31+
- `docs/myst.yml` - Configuration file including the Table of Contents (TOC)
32+
- `docs/index.md` - Main landing page
33+
- `docs/*.ipynb` - Example notebooks (rendered as documentation pages)
34+
35+
### Adding New Documentation
36+
37+
1. **Add notebooks to `docs/`**, not `examples/` (which is gitignored)
38+
2. **Update the TOC** in `docs/myst.yml` under `project.toc`
39+
3. Notebooks are executable documentation - ensure they run without errors
40+
41+
### Building Docs
42+
43+
```bash
44+
myst start docs/ # Preview docs locally with hot reload
45+
myst build docs/ # Build static docs
46+
```
47+
48+
### TOC Format (myst.yml)
49+
50+
```yaml
51+
project:
52+
toc:
53+
- file: index.md
54+
- file: my_example.ipynb
55+
title: My Example Title
56+
- title: Section Name
57+
children:
58+
- file: nested_example.ipynb
59+
title: Nested Example
2560
```
2661
2762
## Architecture Notes

docs/alt-multiindex.ipynb

Lines changed: 55 additions & 76 deletions
Large diffs are not rendered by default.
293 KB
Loading
274 KB
Loading
380 KB
Loading

docs/index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@ Custom xarray indexes for keeping multiple coordinates in sync across shared dim
1313
This library provides custom [xarray Index](https://docs.xarray.dev/en/stable/internals/how-to-create-custom-index.html) implementations that automatically constrain related dimensions when you select on any one of them.
1414

1515

16+
### DimensionInterval
17+
18+
The DimensionInterval provides the ability to performantly store arbitrary intervals over a continuous coordinate. Like a multiindex but more generalized. See the [comparison with MultiIndex](alt-multiindex.ipynb) for an understanding of the comparison.
19+
20+
![diagram of possible sel calls for DimensionInterval](images/generic-intervals.png.excalidraw.png)
21+
22+
See the [Multi-Interval Example](multi_interval_example.ipynb) for a detailed walkthrough.
23+
24+
### NDIndex
25+
26+
Provides the ability to select on N-dimensional derived coordinates (like absolute time computed from trial offsets + relative time).
27+
28+
![diagram of two possible abs-rel indexes](images/abs-rel.png.excalidraw.png)
29+
30+
See the [ND Coordinates Example](nd_index_demo.ipynb) for a detailed walkthrough covering trial-based data with both absolute and relative time coordinates.
31+
32+
```{note}
33+
The time-locking/epoching workflow shown in the diagram is not yet implemented. NDIndex currently supports selection on N-D coordinates but does not yet provide utilities for building multiple time reference frames.
34+
```
35+
1636
### Use Cases
1737

1838
- **Speech/audio data** with hierarchical annotations (words, phonemes, time)

docs/multi_interval_example.ipynb

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,7 @@
44
"cell_type": "markdown",
55
"id": "cell-0",
66
"metadata": {},
7-
"source": [
8-
"# Multi-Interval Index Example\n",
9-
"\n",
10-
"This notebook demonstrates how `DimensionInterval` enables automatic cross-slicing between multiple interval types over a shared continuous dimension.\n",
11-
"\n",
12-
"## Use Case: Speech Data\n",
13-
"\n",
14-
"Imagine you have speech data with:\n",
15-
"- A **continuous time dimension** (e.g., audio samples at regular intervals)\n",
16-
"- **Word intervals** - each word spans a range of time\n",
17-
"- **Phoneme intervals** - each phoneme spans a smaller range of time within words\n",
18-
"\n",
19-
"TODO: add an explanatory image\n",
20-
"\n",
21-
"\n",
22-
"When you select a specific word, you want the time and phoneme dimensions to automatically constrain to only the overlapping values. This is exactly what `DimensionInterval` provides."
23-
]
7+
"source": "# Multi-Interval Index Example\n\nThis notebook demonstrates how `DimensionInterval` enables automatic cross-slicing between multiple interval types over a shared continuous dimension.\n\n![Diagram of possible sel calls for DimensionInterval](images/generic-intervals.png.excalidraw.png)\n\nWhen you select a specific word, you want the time and phoneme dimensions to automatically constrain to only the overlapping values. This is exactly what `DimensionInterval` provides.\n\n::::{note}\nThere are two ways to encode intervals with `DimensionInterval`:\n1. **Pandas IntervalIndex** - Used in this notebook, intervals are encoded directly as `pd.IntervalIndex` objects\n2. **Onset/Duration format** - Intervals are specified as separate onset and duration coordinates, see the [Onset/Duration Example](onset_duration_example.ipynb)\n::::\n\n::::{seealso}\nFor a comparison of `DimensionInterval` with xarray's built-in `MultiIndex`, see the [MultiIndex Comparison](alt-multiindex.ipynb) notebook.\n::::"
248
},
259
{
2610
"cell_type": "code",
@@ -43,6 +27,20 @@
4327
"from linked_indices import DimensionInterval"
4428
]
4529
},
30+
{
31+
"cell_type": "markdown",
32+
"id": "271be299-c765-488f-804d-5322552e41e0",
33+
"metadata": {},
34+
"source": [
35+
"\n",
36+
"## Use Case: Speech Data\n",
37+
"\n",
38+
"Imagine you have speech data with:\n",
39+
"- A **continuous time dimension** (e.g., audio samples at regular intervals)\n",
40+
"- **Word intervals** - each word spans a range of time\n",
41+
"- **Phoneme intervals** - each phoneme spans a smaller range of time within words\n"
42+
]
43+
},
4644
{
4745
"cell_type": "markdown",
4846
"id": "cell-2",
@@ -5444,7 +5442,7 @@
54445442
],
54455443
"metadata": {
54465444
"kernelspec": {
5447-
"display_name": "Python 3",
5445+
"display_name": "Python 3 (ipykernel)",
54485446
"language": "python",
54495447
"name": "python3"
54505448
},
@@ -5463,4 +5461,4 @@
54635461
},
54645462
"nbformat": 4,
54655463
"nbformat_minor": 5
5466-
}
5464+
}

docs/myst.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ project:
1616
title: IntervalIndex Example
1717
- file: onset_duration_example.ipynb
1818
title: Onset/Duration Example
19+
- file: nd_index_demo.ipynb
20+
title: ND Coordinates
21+
- file: ndindex_performance.ipynb
22+
title: NDIndex Performance
1923
- title: Gallery
2024
children:
25+
- file: ndindex_slicing_gallery.ipynb
26+
title: NDIndex Slicing
2127
- file: cell_hierarchy_example.ipynb
2228
title: Cell Hierarchy
2329
- file: alternatives.md

0 commit comments

Comments
 (0)