Skip to content

Commit ea47387

Browse files
committed
feat: separate graph_utils from graph_datasets
1 parent bf9779a commit ea47387

File tree

14 files changed

+5
-1260
lines changed

14 files changed

+5
-1260
lines changed

docs/rst/graph_datasets.utils.rst

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
evaluation
2-
======================
3-
.. automodule:: graph_datasets.utils.evaluation.evaluation
4-
:members:
5-
:show-inheritance:
6-
:exclude-members:
7-
:no-undoc-members:
8-
91
statistics
102
======================
113
.. automodule:: graph_datasets.utils.statistics
@@ -14,27 +6,6 @@ statistics
146
:exclude-members: get_long_edges, get_same_class_deg
157
:no-undoc-members:
168

17-
model management
18-
======================
19-
.. automodule:: graph_datasets.utils.model_management
20-
:members:
21-
:show-inheritance:
22-
:no-undoc-members:
23-
24-
output
25-
======================
26-
.. automodule:: graph_datasets.utils.output
27-
:members:
28-
:show-inheritance:
29-
:no-undoc-members:
30-
31-
plt
32-
======================
33-
.. automodule:: graph_datasets.utils.plt
34-
:members:
35-
:show-inheritance:
36-
:no-undoc-members:
37-
389
common
3910
======================
4011
.. automodule:: graph_datasets.utils.common

graph_datasets/datasets/linkx.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ def load_linkx_data(
134134

135135
if verbosity and verbosity > 1:
136136
print_dataset_info(
137-
dataset_name=f"LINKX Original {dataset_name}",
137+
dataset_name=f"LINKX original {dataset_name}",
138138
n_nodes=g.num_nodes(),
139139
n_edges=g.num_edges(),
140140
n_feats=g.ndata["feat"].shape[1],

graph_datasets/load_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def load_data(
137137

138138
if verbosity:
139139
print_dataset_info(
140-
dataset_name=f"{source} undirected {dataset_name}\nwithout self-loops",
140+
dataset_name=f"{source.upper()} undirected {dataset_name}\nwithout self-loops",
141141
n_nodes=graph.num_nodes(),
142142
n_edges=graph.num_edges(),
143143
n_feats=graph.ndata["feat"].shape[1],

graph_datasets/utils/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,6 @@
22
"""
33
# pylint:disable=invalid-name
44
from .common import *
5-
from .evaluation import evaluate_from_embed_file
6-
from .model_management import check_modelfile_exists
7-
from .model_management import get_modelfile_path
8-
from .model_management import load_model
9-
from .model_management import save_model
10-
from .model_management import set_device
11-
from .model_management import set_seed
12-
from .output import csv2file
13-
from .output import make_parent_dirs
14-
from .output import refresh_file
15-
from .output import save_to_csv_files
16-
from .plt import draw_chart
175
from .statistics import edge_homo
186
from .statistics import node_homo
197
from .statistics import statistics

graph_datasets/utils/bot.py

Lines changed: 0 additions & 83 deletions
This file was deleted.

graph_datasets/utils/common.py

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,14 @@
22
"""
33
import os
44
import sys
5-
from datetime import datetime
65
from typing import Any
76
from typing import Dict
87
from typing import List
98

109
import gdown
11-
import pytz
1210
from texttable import Texttable
1311

1412

15-
def format_result(
16-
dataset: str,
17-
source: str,
18-
model: str,
19-
sort_kw: bool = True,
20-
timezone="Asia/Shanghai",
21-
**kwargs,
22-
):
23-
if sort_kw:
24-
kwargs = dict(sorted(kwargs.items()))
25-
26-
kwargs.update(
27-
{
28-
"ds": dataset,
29-
"src": source,
30-
"model": model,
31-
"time": get_str_time(timezone),
32-
}
33-
)
34-
return kwargs
35-
36-
37-
def get_str_time(timezone="Asia/Shanghai"):
38-
"""Return localtime in the format of %Y-%m-%d-%H:%M:%S."""
39-
40-
# Set the timezone to timezone
41-
pytz_timezone = pytz.timezone(timezone)
42-
43-
# Get the current time in UTC
44-
utc_now = datetime.utcnow()
45-
46-
# Convert UTC time to timezone time
47-
pytz_now = utc_now.replace(tzinfo=pytz.utc).astimezone(pytz_timezone)
48-
49-
return pytz_now.strftime("%Y-%m-%d-%H:%M:%S")
50-
51-
5213
def format_value(value) -> Any:
5314
"""Return number as string with comma split.
5415
@@ -95,8 +56,7 @@ def tab_printer(
9556
[
9657
k.replace("_", " "),
9758
f"{args[k]}" if isinstance(args[k], bool) else format_value(args[k]),
98-
]
99-
for k in keys
59+
] for k in keys
10060
]
10161
)
10262
if cols_align is not None:
@@ -119,9 +79,7 @@ def download_tip(info: Dict) -> None:
11979
data_file (str): filepath.
12080
url (str): url for downloading.
12181
"""
122-
info[
123-
"Tip"
124-
] = "If the download fails, \
82+
info["Tip"] = "If the download fails, \
12583
use the 'Download URL' to download manually and move the file to the 'Save Path'."
12684

12785
tab_printer(info)

graph_datasets/utils/evaluation/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)