Skip to content

Commit 147c138

Browse files
committed
Get ready for release 2.3.0
Fix lint errors
1 parent f1fc830 commit 147c138

File tree

14 files changed

+167
-43
lines changed

14 files changed

+167
-43
lines changed

.editorconfig

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# THis is an EditorConfig file
2+
# https://EditorConfig.org
3+
4+
root = true
5+
6+
[*]
7+
end_of_line = lf
8+
insert_final_newline = true
9+
charset = utf-8
10+
indent_style = tab
11+
indent_size = 4
12+
insert_final_newline = true
13+
14+
[*.yml]
15+
indent_style = space
16+
indent_size = 2
17+
end_of_line = lf
18+
insert_final_newline = true
19+
20+
[*.py]
21+
indent_style = space
22+
indent_size = 4
23+
end_of_line = lf
24+
insert_final_newline = true
25+
26+
# Tab indentation (no size specified)
27+
[Makefile]
28+
indent_style = tab

.pre-commit-config.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.0.0
4+
hooks:
5+
- id: debug-statements
6+
- id: end-of-file-fixer
7+
- repo: https://github.com/psf/black
8+
rev: 20.8b1
9+
hooks:
10+
- id: black
11+
language_version: python3
12+
exclude: 'mathicsscript/version.py'

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pypi-setup:
3131
#: Set up to run from the source tree
3232
develop: pypi-setup
3333

34+
#: Make distirbution: wheels, eggs, tarball
35+
dist:
36+
./admin-tools/make-dist.sh
37+
3438
#: Install pymathics.graph
3539
install: pypi-setup
3640
$(PYTHON) setup.py install

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2.3.0
2+
-----
3+
4+
Small API changes to track Mathics 3.0.0.
5+
6+
Blacken everything
7+
8+
9+
110
2.2.0
211
-----
312

README.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ Example Session
88
::
99

1010
$ mathicsscript
11-
Mathics 1.1.1
11+
Mathics 3.0.1
1212
on CPython 3.6.12 (default, Oct 24 2020, 10:34:18)
13-
using SymPy 1.8.dev, mpmath 1.1.0, cython 0.29.21
13+
using SymPy 1.8, mpmath 1.2.1, cython 0.29.22
1414

15-
Copyright (C) 2011-2020 The Mathics Team.
15+
Copyright (C) 2011-2021 The Mathics Team.
1616
This program comes with ABSOLUTELY NO WARRANTY.
1717
This is free software, and you are welcome to redistribute it
1818
under certain conditions.

pymathics/graph/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
"""Pymathics Graph - Working with Graphs (Vertices and Edgies)
1+
"""Pymathics Graph - Working with Graphs (Vertices and Edges)
22
33
This module provides functions and variables for workting with
44
graphs.
5-
"""
65
6+
Example:
7+
In[1]:= LoadModule["pymathics.graph"]
8+
Out[1]= pymathics.graph
9+
In[2]:= BinomialTree[3]
10+
In[3]:= BinomialTree[6]
11+
In[4]:= CompleteKaryTree[3, VertexLabels->True]
12+
"""
713

814
from pymathics.graph.version import __version__
9-
from pymathics.graph.__main__ import *
10-
from pymathics.graph.tree import *
11-
from pymathics.graph.generators import *
12-
from pymathics.graph.algorithms import *
15+
from pymathics.graph.__main__ import * # noqa
16+
from pymathics.graph.tree import * # qoqa
17+
from pymathics.graph.generators import * # noqa
18+
from pymathics.graph.algorithms import * # noqa
1319

