Exemplo n.º 1
0
class TestBezier(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import Bezier
        self.test_bezier = Bezier()

    def test_expected_properties(self):
        expected_properties = set(['x0','y0','x1','y1','cx0','cy0','cx1','cy1'])
        actual_properties = get_prop_set(type(self.test_bezier))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_bezier.__view_model__,'bezier')
        self.assertEqual(self.test_bezier.x0,'x0')
        self.assertEqual(self.test_bezier.y0,'y0')
        self.assertEqual(self.test_bezier.x1,'x1')
        self.assertEqual(self.test_bezier.y1,'y1')
        self.assertEqual(self.test_bezier.cx0,'cx0')
        self.assertEqual(self.test_bezier.cy0,'cy0')
        self.assertEqual(self.test_bezier.cx1,'cx1')
        self.assertEqual(self.test_bezier.cy1,'cy1')     

    def test_to_glyphspec(self):
        self.assertEqual(self.test_bezier.to_glyphspec(), {'line_color': {'value': 'black'}, 'cx0': {'units': 'data', 'field': 'cx0'}, 'cy1': {'units': 'data', 'field': 'cy1'}, 'cy0': {'units': 'data', 'field': 'cy0'}, 'cx1': {'units': 'data', 'field': 'cx1'}, 'y1': {'units': 'data', 'field': 'y1'}, 'y0': {'units': 'data', 'field': 'y0'}, 'x0': {'units': 'data', 'field': 'x0'}, 'x1': {'units': 'data', 'field': 'x1'}, 'type': 'bezier'})
        self.test_bezier.x0 = 1
        self.test_bezier.x1 = 2
        self.test_bezier.cx0 = 3
        self.test_bezier.cx1 = 4
        self.test_bezier.y0 = 5
        self.test_bezier.y1 = 6
        self.test_bezier.cy0 = 7
        self.test_bezier.cy1 = 8
        self.assertEqual(self.test_bezier.to_glyphspec(), {'cx0': {'units': 'data', 'value': 3}, 'cx1': {'units': 'data', 'value': 4}, 'cy1': {'units': 'data', 'value': 8}, 'cy0': {'units': 'data', 'value': 7}, 'line_color': {'value': 'black'}, 'y1': {'units': 'data', 'value': 6}, 'y0': {'units': 'data', 'value': 5}, 'x0': {'units': 'data', 'value': 1}, 'x1': {'units': 'data', 'value': 2}, 'type': 'bezier'})
Exemplo n.º 2
0
class TestBezier(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import Bezier

        self.test_bezier = Bezier()

    def test_expected_properties(self):
        expected_properties = set(["x0", "y0", "x1", "y1", "cx0", "cy0", "cx1", "cy1"])
        actual_properties = get_prop_set(type(self.test_bezier))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_bezier.__view_model__, "bezier")
        self.assertEqual(self.test_bezier.x0, "x0")
        self.assertEqual(self.test_bezier.y0, "y0")
        self.assertEqual(self.test_bezier.x1, "x1")
        self.assertEqual(self.test_bezier.y1, "y1")
        self.assertEqual(self.test_bezier.cx0, "cx0")
        self.assertEqual(self.test_bezier.cy0, "cy0")
        self.assertEqual(self.test_bezier.cx1, "cx1")
        self.assertEqual(self.test_bezier.cy1, "cy1")

    def test_to_glyphspec(self):
        expected = dict(GENERIC_LINE_DICT)
        expected["type"] = "bezier"
        expected.update(
            {
                "x0": {"units": "data", "field": "x0"},
                "x1": {"units": "data", "field": "x1"},
                "y0": {"units": "data", "field": "y0"},
                "y1": {"units": "data", "field": "y1"},
                "cx0": {"units": "data", "field": "cx0"},
                "cy0": {"units": "data", "field": "cy0"},
                "cx1": {"units": "data", "field": "cx1"},
                "cy1": {"units": "data", "field": "cy1"},
            }
        )
        self.assertEqual(self.test_bezier.to_glyphspec(), expected)
        self.test_bezier.x0 = 1
        self.test_bezier.x1 = 2
        self.test_bezier.cx0 = 3
        self.test_bezier.cx1 = 4
        self.test_bezier.y0 = 5
        self.test_bezier.y1 = 6
        self.test_bezier.cy0 = 7
        self.test_bezier.cy1 = 8
        expected.update(
            {
                "x0": {"units": "data", "value": 1},
                "x1": {"units": "data", "value": 2},
                "y0": {"units": "data", "value": 5},
                "y1": {"units": "data", "value": 6},
                "cx0": {"units": "data", "value": 3},
                "cx1": {"units": "data", "value": 4},
                "cy0": {"units": "data", "value": 7},
                "cy1": {"units": "data", "value": 8},
            }
        )
        self.assertEqual(self.test_bezier.to_glyphspec(), expected)
