Beispiel #1
0
 def test_get_empty_fields(self):
     builder = core.ArrayBuilder()
     builder.new_array(3, 3)
     np.random.seed(7)
     builder.add_seed(3)
     assert set(builder.get_empty_fields()) == set(
         ((0, 0), (0, 1), (0, 2), (1, 2), (2, 1), (2, 2)))
Beispiel #2
0
 def test_filled_circle(self):
     builder = core.ArrayBuilder()
     circle = builder.filled_circle(5, 5, 2)
     good_circle = {(6, 4), (5, 4), (4, 7), (6, 6), (5, 6), (4, 5), (7, 5),
                    (6, 5), (3, 5), (5, 3), (6, 7), (5, 5), (4, 6), (7, 6),
                    (5, 7), (4, 4), (6, 3), (7, 4), (4, 3), (3, 6), (3, 4)}
     assert circle == good_circle
Beispiel #3
0
 def test_get_filled_fields(self):
     builder = core.ArrayBuilder()
     builder.new_array(3, 3)
     np.random.seed(7)
     builder.add_seed(3)
     assert set(builder.get_filled_fields()) == set(
         ((1, 0), (2, 0), (1, 1)))
Beispiel #4
0
 def test_horizontal_line(self):
     builder = core.ArrayBuilder()
     line = builder._horizontal_line(5, -3, 0)
     assert line == set(((5, -3), (5, -2), (5, -1), (5, 0)))
     line = builder._horizontal_line(5, 0, -3)
     assert line == set()
     line = builder._horizontal_line(5, 0, 0)
     assert line == set(((5, 0), ))
Beispiel #5
0
 def test_remove_fields(self):
     builder = core.ArrayBuilder()
     builder.set_array(
         np.array([[5, 0, 0], [1, 0, 1], [3, 0, 0]], dtype=np.uint32))
     builder.remove_fields({1})
     array = builder.get_array()
     assert np.array_equal(
         np.array([[5, 0, 0], [0, 0, 0], [3, 0, 0]], dtype=np.uint32),
         array)
Beispiel #6
0
 def test_add_seed(self):
     builder = core.ArrayBuilder()
     builder.new_array(3, 3)
     np.random.seed(7)
     builder.add_seed(3)
     assert np.array_equal(
         builder.get_array(),
         np.array([[0, 0, 0], [1024331969, 1818769098, 0],
                   [2181898220, 0, 0]]))
Beispiel #7
0
 def test_get_seed_ids(self):
     builder = core.ArrayBuilder()
     builder.set_array(
         np.array([[5, 0, 0], [1, 0, 1], [3, 0, 3]], dtype=np.uint32))
     assert builder.get_seed_ids() == {1, 3, 5}
Beispiel #8
0
 def test_new_array(self):
     builder = core.ArrayBuilder()
     builder.new_array(3, 3)
     assert np.array_equal(builder.get_array(),
                           np.zeros((3, 3), dtype=np.uint32))
Beispiel #9
0
 def test_set_array(self):
     builder = core.ArrayBuilder()
     builder.set_array(np.ones((5, 5)))
     assert np.array_equal(builder.get_array(), np.ones((5, 5)))
Beispiel #10
0
 def test_get_array(self):
     builder = core.ArrayBuilder()
     assert builder.get_array() is None