Skip to content

Commit bdd11e3

Browse files
[TypeHints] ToDense (#5668)
Co-authored-by: rusty1s <[email protected]>
1 parent 888351b commit bdd11e3

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
4040
- Support `in_channels` with `tuple` in `GENConv` for bipartite message passing ([#5627](https://github.com/pyg-team/pytorch_geometric/pull/5627), [#5641](https://github.com/pyg-team/pytorch_geometric/pull/5641))
4141
- Handle cases of not having enough possible negative edges in `RandomLinkSplit` ([#5642](https://github.com/pyg-team/pytorch_geometric/pull/5642))
4242
- Fix `RGCN+pyg-lib` for `LongTensor` input ([#5610](https://github.com/pyg-team/pytorch_geometric/pull/5610))
43-
- Improved type hint support ([#5603](https://github.com/pyg-team/pytorch_geometric/pull/5603), [#5659](https://github.com/pyg-team/pytorch_geometric/pull/5659), [#5665](https://github.com/pyg-team/pytorch_geometric/pull/5665), [#5666](https://github.com/pyg-team/pytorch_geometric/pull/5666), [#5667](https://github.com/pyg-team/pytorch_geometric/pull/5667))
43+
- Improved type hint support ([#5603](https://github.com/pyg-team/pytorch_geometric/pull/5603), [#5659](https://github.com/pyg-team/pytorch_geometric/pull/5659), [#5665](https://github.com/pyg-team/pytorch_geometric/pull/5665), [#5666](https://github.com/pyg-team/pytorch_geometric/pull/5666), [#5667](https://github.com/pyg-team/pytorch_geometric/pull/5667), [#5668](https://github.com/pyg-team/pytorch_geometric/pull/5668))
4444
- Avoid modifying `mode_kwargs` in `MultiAggregation` ([#5601](https://github.com/pyg-team/pytorch_geometric/pull/5601))
4545
- Changed `BatchNorm` to allow for batches of size one during training ([#5530](https://github.com/pyg-team/pytorch_geometric/pull/5530), [#5614](https://github.com/pyg-team/pytorch_geometric/pull/5614))
4646
- Integrated better temporal sampling support by requiring that local neighborhoods are sorted according to time ([#5516](https://github.com/pyg-team/pytorch_geometric/issues/5516), [#5602](https://github.com/pyg-team/pytorch_geometric/issues/5602))

torch_geometric/transforms/to_dense.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
from typing import Optional
2+
13
import torch
24

5+
from torch_geometric.data import Data
36
from torch_geometric.data.datapipes import functional_transform
47
from torch_geometric.transforms import BaseTransform
58

@@ -10,13 +13,14 @@ class ToDense(BaseTransform):
1013
shape :obj:`[num_nodes, num_nodes, *]` (functional name: :obj:`to_dense`).
1114
1215
Args:
13-
num_nodes (int): The number of nodes. If set to :obj:`None`, the number
14-
of nodes will get automatically inferred. (default: :obj:`None`)
16+
num_nodes (int, optional): The number of nodes. If set to :obj:`None`,
17+
the number of nodes will get automatically inferred.
18+
(default: :obj:`None`)
1519
"""
16-
def __init__(self, num_nodes=None):
20+
def __init__(self, num_nodes: Optional[int] = None):
1721
self.num_nodes = num_nodes
1822

19-
def __call__(self, data):
23+
def __call__(self, data: Data) -> Data:
2024
assert data.edge_index is not None
2125

2226
orig_num_nodes = data.num_nodes

0 commit comments

Comments
 (0)