xitorch icon indicating copy to clipboard operation
xitorch copied to clipboard

Raise warnings for unused kwargs when using some methods

Open mfkasim1 opened this issue 9 months ago • 0 comments

Some methods, like rootfinder accepts **kwargs that will be passed to the specific method. However, there is no warnings raised when users specify redundant kwargs.

To reproduce:

import torch
from xitorch.optimize import rootfinder

def func1(y, A):  # example function
    return torch.tanh(A @ y + 0.1) + y / 2.0

A = torch.tensor([[1.1, 0.4], [0.3, 0.8]]).requires_grad_()
y0 = torch.zeros((2, 1))  # zeros as the initial guess
yroot = rootfinder(func1, y0, params=(A,), method="broyden1", unused_kwarg=1)  # a warning should be raised here

mfkasim1 avatar May 23 '24 14:05 mfkasim1