Skip to content

[TEST]: Add tests for utility_functions.py#831

Open
genedan wants to merge 2 commits into
mainfrom
#830-test-utilities
Open

[TEST]: Add tests for utility_functions.py#831
genedan wants to merge 2 commits into
mainfrom
#830-test-utilities

Conversation

@genedan
Copy link
Copy Markdown
Collaborator

@genedan genedan commented May 21, 2026

Summary of Changes

Add tests for cl.concat(), cl.read_pickle(), cl.maximum(), and cl.minimum().

Related GitHub Issue(s)

Partially addresses #830. Will need additional PRs to cover the rest.

Additional Context for Reviewers

There was a bug in cl.concat() that didn't properly re-order each triangle's columns prior to the concat, resulting in incorrect indexing. I added a fix along with some minor type annotation changes and docstring edits.

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)

Note

Medium Risk
Medium risk because it changes cl.concat behavior by reordering/aligning columns before concatenation, which could affect downstream assumptions even though it addresses an indexing bug.

Overview
Adds new test coverage for cl.read_pickle, cl.concat (error handling, mismatched columns, axis-1 uniqueness, and optional sorting), and maximum/minimum behavior.

Fixes concat to force consistent column order across inputs (including when columns are missing and filled with nan) before concatenating, updates the signature/type hints for objs, and documents the sort flag.

Reviewed by Cursor Bugbot for commit bb864ab. Bugbot is set up for automated code reviews on this repo. Configure here.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.19%. Comparing base (b748a4d) to head (bb864ab).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #831      +/-   ##
==========================================
+ Coverage   86.90%   87.19%   +0.29%     
==========================================
  Files          86       86              
  Lines        4971     4976       +5     
  Branches      641      642       +1     
==========================================
+ Hits         4320     4339      +19     
+ Misses        462      452      -10     
+ Partials      189      185       -4     
Flag Coverage Δ
unittests 87.19% <100.00%> (+0.29%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

cl.concat([raa, raa], axis=1)


def test_maximum(raa: Triangle) -> None:
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.

can you remind me what's the desired behavior of max on NaN? leave them alone?

)
assert result == expected

def test_read_pickle(raa: Triangle, tmp_path: Path) -> None:
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.

should we also test read_pickle on estimators?

obj[col] = xp.nan
objs[num] = obj
# Make sure columns are in the same order for all objs to ensure proper indexing.
if list(objs[num].columns) != all_columns:
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.

should we kick out a warning here, since we are creating new all-NaN triangles?

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