def test_ChaosGame_starting_point(): """Test if starting points are within radius 1 from origin (unit circle)""" for i in range(3, 10): testgon = ChaosGame(i, 1 / 2) testgon._starting_point() nt.assert_less_equal( np.sqrt(testgon.start[0]**2 + testgon.start[1]**2), 1)
def test_savepng(): """ Tests if a wrong format of the picture gives error """ temp = ChaosGame(2) temp._generate_ngon() temp._generate_points(20) temp._starting_point() temp.iterate(10) a.savepng('filename.jpg')
def test_scaled(): """ Test scaling vector - sum of the elements should be equal to 0 """ temp = ChaosGame(4) temp._generate_ngon() temp._generate_points(20) temp._starting_point() temp.iterate(10) computed = np.sum(temp.new_r[0]) assert (1 - computed) == 0
def test_starting_point(): """ Test that _starting_point returns array. """ T = ChaosGame(5, 0.5) s = T._starting_point() nt.assert_equal(type(s), np.ndarray)