Spaces:
Sleeping
Sleeping
extend line length in ruff formatting
Browse files- pyproject.toml +3 -0
- src/rubik/__main__.py +1 -1
- src/rubik/cube.py +4 -12
pyproject.toml
CHANGED
@@ -26,3 +26,6 @@ torch = { index = "torch-cu126" }
|
|
26 |
[[tool.uv.index]]
|
27 |
name = "torch-cu126"
|
28 |
url = "https://download.pytorch.org/whl/cu126"
|
|
|
|
|
|
|
|
26 |
[[tool.uv.index]]
|
27 |
name = "torch-cu126"
|
28 |
url = "https://download.pytorch.org/whl/cu126"
|
29 |
+
|
30 |
+
[tool.ruff]
|
31 |
+
line-length = 120
|
src/rubik/__main__.py
CHANGED
@@ -3,4 +3,4 @@ from fire import Fire
|
|
3 |
from rubik.hello import hello_world
|
4 |
|
5 |
|
6 |
-
Fire({
|
|
|
3 |
from rubik.hello import hello_world
|
4 |
|
5 |
|
6 |
+
Fire({"hello": hello_world})
|
src/rubik/cube.py
CHANGED
@@ -26,9 +26,7 @@ class Cube:
|
|
26 |
cube = Cube.from_default(['U', 'L', 'C', 'R', 'B', 'D'], size = 3)
|
27 |
"""
|
28 |
assert (num := len(set(colors))) == 6, f"Expected 6 distinct colors, got {num}"
|
29 |
-
assert isinstance(size, int) and size > 1,
|
30 |
-
f"Expected non-zero integrer size, got {size}"
|
31 |
-
)
|
32 |
|
33 |
# build tensor filled with 0's, and fill the faces with 1's
|
34 |
n = size - 1
|
@@ -54,10 +52,7 @@ class Cube:
|
|
54 |
self.tensor[:, n, :, 4, :].argmax(dim=-1), # back
|
55 |
self.tensor[:, :, 0, 5, :].argmax(dim=-1), # down
|
56 |
]
|
57 |
-
return [
|
58 |
-
[[self.colors[i - 1] for i in row] for row in face.tolist()]
|
59 |
-
for face in grid
|
60 |
-
]
|
61 |
|
62 |
def __str__(self):
|
63 |
"""
|
@@ -79,10 +74,7 @@ class Cube:
|
|
79 |
void = " " * self.size
|
80 |
top = "\n".join(" ".join([void, "".join(row), void, void]) for row in grid[0])
|
81 |
middle = "\n".join(
|
82 |
-
" ".join("".join(grid[face_i][row_i]) for face_i in range(1, 5))
|
83 |
-
for row_i in range(self.size)
|
84 |
-
)
|
85 |
-
bottom = "\n".join(
|
86 |
-
" ".join((void, "".join(row), void, void)) for row in grid[-1]
|
87 |
)
|
|
|
88 |
return "\n".join([top, middle, bottom])
|
|
|
26 |
cube = Cube.from_default(['U', 'L', 'C', 'R', 'B', 'D'], size = 3)
|
27 |
"""
|
28 |
assert (num := len(set(colors))) == 6, f"Expected 6 distinct colors, got {num}"
|
29 |
+
assert isinstance(size, int) and size > 1, f"Expected non-zero integrer size, got {size}"
|
|
|
|
|
30 |
|
31 |
# build tensor filled with 0's, and fill the faces with 1's
|
32 |
n = size - 1
|
|
|
52 |
self.tensor[:, n, :, 4, :].argmax(dim=-1), # back
|
53 |
self.tensor[:, :, 0, 5, :].argmax(dim=-1), # down
|
54 |
]
|
55 |
+
return [[[self.colors[i - 1] for i in row] for row in face.tolist()] for face in grid]
|
|
|
|
|
|
|
56 |
|
57 |
def __str__(self):
|
58 |
"""
|
|
|
74 |
void = " " * self.size
|
75 |
top = "\n".join(" ".join([void, "".join(row), void, void]) for row in grid[0])
|
76 |
middle = "\n".join(
|
77 |
+
" ".join("".join(grid[face_i][row_i]) for face_i in range(1, 5)) for row_i in range(self.size)
|
|
|
|
|
|
|
|
|
78 |
)
|
79 |
+
bottom = "\n".join(" ".join((void, "".join(row), void, void)) for row in grid[-1])
|
80 |
return "\n".join([top, middle, bottom])
|