pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21.32k stars 3.65k forks source link

global_add_pool() missing default batch argument #6891

Open qihuazhong opened 1 year ago

qihuazhong commented 1 year ago

🐛 Describe the bug

According to the doc (https://pytorch-geometric.readthedocs.io/en/stable/modules/nn.html#torch_geometric.nn.pool.global_add_pool) and the code. The batch argument should be optional. However, the default None is not provided in the function signature and would raise an error if not provided.

Should be an easy fix by chaning

def global_add_pool(x: Tensor, batch: Optional[Tensor],
                    size: Optional[int] = None) -> Tensor:

to

def global_add_pool(x: Tensor, batch: Optional[Tensor] = None,
                    size: Optional[int] = None) -> Tensor:

Environment

rusty1s commented 1 year ago

Yes, it is optional (meaning you can pass in None) but it does not have a default argument (which is intended).

eurunuela commented 1 week ago

Yes, it is optional (meaning you can pass in None) but it does not have a default argument (which is intended).

It is actually a required argument. If you try to call global_add_pool(x) it will raise an error saying you didn't pass the batch argument. It should be given a default value or the docs should be updated to say that it is a required argument.