GridTools/gt4py

ProgramWithBoundArgs: pos_or_kw_args need to go to kwargs sometimes

havogt opened this issue · 0 comments

havogt commented

in decorator.py:455, we need to do something like

        full_args = [*args]
        full_kwargs = {**kwargs}
        for index, param in enumerate(self.past_node.params):
            if param.id in self.bound_args.keys():
                if index < len(full_args):
                    full_args.insert(index, self.bound_args[param.id])
                else:
                    full_kwargs[param.id] = self.bound_args[param.id]

        return super()._process_args(tuple(full_args), full_kwargs)

in case we have a bound_arg which need to be provided as kwarg, because all previous pos_or_kw_args are passed as kwargs.

Test case would be something like

@program
def foo(a, b, c):
    ...

bound = foo.with_bound_args(b = True)

bound(a=1,c=2)

currently we try to call foo as foo(True, a=1,c=2) which messes up the order.