Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GraphBolt] Modify __repr__ #6953

Merged
merged 7 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
classname
  • Loading branch information
Skeleton003 committed Jan 16, 2024
commit 3c0604aa224370970ab4944468b7d25f1561e341
6 changes: 4 additions & 2 deletions python/dgl/graphbolt/impl/ondisk_dataset.py
Original file line number Diff line number Diff line change
@@ -340,7 +340,7 @@ def test_set(self) -> Union[ItemSet, ItemSetDict]:
return self._test_set

def __repr__(self) -> str:
ret = "OnDiskTask({attributes})"
ret = "{Classname}({attributes})"

attributes_str = ""

@@ -355,7 +355,9 @@ def __repr__(self) -> str:
attributes_str, " " * len("OnDiskTask(")
).strip()

return ret.format(attributes=attributes_str)
return ret.format(
Classname=self.__class__.__name__, attributes=attributes_str
)


class OnDiskDataset(Dataset):
14 changes: 10 additions & 4 deletions python/dgl/graphbolt/impl/torch_based_feature_store.py
Original file line number Diff line number Diff line change
@@ -172,7 +172,7 @@ def pin_memory_(self):

def __repr__(self) -> str:
ret = (
"TorchBasedFeature(\n"
"{Classname}(\n"
" feature={feature},\n"
" metadata={metadata},\n"
")"
@@ -185,7 +185,11 @@ def __repr__(self) -> str:
str(self.metadata()), " " * len(" metadata=")
).strip()

return ret.format(feature=feature_str, metadata=metadata_str)
return ret.format(
Classname=self.__class__.__name__,
feature=feature_str,
metadata=metadata_str,
)


class TorchBasedFeatureStore(BasicFeatureStore):
@@ -252,6 +256,8 @@ def pin_memory_(self):
feature.pin_memory_()

def __repr__(self) -> str:
ret = "TorchBasedFeatureStore(\n" + " {features}\n" + ")"
ret = "{Classname}(\n" + " {features}\n" + ")"
features_str = textwrap.indent(str(self._features), " ").strip()
return ret.format(features=features_str)
return ret.format(
Classname=self.__class__.__name__, features=features_str
)
10 changes: 7 additions & 3 deletions python/dgl/graphbolt/itemset.py
Original file line number Diff line number Diff line change
@@ -177,7 +177,7 @@ def names(self) -> Tuple[str]:

def __repr__(self) -> str:
ret = (
f"ItemSet(\n"
f"{self.__class__.__name__}(\n"
f" items={self._items},\n"
f" names={self._names},\n"
f")"
@@ -339,7 +339,7 @@ def names(self) -> Tuple[str]:

def __repr__(self) -> str:
ret = (
"ItemSetDict(\n"
"{Classname}(\n"
" itemsets={itemsets},\n"
" names={names},\n"
")"
@@ -349,4 +349,8 @@ def __repr__(self) -> str:
repr(self._itemsets), " " * len(" itemsets=")
).strip()

return ret.format(itemsets=itemsets_str, names=self._names)
return ret.format(
Classname=self.__class__.__name__,
itemsets=itemsets_str,
names=self._names,
)