Skip to content

Commit 38d2534

Browse files
committed
fix merge
2 parents 0eb482e + dceac5f commit 38d2534

File tree

17 files changed

+181
-150
lines changed

17 files changed

+181
-150
lines changed

.github/workflows/consistency-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v4
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
2424
python -m pip install pytest
25-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
25+
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
2626
git clone https://github.com/Mathics3/mathics-core
2727
(cd mathics-core && make)
2828
(cd mathics-core && python -m pip install -e .[full])

.github/workflows/ubuntu.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,17 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v3
1717
- name: Set up Python ${{ matrix.python-version }}
18-
uses: actions/setup-python@v2
18+
uses: actions/setup-python@v4
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121
- name: Install dependencies
2222
run: |
2323
python -m pip install --upgrade pip
2424
python -m pip install pytest
2525
# Can comment out when next Mathics core and Mathics-scanner are released
26-
python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
26+
# python -m pip install -e git+https://github.com/Mathics3/mathics-scanner#egg=Mathics-Scanner[full]
2727
python -m pip install -e git+https://github.com/Mathics3/mathics-core#egg=Mathics3[full]
2828
(cd src/mathics3 && bash ./admin-tools/make-op-tables.sh)
29-
# python -m pip install Mathics3[full]
30-
python -m pip install -e .
3129
- name: install pymathics graph
3230
run: |
3331
make develop

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*~
2+
/.hypothesis
23
/.python-version
34
/ChangeLog
45
/build

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pytest:
6161

6262
#: Run tests that appear in docstring in the code.
6363
doctest:
64-
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m mathics.docpipeline -l pymathics.graph $o
64+
MATHICS_CHARACTER_ENCODING="ASCII" $(PYTHON) -m mathics.docpipeline -l pymathics.graph -c 'Graphs - Vertices and Edges' $o
6565

6666
# #: Make Mathics PDF manual
6767
# doc mathics.pdf: mathics/doc/tex/data

