Skip to content

Fix raise_non_differentiable_error type#361

Merged
ValerianRey merged 1 commit intomainfrom
fix-hook-type-hint
May 27, 2025
Merged

Fix raise_non_differentiable_error type#361
ValerianRey merged 1 commit intomainfrom
fix-hook-type-hint

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey commented May 27, 2025

By contravariance, the type of the _ parameter must be a supertype of the type of the expected parameter for a backward hook, which is tuple[Tensor, ...] | Tensor. Indeed, this hook is supposed to work even if a single Tensor is passed to it.

This was highlighted by MyPy.

@ValerianRey ValerianRey added package: aggregation cc: fix Conventional commit type for bug fixes of the actual library (changes to src). labels May 27, 2025
@ValerianRey ValerianRey self-assigned this May 27, 2025
@ValerianRey ValerianRey added package: aggregation cc: fix Conventional commit type for bug fixes of the actual library (changes to src). labels May 27, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented May 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

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

@ValerianRey ValerianRey changed the title Fix hook type hint Fix raise_non_differentiable_error type May 27, 2025
@ValerianRey ValerianRey merged commit 9b3cc37 into main May 27, 2025
16 checks passed
@ValerianRey ValerianRey deleted the fix-hook-type-hint branch May 27, 2025 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: fix Conventional commit type for bug fixes of the actual library (changes to src). package: aggregation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant