Skip to content

Commit cf348e0

Browse files
committed
more pylint fixes
1 parent 6cb551c commit cf348e0

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Custom_LED_Animations/conways/conways.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from adafruit_led_animation.grid import PixelGrid, HORIZONTAL
1111

1212

13+
def _is_pixel_off(pixel):
14+
return pixel[0] == 0 and pixel[1] == 0 and pixel[2] == 0
15+
16+
1317
class ConwaysLifeAnimation(Animation):
1418
# Constants
1519
DIRECTION_OFFSETS = [
@@ -36,7 +40,8 @@ def __init__(
3640
equilibrium_restart=True,
3741
):
3842
"""
39-
Conway's Game of Life implementation. Watch the cells live and die based on the classic rules.
43+
Conway's Game of Life implementation. Watch the cells
44+
live and die based on the classic rules.
4045
4146
:param pixel_object: The initialised LED object.
4247
:param float speed: Animation refresh rate in seconds, e.g. ``0.1``.
@@ -71,9 +76,6 @@ def __init__(
7176

7277
# self._init_cells()
7378

74-
def _is_pixel_off(self, pixel):
75-
return pixel[0] == 0 and pixel[1] == 0 and pixel[2] == 0
76-
7779
def _is_grid_empty(self):
7880
"""
7981
Checks if the grid is empty.
@@ -82,7 +84,7 @@ def _is_grid_empty(self):
8284
"""
8385
for y in range(self.height):
8486
for x in range(self.width):
85-
if not self._is_pixel_off(self.pixel_grid[x, y]):
87+
if not _is_pixel_off(self.pixel_grid[x, y]):
8688
return False
8789

8890
return True
@@ -106,7 +108,7 @@ def _count_neighbors(self, cell):
106108
neighbors = 0
107109
for direction in ConwaysLifeAnimation.DIRECTION_OFFSETS:
108110
try:
109-
if not self._is_pixel_off(
111+
if not _is_pixel_off(
110112
self.pixel_grid[cell[0] + direction[0], cell[1] + direction[1]]
111113
):
112114
neighbors += 1
@@ -115,6 +117,7 @@ def _count_neighbors(self, cell):
115117
return neighbors
116118

117119
def draw(self):
120+
# pylint: disable=too-many-branches
118121
"""
119122
draw the current frame of the animation
120123
@@ -137,7 +140,7 @@ def draw(self):
137140
for x in range(self.width):
138141

139142
# check and set the current cell type, live or dead
140-
if self._is_pixel_off(self.pixel_grid[x, y]):
143+
if _is_pixel_off(self.pixel_grid[x, y]):
141144
cur_cell_type = ConwaysLifeAnimation.DEAD
142145
else:
143146
cur_cell_type = ConwaysLifeAnimation.LIVE

0 commit comments

Comments
 (0)