pyproject addition and simple tests for ci
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
6c34b9940f
commit
b86934cf49
@ -0,0 +1,12 @@
|
||||
import pytest
|
||||
import conway.anime as anime
|
||||
import conway.gameoflife as gol
|
||||
|
||||
|
||||
class TestPlotlyAnimation:
|
||||
state = gol.State(10, 10, "random")
|
||||
steps = 10
|
||||
plotly_anime = anime.PlotlyAnimation(state, steps)
|
||||
def test_frame_gen(self):
|
||||
assert self.plotly_anime.frames.shape == (11,10,10)
|
||||
assert len(self.plotly_anime.frame_gen()) == 2 * self.steps + 1
|
@ -0,0 +1,17 @@
|
||||
import pytest
|
||||
import numpy as np
|
||||
import conway.gameoflife as gol
|
||||
|
||||
|
||||
class TestState:
|
||||
def test_neighbours(self):
|
||||
state = gol.State(10, 10)
|
||||
n1 = np.array([[1, 1, 1], [1, 1, 1], [1, 1, 1]])
|
||||
assert state.checkNeighbours(n1, 1, 1) == 8
|
||||
assert state.checkNeighbours(n1, 1, 1, neighbourhood="neumann") == 4
|
||||
n2 = np.array([[0, 0, 0], [0, 0, 0], [0, 0, 0]])
|
||||
assert state.checkNeighbours(n2, 1, 1) == 0
|
||||
assert state.checkNeighbours(n2, 1, 1, neighbourhood="neumann") == 0
|
||||
n3 = np.array([[1, 0, 1], [0, 1, 0], [1, 0, 1]])
|
||||
assert state.checkNeighbours(n3, 1, 1, neighbourhood="moore") == 4
|
||||
assert state.checkNeighbours(n3, 1, 1, neighbourhood="neumann") == 0
|
Loading…
Reference in new issue