pyg-team / pytorch_geometric

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

Add optional `attr` argument to `BaseData.snapshot` method #9333

Closed nelsonaloysio closed 1 month ago

nelsonaloysio commented 1 month ago

🛠 Proposed Refactor

The snapshot method of a PyG dataset currently requires that the temporal attribute data is stored as dataset.time.

The method supports both node- and edge-level temporal attributes. However, some datasets may include both node- and edge-level temporal data under distinct keys (e.g., time and edge_time), and there is currently no way to specify it.

Moreover, the result of snapshot when passing a node-level or edge-level data is different; the first returns a dataset object with filtered node data only, while the latter returns filtered edge data only, therefore fulfilling different use cases.

In order to avoid having to modify the dataset.time object on e.g. datasets with both attributes, PyG should IMHO ideally support receiving an attr argument that allows to specify the name of the attribute key in which the data is stored.

Suggest a potential alternative/fix

See PR #9335.