Skip to content

Commit 4c4458e

Browse files
committed
from gap to libgap
1 parent 1cf0c13 commit 4c4458e

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/sage/groups/perm_gps/cubegroup.py

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,12 @@
9393
# *****************************************************************************
9494

9595
from sage.groups.perm_gps.permgroup import PermutationGroup_generic
96-
import random
96+
from random import randint
9797

9898
from sage.structure.sage_object import SageObject
9999
from sage.structure.richcmp import richcmp, richcmp_method
100-
100+
from sage.libs.gap.libgap import libgap
101101
from sage.rings.real_double import RDF
102-
from sage.interfaces.gap import gap
103102
from sage.groups.perm_gps.permgroup_element import PermutationGroupElement
104103
from sage.misc.lazy_import import lazy_import
105104
lazy_import("sage.plot.polygon", "polygon")
@@ -931,19 +930,19 @@ def repr2d(self, mv):
931930
"""
932931
g = self.parse(mv)
933932
lst = self.facets(g)
934-
line1 = " +--------------+\n"
935-
line2 = " |%3d %3d %3d |\n"%(lst[0],lst[1],lst[2])
936-
line3 = " |%3d top %3d |\n"%(lst[3],lst[4])
937-
line4 = " |%3d %3d %3d |\n"%(lst[5],lst[6],lst[7])
938-
line5 = "+------------+--------------+-------------+------------+\n"
939-
line6 = "|%3d %3d %3d |%3d %3d %3d |%3d %3d %3d |%3d %3d %3d |\n"%(lst[8],lst[9],lst[10],lst[16],lst[17],lst[18],lst[24],lst[25],lst[26],lst[32],lst[33],lst[34])
940-
line7 = "|%3d left%3d |%3d front%3d |%3d right%3d |%3d rear%3d |\n"%(lst[11],lst[12],lst[19],lst[20],lst[27],lst[28],lst[35],lst[36])
941-
line8 = "|%3d %3d %3d |%3d %3d %3d |%3d %3d %3d |%3d %3d %3d |\n"%(lst[13],lst[14],lst[15],lst[21],lst[22],lst[23],lst[29],lst[30],lst[31],lst[37],lst[38],lst[39])
942-
line9 = "+------------+--------------+-------------+------------+\n"
943-
line10 = " |%3d %3d %3d |\n"%(lst[40],lst[41],lst[42])
944-
line11 = " |%3d bottom%3d |\n"%(lst[43],lst[44])
945-
line12 = " |%3d %3d %3d |\n"%(lst[45],lst[46],lst[47])
946-
line13 = " +--------------+\n"
933+
line1 = " ┌──────────────┐\n"
934+
line2 = " %3d %3d %3d \n"%(lst[0],lst[1],lst[2])
935+
line3 = " %3d top %3d \n"%(lst[3],lst[4])
936+
line4 = " %3d %3d %3d \n"%(lst[5],lst[6],lst[7])
937+
line5 = "┌────────────┼──────────────┼─────────────┬────────────┐\n"
938+
line6 = "%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d \n"%(lst[8],lst[9],lst[10],lst[16],lst[17],lst[18],lst[24],lst[25],lst[26],lst[32],lst[33],lst[34])
939+
line7 = "%3d left%3d %3d front%3d %3d right%3d %3d rear%3d \n"%(lst[11],lst[12],lst[19],lst[20],lst[27],lst[28],lst[35],lst[36])
940+
line8 = "%3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d \n"%(lst[13],lst[14],lst[15],lst[21],lst[22],lst[23],lst[29],lst[30],lst[31],lst[37],lst[38],lst[39])
941+
line9 = "└────────────┼──────────────┼─────────────┴────────────┘\n"
942+
line10 = " %3d %3d %3d \n"%(lst[40],lst[41],lst[42])
943+
line11 = " %3d bottom%3d \n"%(lst[43],lst[44])
944+
line12 = " %3d %3d %3d \n"%(lst[45],lst[46],lst[47])
945+
line13 = " └──────────────┘\n"
947946
return line1+line2+line3+line4+line5+line6+line7+line8+line9+line10+line11+line12+line13
948947

949948
def plot_cube(self, mv, title=True, colors=[lpurple, yellow, red, green, orange, blue]):
@@ -1107,7 +1106,7 @@ def solve(self, state, algorithm='default'):
11071106
C = RubiksCube(g)
11081107
return C.solve(algorithm)
11091108

1110-
hom = self._gap_().EpimorphismFromFreeGroup()
1109+
hom = libgap(self).EpimorphismFromFreeGroup()
11111110
soln = hom.PreImagesRepresentative(str(g))
11121111
sol = str(soln)
11131112
names = self.gen_names()
@@ -1352,8 +1351,8 @@ def cubie(self, size, gap, x, y, z, colors, stickers=True):
13521351
sage: C.cubie(0.15, 0.025, 0,0,0, C.colors*3) # needs sage.plot
13531352
Graphics3d Object
13541353
"""
1355-
sides = cubie_face_list[x,y,z]
1356-
t = 2*size+gap
1354+
sides = cubie_face_list[x, y, z]
1355+
t = 2 * size + gap
13571356
my_colors = [colors[sides[i]+6] for i in range(6)]
13581357
if stickers:
13591358
B = Box(size, size, size, color=(.1, .1, .1))
@@ -1377,7 +1376,7 @@ def plot3d(self, stickers=True):
13771376
side_colors = [Texture(color=c, ambient=.75) for c in self.colors]
13781377
start_colors = sum([[c]*8 for c in side_colors], [])
13791378
facets = self._group.facets(self._state)
1380-
facet_colors = [0]*48
1379+
facet_colors = [0] * 48
13811380
for i in range(48):
13821381
facet_colors[facets[i]-1] = start_colors[i]
13831382
all_colors = side_colors + facet_colors
@@ -1493,7 +1492,7 @@ def solve(self, algorithm="hybrid", timeout=15):
14931492
return solver.solve(self._state, algorithm="gap")
14941493

14951494
else:
1496-
raise ValueError("Unrecognized algorithm: %s" % algorithm)
1495+
raise ValueError(f"Unrecognized algorithm: {algorithm}")
14971496

14981497
def scramble(self, moves=30):
14991498
"""
@@ -1522,7 +1521,7 @@ def scramble(self, moves=30):
15221521
all = []
15231522
for i in range(moves):
15241523
while move[0] == last_move[0]:
1525-
move = "RLUDBF"[random.randint(0,5)] + " '2"[random.randint(0,2)]
1524+
move = "RLUDBF"[randint(0, 5)] + " '2"[randint(0, 2)]
15261525
last_move = move
15271526
all.append(move)
15281527
return self.move(' '.join(all))

0 commit comments

Comments
 (0)