Skip to content

Commit b98cc51

Browse files
authored
fix(aggregation): Place CAGradWeighting docstring before class attributes (#819)
1 parent 2de4301 commit b98cc51

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎src/torchjd/aggregation/_cagrad.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
# Non-differentiable: the cvxpy solver operates on numpy arrays, breaking the autograd graph.
2121
class CAGradWeighting(_WithOptionalDeps, _GramianWeighting, _NonDifferentiable):
22-
_REQUIRED_DEPS = ["numpy", "cvxpy", "clarabel"]
23-
_INSTALL_HINT = 'Install them with: pip install "torchjd[cagrad]"'
2422
"""
2523
:class:`~torchjd.aggregation.Weighting` [:class:`~torchjd.linalg.PSDMatrix`]
2624
giving the weights of :class:`~torchjd.aggregation.CAGrad`.
@@ -37,6 +35,9 @@ class CAGradWeighting(_WithOptionalDeps, _GramianWeighting, _NonDifferentiable):
3735
function.
3836
"""
3937

38+
_REQUIRED_DEPS = ["numpy", "cvxpy", "clarabel"]
39+
_INSTALL_HINT = 'Install them with: pip install "torchjd[cagrad]"'
40+
4041
def __init__(self, c: float, norm_eps: float = 0.0001) -> None:
4142
super().__init__()
4243
self.c = c

‎src/torchjd/aggregation/_nash_mtl.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
# Non-differentiable: the cvxpy solver operates on numpy arrays, breaking the autograd graph.
2424
class _NashMTLWeighting(_WithOptionalDeps, _MatrixWeighting, Stateful, _NonDifferentiable):
25-
_REQUIRED_DEPS = ["numpy", "cvxpy", "ecos"]
26-
_INSTALL_HINT = 'Install them with: pip install "torchjd[nash_mtl]"'
2725
"""
2826
:class:`~torchjd.Stateful`
2927
:class:`~torchjd.aggregation.Weighting` [:class:`~torchjd.linalg.Matrix`] that
@@ -45,6 +43,9 @@ class _NashMTLWeighting(_WithOptionalDeps, _MatrixWeighting, Stateful, _NonDiffe
4543
affects the shape of the cached state).
4644
"""
4745

46+
_REQUIRED_DEPS = ["numpy", "cvxpy", "ecos"]
47+
_INSTALL_HINT = 'Install them with: pip install "torchjd[nash_mtl]"'
48+
4849
def __init__(
4950
self,
5051
n_tasks: int,

0 commit comments

Comments
 (0)