def test_regular_polygon_from_dict(): spec = { 'center': [0, 0], 'radius': 1, 'n_vertices': 10, } assert Shape.from_dict(spec) == Shape.regular_polygon([0, 0], 1, 10)
def test_from_dict(): spec = { 'vertices': [[1, 0], [0, 1], [-1, 0], [0, -1]], 'color': (120, 50, 12), 'velocity': np.random.sample(2), } assert Shape.from_dict(spec) == Shape(spec['vertices'], color=spec['color'], velocity=spec['velocity'])
def test_rectangle_from_dict(): spec = { 'vertices': [[-1, -1], [1, 1]], } assert Shape.from_dict(spec) == Shape.rectangle(spec['vertices'])
def test_circle_from_dict(): spec = { 'center': [0, 0], 'radius': 1, } assert Shape.from_dict(spec) == Shape.circle([0, 0], 1)