Issue
Problem Description
When using keyword arguments in Simpson().calculate_result() function, fails with IndexError: tuple index out of range. The issue seems to come from expand_func_values_and_squeeze_integral only checking args and not kwargs, so when specifying keyword arguments, args is reduced to (self,) and leads to the previous error
Expected Behavior
Should run properly as when not specifying keywords.
What Needs to be Done
Change expand_func_values_and_squeeze_integral to handle a both only keyword arguments and a mixture of positional and keyword arguments
How Can It Be Tested or Reproduced
Here is a minimal example failing using torchquad v0.4.0
import torch
from torchquad import Simpson
N = 101
integration_domain = torch.tensor([[0.,1.]])
y = torch.randn(N)
x = torch.linspace(integration_domain[0,0], integration_domain[0,1], N)
integrator = Simpson()
integrator.calculate_result(
function_values=y,
dim=1,
n_per_dim=N,
hs=torch.diff(x)[:0],
integration_domain=integration_domain,
)
# fails with IndexError: tuple index out of range
Issue
Problem Description
When using keyword arguments in
Simpson().calculate_result()function, fails withIndexError: tuple index out of range. The issue seems to come fromexpand_func_values_and_squeeze_integralonly checkingargsand notkwargs, so when specifying keyword arguments,argsis reduced to(self,)and leads to the previous errorExpected Behavior
Should run properly as when not specifying keywords.
What Needs to be Done
Change
expand_func_values_and_squeeze_integralto handle a both only keyword arguments and a mixture of positional and keyword argumentsHow Can It Be Tested or Reproduced
Here is a minimal example failing using torchquad v0.4.0