Skip to content

Add Slicing tests, annotations.#946

Merged
genedan merged 6 commits into
mainfrom
slicing_tests
Jun 10, 2026
Merged

Add Slicing tests, annotations.#946
genedan merged 6 commits into
mainfrom
slicing_tests

Conversation

@genedan

@genedan genedan commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Summary of Changes

Adding some tests for uncovered lines in slice.py. Add some docstrings and typing for Locaction class.

Related GitHub Issue(s)

#486

Additional Context for Reviewers

  • I passed tests locally for both code (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/.iloc slicing in slice.py, including a new _LabelKey alias in typing.py for label-based indexers.

Implementation tweaks: sparse._slicing is loaded via importlib instead of a direct import; sparse single-cell updates in _sparse_setitem use explicit COO typing and keyword construction; several type() checks become isinstance.

Tests: test_slicing.py gains stricter assertions (origin/development bounds, missing assert on link_ratio), coverage for invalid .loc column keys, .at assignment from a TriangleSlicer, 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.

@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.79%. Comparing base (11f6263) to head (219b586).

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     
Flag Coverage Δ
unittests 88.79% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

Comment thread chainladder/core/tests/test_slicing.py Outdated
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", :]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this doing anything? do you want to make it into another assert?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@genedan genedan merged commit b24f209 into main Jun 10, 2026
17 checks passed
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.

2 participants