Skip to content

Commit 7f2e6d5

Browse files
committed
Doc and type corrections
1 parent 2681706 commit 7f2e6d5

File tree

5 files changed

+33
-16
lines changed

5 files changed

+33
-16
lines changed

pymathics/graph/base.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def graph_helper(
8181
graph_generator_func: Callable,
8282
options: dict,
8383
can_digraph: bool,
84-
graph_layout: str,
84+
graph_layout: Optional[str],
8585
evaluation,
8686
root: Optional[int] = None,
8787
*args,
@@ -124,7 +124,7 @@ def graph_helper(
124124

125125

126126
def has_directed_option(options: dict) -> bool:
127-
return options.get("System`DirectedEdges", False).to_python()
127+
return options.get("System`DirectedEdges", False)
128128

129129

130130
def _process_graph_options(g, options: dict) -> None:
@@ -173,15 +173,15 @@ def _process_graph_options(g, options: dict) -> None:
173173

174174

175175
def _circular_layout(G):
176-
return nx.drawing.circular_layout(G, scale=1.5)
176+
return nx.drawing.circular_layout(G, scale=1)
177177

178178

179179
def _spectral_layout(G):
180-
return nx.drawing.spectral_layout(G, scale=2.0)
180+
return nx.drawing.spectral_layout(G, scale=2)
181181

182182

183183
def _shell_layout(G):
184-
return nx.drawing.shell_layout(G, scale=2.0)
184+
return nx.drawing.shell_layout(G, scale=2)
185185

186186

187187
def _generic_layout(G, warn):

pymathics/graph/collections.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
from pymathics.graph.graphsymbols import SymbolDirectedEdge
99

10+
# There is no user-facing documentation here.
11+
no_doc = True
12+
1013

1114
def _count_edges(counts, edges, sign):
1215
n_directed, n_undirected = counts

pymathics/graph/components.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
class ConnectedComponents(_NetworkXBuiltin):
1717
"""
1818
<url>
19-
:WMA:https://reference.wolfram.com/language/ref/ConnectedComponents.html
20-
</url>
19+
:Strongly connected components:
20+
https://en.wikipedia.org/wiki/Strongly_connected_component</url> (<url>
21+
:NetworkX:
22+
https://networkx.org/documentation/networkx-2.8.8/reference/algorithms/\
23+
generated/networkx.algorithms.components.strongly_connected_components.html</url>, <url>
24+
:WMA:https://reference.wolfram.com/language/ref/ConnectedComponents.html</url>)
2125
2226
<dl>
2327
<dt>'ConnectedComponents'[$g$]
@@ -83,8 +87,13 @@ def eval(
8387
class WeaklyConnectedComponents(_NetworkXBuiltin):
8488
"""
8589
<url>
86-
:WMA:https://reference.wolfram.com/language/ref/WeaklyConnectedComponents.html
87-
</url>
90+
:Weak components:
91+
https://en.wikipedia.org/wiki/Weak_component</url> (<url>
92+
:NetworkX:
93+
https://networkx.org/documentation/networkx-2.8.8/reference/algorithms/\
94+
generated/networkx.algorithms.components.weakly_connected_components.html</url>, <url>
95+
:WMA:
96+
https://reference.wolfram.com/language/ref/WeaklyConnectedComponents.html</url>)
8897
8998
<dl>
9099
<dt>'WeaklyConnectedComponents'[$g$]

pymathics/graph/curated.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import networkx as nx
6+
from typing import Callable, Dict, Optional, Tuple
67
from mathics.core.evaluation import Evaluation
78

89
from pymathics.graph.base import Graph, _NetworkXBuiltin, graph_helper
@@ -11,8 +12,7 @@
1112
class GraphData(_NetworkXBuiltin):
1213
"""
1314
<url>
14-
:WMA:https://reference.wolfram.com/language/ref/GraphData.html
15-
</url>
15+
:WMA link:https://reference.wolfram.com/language/ref/GraphData.html</url>
1616
1717
<dl>
1818
<dt>'GraphData[$name$]'
@@ -25,7 +25,9 @@ class GraphData(_NetworkXBuiltin):
2525

2626
summary_text = "create a graph by name"
2727

28-
def eval(self, name, expression, evaluation: Evaluation, options: dict) -> Graph:
28+
def eval(
29+
self, name, expression, evaluation: Evaluation, options: dict
30+
) -> Optional[Graph]:
2931
"GraphData[name_String, OptionsPattern[GraphData]]"
3032
py_name = name.get_string_value()
3133
fn, layout = WL_TO_NETWORKX_FN.get(py_name, (None, None))
@@ -42,12 +44,13 @@ def eval(self, name, expression, evaluation: Evaluation, options: dict) -> Graph
4244
# if len([p for p in list(parameters) if p.kind in [inspect.Parameter.POSITIONAL_ONLY, inspect.Parameter.POSITIONAL_OR_KEYWORD]]) != 0:
4345
# return
4446
if fn:
45-
g = graph_helper(fn, options, False, evaluation, layout)
46-
g.G.name = py_name
47+
g = graph_helper(fn, options, False, layout, evaluation)
48+
if g is not None:
49+
g.G.name = py_name
4750
return g
4851

4952

50-
WL_TO_NETWORKX_FN = {
53+
WL_TO_NETWORKX_FN: Dict[str, Tuple[Callable, Optional[str]]] = {
5154
"DodecahedralGraph": (nx.dodecahedral_graph, None),
5255
"DiamondGraph": (nx.diamond_graph, "spring"),
5356
"PappusGraph": (nx.pappus_graph, "circular"),

pymathics/graph/parametric.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,12 @@ def eval(
140140
class BinomialTree(_NetworkXBuiltin):
141141
"""
142142
<url>
143+
:Binomial tree:
144+
https://en.wikipedia.org/wiki/Binomial_heap</url> (<url>
143145
:NetworkX:
144146
https://networkx.org/documentation/networkx-2.8.8/reference/\
145147
generated/networkx.generators.classic.binomial_tree.html</url>, <url>
146-
:WMA:https://reference.wolfram.com/language/ref/BinomialTree.html</url>
148+
:WMA:https://reference.wolfram.com/language/ref/BinomialTree.html</url>)
147149
148150
<dl>
149151
<dt>'BinomialTree[$n$]'

0 commit comments

Comments
 (0)