add iteration for lgdo collections#231
Conversation
There was a problem hiding this comment.
Pull request overview
Adds an iter_chunks method to Table that yields consecutive row-range views of the table, plus tests covering even/uneven divisions, slice equivalence, memory sharing, and invalid input.
Changes:
- New
Table.iter_chunks(chunk_size)generator that validateschunk_size > 0and yieldsself[start:start+chunk_size]for each window. - Imports
Iteratorfromcollections.abc. - Adds
test_iter_chunkscovering happy paths, edge cases, and invalid arguments.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/lgdo/types/table.py | Adds iter_chunks method and Iterator import |
| tests/types/test_table.py | Adds tests for the new chunked iteration API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #231 +/- ##
==========================================
+ Coverage 86.04% 86.09% +0.04%
==========================================
Files 21 21
Lines 1806 1812 +6
==========================================
+ Hits 1554 1560 +6
Misses 252 252 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Array returns a numpy array not an lgdo, do we want to change this? |
|
I think we should always return an LGDO |
|
Yeah agreed. I was reluctant to change this due to fear of breaking things, but I think that's how it should be. If you want a numpy array you call |
Maybe a better way to do this consistently over our types but here is a quick iterator for Table.