Exemplo n.º 3
0
def test_Bezier():
    glyph = Bezier()
    assert glyph.x0 == "x0"
    assert glyph.y0 == "y0"
    assert glyph.x1 == "x1"
    assert glyph.y1 == "y1"
    assert glyph.cx0 == "cx0"
    assert glyph.cy0 == "cy0"
    assert glyph.cx1 == "cx1"
    assert glyph.cy1 == "cy1"
    yield check_line, glyph
    yield check_props, glyph, [
        "x0", "y0", "x1", "y1", "cx0", "cy0", "cx1", "cy1"
    ], LINE
Exemplo n.º 4
0
 def setUp(self):
     from bokeh.glyphs import Bezier
     self.test_bezier = Bezier()
Exemplo n.º 5
0
          outer_radius=screen(20),
          fill_color="#7FC97F")),
 ("arc",
  Arc(x="x",
      y="y",
      radius=screen(20),
      start_angle=0.6,
      end_angle=4.1,
      line_color="#BEAED4",
      line_width=3)),
 ("bezier",
  Bezier(x0="x",
         y0="y",
         x1="xp02",
         y1="y",
         cx0="xp01",
         cy0="yp01",
         cx1="xm01",
         cy1="ym01",
         line_color="#D95F02",
         line_width=2)),
 ("line", Line(x="x", y="y", line_color="#F46D43")),
 ("multi_line",
  MultiLine(xs="xs", ys="ys", line_color="#8073AC", line_width=2)),
 ("oval",
  Oval(x="x",
       y="y",
       width=screen(15),
       height=screen(25),
       angle=-0.7,
       fill_color="#1D91C0")),
 ("patch", Patch(x="x", y="y", fill_color="#A6CEE3")),
Exemplo n.º 6
0
 def setUp(self):
     from bokeh.glyphs import Bezier
     self.test_bezier = Bezier()
Exemplo n.º 7
0
class TestBezier(unittest.TestCase):
    def setUp(self):
        from bokeh.glyphs import Bezier
        self.test_bezier = Bezier()

    def test_expected_properties(self):
        expected_properties = set(
            ['x0', 'y0', 'x1', 'y1', 'cx0', 'cy0', 'cx1', 'cy1'])
        actual_properties = get_prop_set(type(self.test_bezier))
        self.assertTrue(expected_properties.issubset(actual_properties))

    def test_expected_values(self):
        self.assertEqual(self.test_bezier.__view_model__, 'bezier')
        self.assertEqual(self.test_bezier.x0, 'x0')
        self.assertEqual(self.test_bezier.y0, 'y0')
        self.assertEqual(self.test_bezier.x1, 'x1')
        self.assertEqual(self.test_bezier.y1, 'y1')
        self.assertEqual(self.test_bezier.cx0, 'cx0')
        self.assertEqual(self.test_bezier.cy0, 'cy0')
        self.assertEqual(self.test_bezier.cx1, 'cx1')
        self.assertEqual(self.test_bezier.cy1, 'cy1')

    def test_to_glyphspec(self):
        expected = dict(GENERIC_LINE_DICT)
        expected['type'] = 'bezier'
        expected.update({
            'x0': {
                'units': 'data',
                'field': 'x0'
            },
            'x1': {
                'units': 'data',
                'field': 'x1'
            },
            'y0': {
                'units': 'data',
                'field': 'y0'
            },
            'y1': {
                'units': 'data',
                'field': 'y1'
            },
            'cx0': {
                'units': 'data',
                'field': 'cx0'
            },
            'cy0': {
                'units': 'data',
                'field': 'cy0'
            },
            'cx1': {
                'units': 'data',
                'field': 'cx1'
            },
            'cy1': {
                'units': 'data',
                'field': 'cy1'
            },
        })
        self.assertEqual(self.test_bezier.to_glyphspec(), expected)
        self.test_bezier.x0 = 1
        self.test_bezier.x1 = 2
        self.test_bezier.cx0 = 3
        self.test_bezier.cx1 = 4
        self.test_bezier.y0 = 5
        self.test_bezier.y1 = 6
        self.test_bezier.cy0 = 7
        self.test_bezier.cy1 = 8
        expected.update({
            'x0': {
                'units': 'data',
                'value': 1
            },
            'x1': {
                'units': 'data',
                'value': 2
            },
            'y0': {
                'units': 'data',
                'value': 5
            },
            'y1': {
                'units': 'data',
                'value': 6
            },
            'cx0': {
                'units': 'data',
                'value': 3
            },
            'cx1': {
                'units': 'data',
                'value': 4
            },
            'cy0': {
                'units': 'data',
                'value': 7
            },
            'cy1': {
                'units': 'data',
                'value': 8
            },
        })
        self.assertEqual(self.test_bezier.to_glyphspec(), expected)