Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes in sandpiles #37410

Merged
merged 3 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/sage/sandpiles/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from sage.sandpiles.sandpile import Sandpile
from sage.graphs.graph_generators import graphs

class SandpileExamples():

class SandpileExamples:
"""
Some examples of sandpiles.

Expand Down Expand Up @@ -92,7 +93,7 @@
sage: sandpiles.Complete(3) == sandpiles.Cycle(3)
True
"""
return Sandpile(graphs.CompleteGraph(n),0)
return Sandpile(graphs.CompleteGraph(n), 0)

def Cycle(self, n):
"""
Expand All @@ -119,7 +120,7 @@
(3, 0, 1),
(3, 2, 1)]
"""
return Sandpile(graphs.CycleGraph(n),0)
return Sandpile(graphs.CycleGraph(n), 0)

def Diamond(self):
"""
Expand Down Expand Up @@ -164,18 +165,18 @@
"""
f = graphs.WheelGraph(n)
if n > 2:
f.delete_edge(1,n-1)
f.delete_edge(1, n-1)
if deg_three_verts:
f.allow_multiple_edges(True)
f.add_edges([(0,1),(0,n-1)])
return Sandpile(f,0)
f.add_edges([(0, 1), (0, n-1)])
return Sandpile(f, 0)
elif n == 1:
return Sandpile(f,0)
return Sandpile(f, 0)

Check warning on line 174 in src/sage/sandpiles/examples.py

View check run for this annotation

Codecov / codecov/patch

src/sage/sandpiles/examples.py#L174

Added line #L174 was not covered by tests
elif n == 2:
if deg_three_verts:
return Sandpile({0:{1:3}, 1:{0:3}})
return Sandpile({0: {1: 3}, 1: {0: 3}})

Check warning on line 177 in src/sage/sandpiles/examples.py

View check run for this annotation

Codecov / codecov/patch

src/sage/sandpiles/examples.py#L177

Added line #L177 was not covered by tests
else:
return Sandpile(f,0)
return Sandpile(f, 0)

Check warning on line 179 in src/sage/sandpiles/examples.py

View check run for this annotation

Codecov / codecov/patch

src/sage/sandpiles/examples.py#L179

Added line #L179 was not covered by tests

def Grid(self, m, n):
"""
Expand All @@ -200,11 +201,12 @@
sage: s.dict()
{(0, 0): {(1, 1): 4}, (1, 1): {(0, 0): 4}}
"""
G = graphs.Grid2dGraph(m+2,n+2)
G = graphs.Grid2dGraph(m+2, n+2)
G.allow_multiple_edges(True) # to ensure each vertex ends up with degree 4
V = [(i,j) for i in [0,m+1] for j in range(n+2)] + [(i,j) for j in [0,n+1] for i in range(m+2)]
V = [(i, j) for i in [0, m+1] for j in range(n+2)]
V += [(i, j) for j in [0, n+1] for i in range(m+2)]
G.merge_vertices(V)
return Sandpile(G, (0,0))
return Sandpile(G, (0, 0))

def House(self):
"""
Expand All @@ -224,7 +226,7 @@
sage: s.invariant_factors()
[1, 1, 1, 11]
"""
return Sandpile(graphs.HouseGraph(),0)
return Sandpile(graphs.HouseGraph(), 0)

def Wheel(self, n):
"""
Expand All @@ -244,7 +246,7 @@
sage: w.invariant_factors()
[1, 1, 1, 11, 11]
"""
return Sandpile(graphs.WheelGraph(n),0)
return Sandpile(graphs.WheelGraph(n), 0)


sandpiles = SandpileExamples()
Loading
Loading