NEWS.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
6.0.0
2+
-----
3+
4+
Revise for 6.0.0 Mathics3 API and current Mathics3 builtin standards
5+
described in [Guidelines for Writing
6+
Documentation](https://mathics-development-guide.readthedocs.io/en/latest/extending/developing-code/extending/documentation-markup.html#guidelines-for-writing-documentation).
7+
8+
This package has undergone a major overhaul. Modules have been split out along into logical groups following the documentation structure.
9+
10+
We have gradually been rolling in more Python type annotations and
11+
have been using current Python practices. Tools such as using
12+
``isort``, ``black`` and ``flake8`` are used as well.
13+
14+
Evaluation methods of built-in functions start ``eval_`` not
15+
``apply_``.
16+
17+
There is more refactoring more to do here, Upgrade to NetworkX is also
18+
desirable.
19+
120
5.0.0.alpha0
221
------------
322

admin-tools/pyenv-versions

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
55
echo "This script should be *sourced* rather than run directly through bash"
66
exit 1
77
fi
8-
export PYVERSIONS='3.6.13 3.7.13 3.8.13 3.9.13 3.10.5'
8+
export PYVERSIONS='3.6.15 3.7.16 3.8.16 3.9.16 3.10.10'

pymathics/graph/base.py

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from mathics.core.convert.expression import ListExpression, from_python, to_mathics_list
1616
from mathics.core.element import BaseElement
1717
from mathics.core.expression import Expression
18+
from mathics.core.pattern import pattern_objects
1819
from mathics.core.symbols import Symbol, SymbolList, SymbolTrue
1920
from mathics.core.systemsymbols import (
2021
SymbolBlank,
@@ -81,7 +82,7 @@ def graph_helper(
8182
graph_generator_func: Callable,
8283
options: dict,
8384
can_digraph: bool,
84-
graph_layout: str,
85+
graph_layout: Optional[str],
8586
evaluation,
8687
root: Optional[int] = None,
8788
*args,
@@ -124,7 +125,7 @@ def graph_helper(
124125

125126

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

129130

130131
def _process_graph_options(g, options: dict) -> None:
@@ -173,15 +174,15 @@ def _process_graph_options(g, options: dict) -> None:
173174

174175

175176
def _circular_layout(G):
176-
return nx.drawing.circular_layout(G, scale=1.5)
177+
return nx.drawing.circular_layout(G, scale=1)
177178

178179

179180
def _spectral_layout(G):
180-
return nx.drawing.spectral_layout(G, scale=2.0)
181+
return nx.drawing.spectral_layout(G, scale=2)
181182

182183

183184
def _shell_layout(G):
184-
return nx.drawing.shell_layout(G, scale=2.0)
185+
return nx.drawing.shell_layout(G, scale=2)
185186

186187

187188
def _generic_layout(G, warn):
@@ -840,7 +841,6 @@ class AdjacencyList(_NetworkXBuiltin):
840841
matching $pattern$.
841842
</dl>
842843
843-
>> LoadModule["pymathics.graph"];
844844
>> AdjacencyList[{1 -> 2, 2 -> 3}, 3]
845845
= {2}
846846
@@ -854,8 +854,6 @@ class AdjacencyList(_NetworkXBuiltin):
854854
summary_text = "list the adjacent vertices"
855855

856856
def _retrieve(self, graph, what, neighbors, expression, evaluation):
857-
from mathics.core.pattern import pattern_objects
858-
859857
if what.get_head_name() in pattern_objects:
860858
collected = set()
861859
match = Matcher(what).match
@@ -897,12 +895,11 @@ def neighbors(v):
897895

898896
class DirectedEdge(Builtin):
899897
"""
900-
<url>
901-
:Directed edge:
898+
Edge of a <url>
899+
:Directed graph:
902900
https://en.wikipedia.org/wiki/Directed_graph</url> (<url>
903901
:NetworkX:
904-
https://networkx.org/documentation/networkx-2.8.8/reference/classes/digraph.html</url>,
905-
<url>
902+
https://networkx.org/documentation/networkx-2.8.8/reference/classes/digraph.html</url>, <url>
906903
:WMA:
907904
https://reference.wolfram.com/language/ref/DirectedEdge.html</url>)
908905
@@ -920,11 +917,10 @@ class EdgeConnectivity(_NetworkXBuiltin):
920917
"""
921918
<url>
922919
:Edge connectivity:
923-
https://en.wikipedia.org/wiki/Directed_graph</url> (<url>
920+
https://en.wikipedia.org/wiki/Directed_graph#Directed_graph_connectivity</url> (<url>
924921
:NetworkX:
925922
https://networkx.org/documentation/networkx-2.8.8/reference/algorithms/\
926-
generated/networkx.algorithms.connectivity.connectivity.edge_connectivity.html</url>,
927-
<url>
923+
generated/networkx.algorithms.connectivity.connectivity.edge_connectivity.html</url>, <url>
928924
:WMA:
929925
https://reference.wolfram.com/language/ref/EdgeConnectivity.html</url>)
930926
@@ -970,7 +966,7 @@ def eval_st(self, graph, s, t, expression, evaluation, options):
970966
class EdgeIndex(_NetworkXBuiltin):
971967
"""
972968
<url>
973-
:WMA:
969+
:WMA link:
974970
https://reference.wolfram.com/language/ref/EdgeIndex.html</url>
975971
976972
<dl>
@@ -998,7 +994,7 @@ def eval(self, graph, v, expression, evaluation, options):
998994
class EdgeList(_PatternList):
999995
"""
1000996
<url>
1001-
:WMA:
997+
:WMA link:
1002998
https://reference.wolfram.com/language/ref/EdgeList.html</url>
1003999
10041000
<dl>
@@ -1016,7 +1012,7 @@ def _items(self, graph):
10161012
class EdgeRules(_NetworkXBuiltin):
10171013
"""
10181014
<url>
1019-
:WMA:
1015+
:WMA link:
10201016
https://reference.wolfram.com/language/ref/EdgeRules.html</url>
10211017
10221018
<dl>
@@ -1048,8 +1044,7 @@ class FindShortestPath(_NetworkXBuiltin):
10481044
https://en.wikipedia.org/wiki/Shortest_path_problem</url> (<url>
10491045
:NetworkX:
10501046
https://networkx.org/documentation/networkx-2.8.8/reference/algorithms\
1051-
/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html</url>,
1052-
<url>
1047+
/generated/networkx.algorithms.shortest_paths.generic.shortest_path.html</url>, <url>
10531048
:WMA:
10541049
https://reference.wolfram.com/language/ref/FindShortestPath.html</url>)
10551050
@@ -1083,7 +1078,7 @@ class FindShortestPath(_NetworkXBuiltin):
10831078
summary_text = "find the shortest path between two vertices"
10841079

10851080
def eval_s_t(self, graph, s, t, expression, evaluation, options):
1086-
"%(name)s[graph_, s_, t_, OptionsPattern[%(name)s]]"
1081+
"FindShortestPath[graph_, s_, t_, OptionsPattern[FindShortestPath]]"
10871082
graph = self._build_graph(graph, evaluation, options, expression)
10881083
if not graph:
10891084
return
@@ -1169,8 +1164,7 @@ def eval_st(self, graph, s, t, expression, evaluation, options):
11691164

11701165
class GraphAtom(AtomBuiltin):
11711166
"""
1172-
<url>:Graph:https://en.wikipedia.org/wiki/graph</url> (
1173-
<url>:WMA:
1167+
<url>:Graph:https://en.wikipedia.org/wiki/graph</url> (<url>:WMA:
11741168
https://reference.wolfram.com/language/ref/Graph.html</url>)
11751169
<dl>
11761170
<dt>'Graph[{$e1, $e2, ...}]'
@@ -1224,7 +1218,7 @@ def eval_1(self, vertices, edges, evaluation, options):
12241218
class HighlightGraph(_NetworkXBuiltin):
12251219
"""
12261220
<url>
1227-
:WMA:
1221+
:WMA link:
12281222
https://reference.wolfram.com/language/ref/HighlightGraph.html</url>
12291223
12301224
<dl>
@@ -1264,7 +1258,7 @@ def parse(item):
12641258
class Property(Builtin):
12651259
"""
12661260
<url>
1267-
:WMA:
1261+
:WMA link:
12681262
https://reference.wolfram.com/language/ref/Property.html</url>
12691263
12701264
<dl>
@@ -1280,7 +1274,7 @@ class Property(Builtin):
12801274
class PropertyValue(Builtin):
12811275
"""
12821276
<url>
1283-
:WMA:
1277+
:WMA link:
12841278
https://reference.wolfram.com/language/ref/PropertyValue.html</url>
12851279
12861280
<dl>
@@ -1323,7 +1317,7 @@ def eval(self, graph, item, name, evaluation):
13231317
class VertexAdd(_NetworkXBuiltin):
13241318
"""
13251319
<url>
1326-
:WMA:
1320+
:WMA link:
13271321
https://reference.wolfram.com/language/ref/VertexAdd.html</url>
13281322
13291323
<dl>
@@ -1343,7 +1337,7 @@ class VertexAdd(_NetworkXBuiltin):
13431337
summary_text = "add a vertex"
13441338

13451339
def eval(self, graph: Expression, what, expression, evaluation, options):
1346-
"%(name)s[graph_, what_, OptionsPattern[%(name)s]]"
1340+
"VertexAdd[graph_, what_, OptionsPattern[VertexAdd]]"
13471341
mathics_graph = self._build_graph(graph, evaluation, options, expression)
13481342
if mathics_graph:
13491343
if what.get_head_name() == "System`List":
@@ -1357,7 +1351,7 @@ def eval(self, graph: Expression, what, expression, evaluation, options):
13571351
class VertexConnectivity(_NetworkXBuiltin):
13581352
"""
13591353
<url>
1360-
:WMA:
1354+
:WMA link:
13611355
https://reference.wolfram.com/language/ref/VertexConnectivity.html</url>
13621356
13631357
<dl>
@@ -1408,7 +1402,7 @@ def eval_st(self, graph, s, t, expression, evaluation, options):
14081402
class VertexDelete(_NetworkXBuiltin):
14091403
"""
14101404
<url>
1411-
:WMA:
1405+
:WMA link:
14121406
https://reference.wolfram.com/language/ref/VertexDelete.html</url>
14131407
14141408
<dl>
@@ -1431,8 +1425,6 @@ def eval(self, graph, what, expression, evaluation, options) -> Optional[Graph]:
14311425
"VertexDelete[graph_, what_, OptionsPattern[VertexDelete]]"
14321426
graph = self._build_graph(graph, evaluation, options, expression)
14331427
if graph:
1434-
from mathics.core.pattern import pattern_objects
1435-
14361428
head_name = what.get_head_name()
14371429
if head_name in pattern_objects:
14381430
cases = Expression(
@@ -1449,7 +1441,7 @@ def eval(self, graph, what, expression, evaluation, options) -> Optional[Graph]:
14491441
class VertexIndex(_NetworkXBuiltin):
14501442
"""
14511443
<url>
1452-
:WMA:
1444+
:WMA link:
14531445
https://reference.wolfram.com/language/ref/VertexIndex.html</url>
14541446
<dl>
14551447
<dt>'VertexIndex'['g', 'v']
@@ -1477,7 +1469,7 @@ def eval(self, graph, v, expression, evaluation, options):
14771469
class VertexList(_PatternList):
14781470
"""
14791471
<url>
1480-
:WMA:
1472+
:WMA link:
14811473
https://reference.wolfram.com/language/ref/VertexList.html</url>
14821474
<dl>
14831475
<dt>'VertexList[$edgelist$]'
@@ -1495,7 +1487,7 @@ class VertexList(_PatternList):
14951487
= {10}
14961488
"""
14971489

1498-
summary_text = "list the vertex"
1490+
summary_text = "list the vertices of a graph"
14991491

15001492
def _items(self, graph):
15011493
return graph.vertices
@@ -1504,7 +1496,7 @@ def _items(self, graph):
15041496
class UndirectedEdge(Builtin):
15051497
"""
15061498
<url>
1507-
:WMA:
1499+
:WMA link:
15081500
https://reference.wolfram.com/language/ref/UndirectedEdge.html</url>
15091501
15101502
<dl>
@@ -1544,9 +1536,9 @@ class UndirectedEdge(Builtin):
15441536

15451537
class EdgeDelete(_NetworkXBuiltin):
15461538
"""
1547-
<url>
1539+
Delete an Edge (<url>
15481540
:WMA:
1549-
https://reference.wolfram.com/language/ref/EdgeDelete.html</url>
1541+
https://reference.wolfram.com/language/ref/EdgeDelete.html</url>)
15501542
15511543
<dl>
15521544
<dt>'EdgeDelete'[$g$, $edge$]
@@ -1572,8 +1564,6 @@ def eval(self, graph, what, expression, evaluation, options) -> Optional[Graph]:
15721564
"EdgeDelete[graph_, what_, OptionsPattern[EdgeDelete]]"
15731565
graph = self._build_graph(graph, evaluation, options, expression)
15741566
if graph:
1575-
from mathics.core.pattern import pattern_objects
1576-
15771567
head_name = what.get_head_name()
15781568
if head_name in pattern_objects:
15791569
cases = Expression(

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

0 commit comments

Comments
 (0)