Add Slicing tests, annotations.#946
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #946 +/- ##
==========================================
+ Coverage 88.69% 88.79% +0.09%
==========================================
Files 89 89
Lines 5052 5060 +8
Branches 645 646 +1
==========================================
+ Hits 4481 4493 +12
+ Misses 425 423 -2
+ Partials 146 144 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| def test_slice_origin(raa): | ||
| assert raa[raa.origin > "1985"].shape == (1, 1, 5, 10) | ||
| raa.loc[..., raa.origin <= "1994", :] | ||
| _= raa.loc[..., raa.origin <= "1994", :] |
There was a problem hiding this comment.
is this doing anything? do you want to make it into another assert?
There was a problem hiding this comment.
I went ahead and added some assertions in lines that didn't have any. There are still a couple outstanding regarding .iat and .at, I have yet to annotate/explore those classes in slicing.py so I've left those for a future PR - probably 2 steps into the future as TriangleSlicer is next on the PR queue. The one after that will likely combine work onAT/IAT/VirtualColumns to complete the slicing annotations & coverage gaps.
Summary of Changes
Adding some tests for uncovered lines in
slice.py. Add some docstrings and typing forLocactionclass.Related GitHub Issue(s)
#486
Additional Context for Reviewers
uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)Note
Low Risk
Changes are mostly annotations, docs, and tests; sparse COO rebuild is a small refactor in an already-used code path with new tests guarding behavior.
Overview
Adds typing, module docstring, and docstrings across Triangle
.loc/.ilocslicing inslice.py, including a new_LabelKeyalias intyping.pyfor label-based indexers.Implementation tweaks:
sparse._slicingis loaded viaimportlibinstead of a direct import; sparse single-cell updates in_sparse_setitemuse explicitCOOtyping and keyword construction; severaltype()checks becomeisinstance.Tests:
test_slicing.pygains stricter assertions (origin/development bounds, missingassertonlink_ratio), coverage for invalid.loccolumn keys,.atassignment from aTriangleSlicer, and minor hygiene (_=for intentional reads).Reviewed by Cursor Bugbot for commit 219b586. Bugbot is set up for automated code reviews on this repo. Configure here.