Skip to content

Commit 00506fc

Browse files
use featurizer
1 parent 08717cb commit 00506fc

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

tests/data/baseline/ml/fastRP.json.gz

0 Bytes
Binary file not shown.

tests/run.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
clear
2-
python3 test/setup.py &&
2+
# python3 test/setup.py &&
33
python3 test/baseline/create_baselines.py &&
4-
pytest test/test_centrality.py &&
4+
# pytest test/test_centrality.py test/test_ml.py
55
pytest test/test_ml.py
6-
# pytest

tests/test/baseline/create_baselines.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,5 @@
22
import fast_rp_baseline
33

44
if __name__ == "__main__":
5-
# degree_cent_baseline.run()
6-
5+
degree_cent_baseline.run()
76
fast_rp_baseline.run()

tests/test/test_ml.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
11
import gzip
22
import json
3-
import os
43

54
import numpy as np
65
import pytest
76
from dotenv import load_dotenv
8-
from pyTigerGraph import TigerGraphConnection
7+
8+
from util import get_featurizer
99

1010
load_dotenv()
1111
data_path_root = "data"
1212
baseline_path_root = f"{data_path_root}/baseline"
1313

1414

15-
conn = TigerGraphConnection(
16-
host=os.environ["HOST_NAME"],
17-
graphname="Cora",
18-
username=os.environ["USER_NAME"],
19-
password=os.environ["PASS"],
20-
)
21-
conn.getToken()
22-
23-
2415
def cos_sim(x, y):
2516
x_mag = np.linalg.norm(x)
2617
y_mag = np.linalg.norm(y)
@@ -29,6 +20,8 @@ def cos_sim(x, y):
2920

3021

3122
class TestML:
23+
feat = get_featurizer("Cora")
24+
3225
def test_fastRP(self):
3326
params = {
3427
"v_type_set": ["Paper"],
@@ -47,10 +40,9 @@ def test_fastRP(self):
4740
with gzip.open(f"{baseline_path_root}/ml/fastRP.json.gz", "rb") as f:
4841
baseline = json.load(f)
4942

50-
result = conn.runInstalledQuery(
43+
result = self.feat.runAlgorithm(
5144
"tg_fastRP",
5245
params=params,
53-
usePost=True,
5446
)
5547
result = {
5648
v["v_id"]: v["attributes"]["res.@final_embedding_list"]
@@ -61,4 +53,4 @@ def test_fastRP(self):
6153
v = result[bk]
6254
sim = abs(cos_sim(v, bv))
6355
if sim < threshold:
64-
pytest.fail(f"cos-sim of {bk} is {sim} (< threshold of {threshold}")
56+
pytest.fail(f"cos-sim of ID: {bk} is {sim} (< threshold of {threshold}")

0 commit comments

Comments
 (0)