Skip to content

refactor(aggregation): Fix typing issue in Weighting#539

Merged
ValerianRey merged 1 commit intomainfrom
fix-type-error-weighting
Jan 29, 2026
Merged

refactor(aggregation): Fix typing issue in Weighting#539
ValerianRey merged 1 commit intomainfrom
fix-type-error-weighting

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey commented Jan 29, 2026

Since #522, we don't use type annotations anymore, so a new (user-facing) typing issue that we already had for a long time is now visible: in autogram usage examples, we call weighting(gramian) where gramian is a Tensor (but not a PSDMatrix), but weighting.__call__ expects a PSDMatrix.

I changed weighting.__call__ to rather expect a Tensor (like Aggregator.__call__ expects a Tensor and not a Matrix). I thus also made the _T type variable bound to Tensor.

This fixes the issue, but it also doesn't seem to be a very good long-term solution. I don't really like that the user-facing types "lie" to the user. Maybe we could make those types (Matrix and PSDMatrix) public at some point?

@ValerianRey ValerianRey added package: aggregation cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements labels Jan 29, 2026
@ValerianRey ValerianRey self-assigned this Jan 29, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/torchjd/aggregation/_weighting_bases.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@PierreQuinton PierreQuinton left a comment

Choose a reason for hiding this comment

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

Good enough for now, but yeah, one day we might make them public though, even if this can be annoying (for isntance the function torch.eye doesn't returns a PSDMatrix, but it should). I think for now, those types are just for us to not screw things up, but the interface should be agnostic to them.

@ValerianRey ValerianRey changed the title refactor(aggregation): Fix user-facing typing error refactor(aggregation): Fix typing issue in Weighting Jan 29, 2026
@ValerianRey ValerianRey merged commit d4e9957 into main Jan 29, 2026
15 checks passed
@ValerianRey ValerianRey deleted the fix-type-error-weighting branch January 29, 2026 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements package: aggregation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants