def test_layout(): layout = Layout() # Add a rectangle at position layout.add(Rectangle(40, 40), [0, 0]) # Panel is a container for data p = Panel(400, 400, xlim=[0, 10], ylim=[0, 10]) p.scatter([0, 5], [0, 5]) layout.add(p, [10, 10]) #t = Text("Hello", size=12) #layout.add(p, 10, 20) prim = layout.get_primitives() rect = prim[0] assert rect['type'] == 'rect' npeq_(rect['position'], [0, 0]) assert rect['width'] == 40 assert rect['height'] == 40 point1 = prim[1] assert point1['type'] == 'point' npeq_(point1['position'], [10, 10]) point2 = prim[2] assert point2['type'] == 'point' npeq_(point2['position'], [10 + 200, 10 + 200])
def test_scatter(): object = Panel(200, 200) object.scatter(np.arange(0, 1, 0.1), np.arange(0, 1, 0.1)) r = CairoRenderer('/tmp/hello.svg', width=400, height=400) r.render(object.get_primitives())
def test_twopanels(): p1 = Panel(200, 200) p2 = Panel(50, 50) p1.scatter(np.arange(0, 1, 0.1), np.arange(0, 1, 0.1)) p2.scatter(np.arange(0, 1, 0.1), np.arange(0, 1, 0.1)[::-1]) layout = Layout(400, 600) layout.add(p1, [0, 0]) layout.add(p2, [250, 0]) r = CairoRenderer('/tmp/hello.svg', width=400, height=200) r.render(layout.get_primitives())