|
1 | 1 | import pytest |
2 | 2 | import pandas as pd |
3 | 3 | import pandas.core.frame |
4 | | -from raphtory import Graph, PersistentGraph, PyDirection |
| 4 | +from raphtory import Graph, PersistentGraph |
5 | 5 | from raphtory import algorithms |
6 | 6 | from raphtory import graph_loader |
7 | 7 |
|
@@ -223,8 +223,8 @@ def test_algo_result(): |
223 | 223 | assert len(actual.group_by()[1]) == 8 |
224 | 224 | assert type(actual.to_df()) == pandas.core.frame.DataFrame |
225 | 225 | df = actual.to_df() |
226 | | - expected_result = pd.DataFrame({"Key": [1], "Value": [1]}) |
227 | | - row_with_one = df[df["Key"] == 1] |
| 226 | + expected_result = pd.DataFrame({"Node": 1, "Value": [1]}) |
| 227 | + row_with_one = df[df["Node"] == 1] |
228 | 228 | row_with_one.reset_index(inplace=True, drop=True) |
229 | 229 | assert row_with_one.equals(expected_result) |
230 | 230 | # Algo Str u64 |
@@ -254,7 +254,7 @@ def test_algo_result(): |
254 | 254 | "8": 0.11786468661230831, |
255 | 255 | } |
256 | 256 | assert actual.get_all_with_names() == expected_result |
257 | | - assert actual.get("Not a node") == None |
| 257 | + assert actual.get("Not a node") is None |
258 | 258 | assert len(actual.to_df()) == 8 |
259 | 259 | # algo str vector |
260 | 260 | actual = algorithms.temporally_reachable_nodes(g, 20, 11, [1, 2], [4, 5]) |
@@ -463,19 +463,13 @@ def test_balance_algorithm(): |
463 | 463 | ] |
464 | 464 | for src, dst, val, time in edges_str: |
465 | 465 | g.add_edge(time, src, dst, {"value_dec": val}) |
466 | | - result = algorithms.balance( |
467 | | - g, "value_dec", PyDirection("BOTH"), None |
468 | | - ).get_all_with_names() |
| 466 | + result = algorithms.balance(g, "value_dec", "both", None).get_all_with_names() |
469 | 467 | assert result == {"1": -26.0, "2": 7.0, "3": 12.0, "4": 5.0, "5": 2.0} |
470 | 468 |
|
471 | | - result = algorithms.balance( |
472 | | - g, "value_dec", PyDirection("IN"), None |
473 | | - ).get_all_with_names() |
| 469 | + result = algorithms.balance(g, "value_dec", "in", None).get_all_with_names() |
474 | 470 | assert result == {"1": 6.0, "2": 12.0, "3": 15.0, "4": 20.0, "5": 2.0} |
475 | 471 |
|
476 | | - result = algorithms.balance( |
477 | | - g, "value_dec", PyDirection("OUT"), None |
478 | | - ).get_all_with_names() |
| 472 | + result = algorithms.balance(g, "value_dec", "out", None).get_all_with_names() |
479 | 473 | assert result == {"1": -32.0, "2": -5.0, "3": -3.0, "4": -15.0, "5": 0.0} |
480 | 474 |
|
481 | 475 |
|
|
0 commit comments