Create NDCoord Index + Big Doc improvemntes#11
Merged
Conversation
✅ Deploy Preview for xarray-linked-indexes ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #11 +/- ##
==========================================
+ Coverage 95.02% 95.90% +0.87%
==========================================
Files 5 7 +2
Lines 1066 1685 +619
Branches 74 113 +39
==========================================
+ Hits 1013 1616 +603
- Misses 28 36 +8
- Partials 25 33 +8 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Create a new index for ND coords. e.g.
abs_timein this datasetClaude generated summary:
Add NDIndex for N-D Coordinate Selection
Summary
This PR introduces
NDIndex, a new xarray Index that enables label-based selection on N-dimensional derived coordinates. The primary use case is trial-based data where you have a 2Dabs_timecoordinate (shape:trial × rel_time) computed from trial offsets plus relative time.New Features
NDIndex (
src/linked_indices/nd_index.py)A simple xarray Index for N-D derived coordinates that:
ds.sel(abs_time=7.5, method='nearest')finds the (trial, rel_time) indices nearest to the valueds.sel(abs_time=slice(2, 8))returns a bounding box containing all matching cells"bounding_box"(default): smallest rectangular region containing all matches"trim_outer": like bounding_box but trims outer dimensions more aggressivelyslice(0, 10, 2)applies step to the innermost dimensionisel()with dimension reductionExample Data (
src/linked_indices/example_data.py)trial_based_dataset()function for generating test data with configurable waveforms (sine, cosine, square, sawtooth)Documentation
New Notebooks
nd_index_demo.ipynbndindex_slicing_gallery.ipynbndindex_performance.ipynbUpdated Documentation
index.md: Added NDIndex section with note that time-locking/epoching utilities are not yet implementedmyst.yml: Added new notebooks to table of contentsDiagram Images
abs-rel.png.excalidraw.png: Absolute vs relative time conceptevent-locking.png.excalidraw.png: Event-locking/epoching conceptgeneric-intervals.png.excalidraw.png: DimensionInterval diagramTesting
tests/test_nd_index.pywith 100% code coverageTestNDIndexCreation: Index creation and validationTestNDIndexSelFollower: Scalar selection on N-D coordinatesTestNDIndexSelSlice: Slice selectionTestNDIndexIsel: Integer-based selection and dimension reductionTestNDIndexSliceMethods: Slice method options (bounding_box, trim_outer)TestNDIndexSliceMethods3D: 3D coordinate handlingTestNDIndexBoundingBoxBehavior: Comprehensive bounding box behavior testsPerformance Characteristics
isel()Breaking Changes
None - this is additive functionality.
How to Test