Unverified Commit e645d936 authored by Mingbang Wang's avatar Mingbang Wang Committed by GitHub
Browse files

[Misc] polish the python code (#6499)

parent a93b6fec
...@@ -32,17 +32,17 @@ class Task: ...@@ -32,17 +32,17 @@ class Task:
raise NotImplementedError raise NotImplementedError
@property @property
def train_set(self) -> ItemSet or ItemSetDict: def train_set(self) -> Union[ItemSet, ItemSetDict]:
"""Return the training set.""" """Return the training set."""
raise NotImplementedError raise NotImplementedError
@property @property
def validation_set(self) -> ItemSet or ItemSetDict: def validation_set(self) -> Union[ItemSet, ItemSetDict]:
"""Return the validation set.""" """Return the validation set."""
raise NotImplementedError raise NotImplementedError
@property @property
def test_set(self) -> ItemSet or ItemSetDict: def test_set(self) -> Union[ItemSet, ItemSetDict]:
"""Return the test set.""" """Return the test set."""
raise NotImplementedError raise NotImplementedError
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
from collections.abc import Mapping from collections.abc import Mapping
from functools import partial from functools import partial
from typing import Callable, Iterator, Optional from typing import Callable, Iterator, Optional, Union
import numpy as np import numpy as np
import torch import torch
...@@ -200,7 +200,7 @@ class ItemSampler(IterDataPipe): ...@@ -200,7 +200,7 @@ class ItemSampler(IterDataPipe):
Parameters Parameters
---------- ----------
item_set : ItemSet or ItemSetDict item_set : Union[ItemSet, ItemSetDict]
Data to be sampled. Data to be sampled.
batch_size : int batch_size : int
The size of each batch. The size of each batch.
...@@ -391,7 +391,7 @@ class ItemSampler(IterDataPipe): ...@@ -391,7 +391,7 @@ class ItemSampler(IterDataPipe):
def __init__( def __init__(
self, self,
item_set: ItemSet or ItemSetDict, item_set: Union[ItemSet, ItemSetDict],
batch_size: int, batch_size: int,
minibatcher: Optional[Callable] = minibatcher_default, minibatcher: Optional[Callable] = minibatcher_default,
drop_last: Optional[bool] = False, drop_last: Optional[bool] = False,
...@@ -501,7 +501,7 @@ class DistributedItemSampler(ItemSampler): ...@@ -501,7 +501,7 @@ class DistributedItemSampler(ItemSampler):
Parameters Parameters
---------- ----------
item_set : ItemSet or ItemSetDict item_set : Union[ItemSet, ItemSetDict]
Data to be sampled. Data to be sampled.
batch_size : int batch_size : int
The size of each batch. The size of each batch.
...@@ -627,7 +627,7 @@ class DistributedItemSampler(ItemSampler): ...@@ -627,7 +627,7 @@ class DistributedItemSampler(ItemSampler):
def __init__( def __init__(
self, self,
item_set: ItemSet or ItemSetDict, item_set: Union[ItemSet, ItemSetDict],
batch_size: int, batch_size: int,
minibatcher: Optional[Callable] = minibatcher_default, minibatcher: Optional[Callable] = minibatcher_default,
drop_last: Optional[bool] = False, drop_last: Optional[bool] = False,
......
...@@ -45,8 +45,8 @@ class SubgraphSampler(MiniBatchTransformer): ...@@ -45,8 +45,8 @@ class SubgraphSampler(MiniBatchTransformer):
seeds = minibatch.seed_nodes seeds = minibatch.seed_nodes
else: else:
raise ValueError( raise ValueError(
f"Invalid minibatch {minibatch}: Either 'node_pairs' or \ f"Invalid minibatch {minibatch}: Either `node_pairs` or "
'seed_nodes' should have a value." "`seed_nodes` should have a value."
) )
( (
minibatch.input_nodes, minibatch.input_nodes,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment