|
5 | 5 | from test.helper import check_evaluation, evaluate, evaluate_value |
6 | 6 | import pytest |
7 | 7 |
|
| 8 | + |
8 | 9 | def setup_module(module): |
9 | 10 | """Load pymathics.graph""" |
10 | 11 | assert evaluate_value('LoadModule["pymathics.graph"]') == "pymathics.graph" |
11 | 12 | evaluate("SortList[list_] := Sort[Map[Sort, list]]") |
12 | 13 |
|
13 | 14 |
|
14 | | - |
15 | 15 | @pytest.mark.skip("Wrong result. Investigate me.") |
16 | 16 | def test_EdgeList(): |
17 | 17 | check_evaluation( |
18 | | - "EdgeList[{1 -> 2, 2 <-> 3}]", |
19 | | - "{DirectedEdge[1, 2], UndirectedEdge[2, 3]}" |
20 | | - ) |
| 18 | + "EdgeList[{1 -> 2, 2 <-> 3}]", "{DirectedEdge[1, 2], UndirectedEdge[2, 3]}" |
| 19 | + ) |
21 | 20 |
|
22 | 21 |
|
23 | | - |
24 | 22 | @pytest.mark.skip("Wrong result. Investigate me.") |
25 | 23 | def test_FindShortestPath(): |
26 | | - check_evaluation( |
27 | | - ( |
28 | | - "g = Graph[{1 -> 2, 2 -> 3, 1 -> 3}, EdgeWeight -> {0.5, a, 3}];" |
29 | | - "a = 0.5; FindShortestPath[g, 1, 3]'"), |
30 | | - "{1, 2, 3}") |
31 | | - check_evaluation("a = 10; FindShortestPath[g, 1, 3]", "{1, 3}") |
32 | | - check_evaluation("a = .;", "Null") |
33 | | - |
34 | | - |
| 24 | + check_evaluation( |
| 25 | + ( |
| 26 | + "g = Graph[{1 -> 2, 2 -> 3, 1 -> 3}, EdgeWeight -> {0.5, a, 3}];" |
| 27 | + "a = 0.5; FindShortestPath[g, 1, 3]'" |
| 28 | + ), |
| 29 | + "{1, 2, 3}", |
| 30 | + ) |
| 31 | + check_evaluation("a = 10; FindShortestPath[g, 1, 3]", "{1, 3}") |
| 32 | + check_evaluation("a = .;", "Null") |
35 | 33 |
|
36 | 34 |
|
37 | 35 | @pytest.mark.skip("This finds d<->a in the position 4 instead 2.") |
38 | 36 | def test_EdgeIndex(): |
39 | | - check_evaluation("EdgeIndex[{c <-> d, d <-> a, a -> e}, d <-> a]", |
40 | | - "2") |
| 37 | + check_evaluation("EdgeIndex[{c <-> d, d <-> a, a -> e}, d <-> a]", "2") |
| 38 | + |
41 | 39 |
|
42 | | - |
43 | 40 | @pytest.mark.parametrize( |
44 | 41 | ("str_expr", "str_expect"), |
45 | 42 | [ |
46 | 43 | ( |
47 | | - ("g = Graph[{1 -> 2, 2 -> 3}, DirectedEdges -> True];" |
48 | | - "EdgeCount[g, _DirectedEdge]"), |
49 | | - "2" |
| 44 | + ( |
| 45 | + "g = Graph[{1 -> 2, 2 -> 3}, DirectedEdges -> True];" |
| 46 | + "EdgeCount[g, _DirectedEdge]" |
| 47 | + ), |
| 48 | + "2", |
50 | 49 | ), |
51 | 50 | ( |
52 | 51 | ( |
53 | 52 | "g = Graph[{1 -> 2, 2 -> 3}, DirectedEdges -> False];" |
54 | | - "EdgeCount[g, _DirectedEdge]"), |
55 | | - "0" |
| 53 | + "EdgeCount[g, _DirectedEdge]" |
| 54 | + ), |
| 55 | + "0", |
56 | 56 | ), |
57 | | - ("EdgeCount[g, _UndirectedEdge]","2") |
58 | | - ] |
| 57 | + ("EdgeCount[g, _UndirectedEdge]", "2"), |
| 58 | + ], |
59 | 59 | ) |
60 | 60 | @pytest.mark.skip("This finds d<->a in the position 4 instead 2.") |
61 | 61 | def test_edgecount(str_expr, str_expect): |
62 | 62 | check_evaluation(str_expr, str_expect) |
63 | 63 |
|
64 | | - |
| 64 | + |
65 | 65 | @pytest.mark.skip("This finds d<->a in the position 4 instead 2.") |
66 | 66 | def test_EdgeIndex(): |
67 | | - check_evaluation("EdgeIndex[{c <-> d, d <-> a, a -> e}, d <-> a]", |
68 | | - "2") |
| 67 | + check_evaluation("EdgeIndex[{c <-> d, d <-> a, a -> e}, d <-> a]", "2") |
| 68 | + |
69 | 69 |
|
70 | 70 | @pytest.mark.skip("This is not properly evaluated. Investigate me") |
71 | 71 | def test_HITSCentrality(): |
72 | | - check_evaluation("g = Graph[{a -> d, b -> c, d -> c, d -> a, e -> c}]; HITSCentrality[g]", |
73 | | - "{{0.292893, 0., 0., 0.707107, 0.}, {0., 1., 0.707107, 0., 0.707107}}") |
| 72 | + check_evaluation( |
| 73 | + "g = Graph[{a -> d, b -> c, d -> c, d -> a, e -> c}]; HITSCentrality[g]", |
| 74 | + "{{0.292893, 0., 0., 0.707107, 0.}, {0., 1., 0.707107, 0., 0.707107}}", |
| 75 | + ) |
| 76 | + |
74 | 77 |
|
75 | 78 | @pytest.mark.skip("Investigate me.") |
76 | 79 | def test_EdgeRules(): |
77 | 80 | check_evaluation( |
78 | | - "EdgeRules[{1 <-> 2, 2 -> 3, 3 <-> 4}]", |
79 | | - "{1 -> 2, 2 -> 3, 3 -> 4}" |
| 81 | + "EdgeRules[{1 <-> 2, 2 -> 3, 3 <-> 4}]", "{1 -> 2, 2 -> 3, 3 -> 4}" |
80 | 82 | ) |
81 | | - |
|
0 commit comments