1420
pymathics_version_data = {
1521
"author": "The Mathics Team",

pymathics/graph/__main__.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
# uses networkx
1111

1212
from mathics.builtin.base import Builtin, AtomBuiltin
13-
from mathics.builtin.graphics import GraphicsBox
13+
from mathics.builtin.box.graphics import GraphicsBox
1414
from mathics.core.expression import (
1515
Atom,
1616
Expression,
1717
Integer,
1818
Real,
19-
String,
2019
Symbol,
2120
)
2221
from mathics.builtin.patterns import Matcher
@@ -730,7 +729,7 @@ def full_new_edge_properties(new_edge_style):
730729
attr_dict = attr_dict or empty_dict
731730
G.add_edge(u, v, **attr_dict)
732731

733-
edge_collection = _EdgeCollection(
732+
_EdgeCollection(
734733
edges,
735734
edge_properties,
736735
n_directed=len(directed_edges),
@@ -1804,7 +1803,7 @@ def apply_s_t(self, graph, s, t, expression, evaluation, options):
18041803
def _convert_networkx_graph(G, options):
18051804
mapping = dict((v, Integer(i)) for i, v in enumerate(G.nodes))
18061805
G = nx.relabel_nodes(G, mapping)
1807-
edges = [Expression("System`UndirectedEdge", u, v) for u, v in G.edges]
1806+
[Expression("System`UndirectedEdge", u, v) for u, v in G.edges]
18081807
return Graph(
18091808
G,
18101809
**options,

pymathics/graph/algorithms.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
# SymbolFalse = Symbol("System`False")
2323
# SymbolTrue = Symbol("System`True")
2424

25+
2526
class ConnectedComponents(_NetworkXBuiltin):
2627
"""
2728
>> g = Graph[{1 -> 2, 2 -> 3, 3 <-> 4}]; ConnectedComponents[g]
@@ -38,10 +39,12 @@ def apply(self, graph, expression, evaluation, options):
3839
"ConnectedComponents[graph_, OptionsPattern[%(name)s]]"
3940
graph = self._build_graph(graph, evaluation, options, expression)
4041
if graph:
41-
connect_fn = nx.strongly_connected_components if graph.G.is_directed() else nx.connected_components
42-
components = [
43-
Expression("List", *c) for c in connect_fn(graph.G)
44-
]
42+
connect_fn = (
43+
nx.strongly_connected_components
44+
if graph.G.is_directed()
45+
else nx.connected_components
46+
)
47+
components = [Expression("List", *c) for c in connect_fn(graph.G)]
4548
return Expression("List", *components)
4649

4750

@@ -63,6 +66,7 @@ def apply(self, graph, expression, evaluation, options):
6366
# # int_path = map(Integer, path)
6467
# return Expression("List", *path)
6568

69+
6670
class GraphDistance(_NetworkXBuiltin):
6771
"""
6872
<dl>
@@ -110,9 +114,7 @@ def apply_s(self, graph, s, expression, evaluation, options):
110114
weight = graph.update_weights(evaluation)
111115
d = nx.shortest_path_length(graph.G, source=s, weight=weight)
112116
inf = Expression("DirectedInfinity", 1)
113-
return Expression(
114-
"List", *[d.get(v, inf) for v in graph.vertices]
115-
)
117+
return Expression("List", *[d.get(v, inf) for v in graph.vertices])
116118

117119
def apply_s_t(self, graph, s, t, expression, evaluation, options):
118120
"%(name)s[graph_, s_, t_, OptionsPattern[%(name)s]]"
@@ -133,6 +135,7 @@ def apply_s_t(self, graph, s, t, expression, evaluation, options):
133135
except nx.exception.NetworkXNoPath:
134136
return Expression("DirectedInfinity", 1)
135137

138+
136139
class FindSpanningTree(_NetworkXBuiltin):
137140
"""
138141
<dl>
@@ -144,14 +147,18 @@ class FindSpanningTree(_NetworkXBuiltin):
144147
"""
145148

146149
options = DEFAULT_GRAPH_OPTIONS
150+
147151
def apply(self, graph, expression, evaluation, options):
148152
"%(name)s[graph_, OptionsPattern[%(name)s]]"
149153
graph = self._build_graph(graph, evaluation, options, expression)
150154
if graph:
151155
weight = graph.update_weights(evaluation)
152156
edge_type = "DirectedEdge" if graph.G.is_directed() else "UndirectedEdge"
153157
# FIXME: put in edge to Graph conversion function?
154-
edges = [Expression("UndirectedEdge", u, v) for u, v in nx.minimum_spanning_edges(graph.G, data=False)]
158+
edges = [
159+
Expression("UndirectedEdge", u, v)
160+
for u, v in nx.minimum_spanning_edges(graph.G, data=False)
161+
]
155162
g = _create_graph(edges, [None] * len(edges), options)
156163
if not hasattr(g.G, "graph_layout"):
157164
if hasattr(graph.G, "graph_layout"):
@@ -160,6 +167,7 @@ def apply(self, graph, expression, evaluation, options):
160167
g.G.graph_layout = "tree"
161168
return g
162169

170+
163171
class PlanarGraphQ(_NetworkXBuiltin):
164172
"""
165173
<dl>
@@ -174,6 +182,7 @@ class PlanarGraphQ(_NetworkXBuiltin):
174182
"""
175183

176184
options = DEFAULT_GRAPH_OPTIONS
185+
177186
def apply(self, graph, expression, evaluation, options):
178187
"%(name)s[graph_, OptionsPattern[%(name)s]]"
179188
graph = self._build_graph(graph, evaluation, options, expression)
@@ -182,6 +191,7 @@ def apply(self, graph, expression, evaluation, options):
182191
is_planar, _ = nx.check_planarity(graph.G)
183192
return Symbol("System`True") if is_planar else Symbol("System`False")
184193

194+
185195
class WeaklyConnectedComponents(_NetworkXBuiltin):
186196
"""
187197
>> g = Graph[{1 -> 2, 2 -> 3, 3 <-> 4}]; WeaklyConnectedComponents[g]

0 commit comments

Comments
 (0)