class TestPatch(unittest.TestCase): def setUp(self): from bokeh.glyphs import Patch self.test_patch = Patch() def test_expected_properties(self): expected_properties = set(['x', 'y']) actual_properties = get_prop_set(type(self.test_patch)) self.assertTrue(expected_properties.issubset(actual_properties)) def test_expected_values(self): self.assertEqual(self.test_patch.x, 'x') self.assertEqual(self.test_patch.y, 'y') self.assertEqual(self.test_patch.__view_model__, 'patch') def test_to_glyphspec(self): expected = dict(GENERIC_GLYPH_DICT) expected['type'] = 'patch' self.assertEqual(self.test_patch.to_glyphspec(), expected) self.test_patch.x = [50] self.test_patch.y = [51] expected.update({ 'x': { 'units': 'data', 'value': [50] }, 'y': { 'units': 'data', 'value': [51] }, }) self.assertEqual(self.test_patch.to_glyphspec(), expected)
class TestPatch(unittest.TestCase): def setUp(self): from bokeh.glyphs import Patch self.test_patch = Patch() def test_expected_properties(self): expected_properties = set(['x', 'y']) actual_properties = get_prop_set(type(self.test_patch)) self.assertTrue(expected_properties.issubset(actual_properties)) def test_expected_values(self): self.assertEqual(self.test_patch.x, 'x') self.assertEqual(self.test_patch.y, 'y') self.assertEqual(self.test_patch.__view_model__, 'patch') def test_to_glyphspec(self): expected = dict(GENERIC_GLYPH_DICT) expected['type'] = 'patch' self.assertEqual(self.test_patch.to_glyphspec(), expected) self.test_patch.x = [50] self.test_patch.y = [51] expected.update({ 'x': {'units': 'data', 'value': [50]}, 'y': {'units': 'data', 'value': [51]}, }) self.assertEqual(self.test_patch.to_glyphspec(), expected)
def test_Patch(): glyph = Patch() assert glyph.x == "x" assert glyph.y == "y" yield check_fill, glyph yield check_line, glyph yield check_props, glyph, ["x", "y"], FILL, LINE
class TestPatch(unittest.TestCase): def setUp(self): from bokeh.glyphs import Patch self.test_patch = Patch() def test_expected_properties(self): expected_properties = set(['x','y']) actual_properties = get_prop_set(type(self.test_patch)) self.assertTrue(expected_properties.issubset(actual_properties)) def test_expected_values(self): self.assertEqual(self.test_patch.x,'x') self.assertEqual(self.test_patch.y,'y') self.assertEqual(self.test_patch.__view_model__,'patch') def test_to_glyphspec(self): self.assertEqual(self.test_patch.to_glyphspec(), {'line_color': {'value': 'black'}, 'y': {'units': 'data', 'field': 'y'}, 'type': 'patch', 'fill_color': {'value': 'gray'}, 'x': {'units': 'data', 'field': 'x'}}) self.test_patch.x = 50 self.test_patch.y = 51 self.assertEqual(self.test_patch.to_glyphspec(), {'y': {'units': 'data', 'value': 51}, 'x': {'units': 'data', 'value': 50}, 'type': 'patch', 'fill_color': {'value': 'gray'}, 'line_color': {'value': 'black'}})
class TestPatch(unittest.TestCase): def setUp(self): from bokeh.glyphs import Patch self.test_patch = Patch() def test_expected_properties(self): expected_properties = set(["x", "y"]) actual_properties = get_prop_set(type(self.test_patch)) self.assertTrue(expected_properties.issubset(actual_properties)) def test_expected_values(self): self.assertEqual(self.test_patch.x, "x") self.assertEqual(self.test_patch.y, "y") self.assertEqual(self.test_patch.__view_model__, "patch") def test_to_glyphspec(self): expected = dict(GENERIC_GLYPH_DICT) expected["type"] = "patch" self.assertEqual(self.test_patch.to_glyphspec(), expected) self.test_patch.x = [50] self.test_patch.y = [51] expected.update({"x": {"units": "data", "value": [50]}, "y": {"units": "data", "value": [51]}}) self.assertEqual(self.test_patch.to_glyphspec(), expected)
def setUp(self): from bokeh.glyphs import Patch self.test_patch = Patch()
times=[dt.time(11, 30)] * 3, texts=["CST (UTC+1)", "CEST (UTC+2)", "CST (UTC+1)"], )) xdr = DataRange1d(sources=[source.columns("dates")]) ydr = DataRange1d(sources=[source.columns("sunrises", "sunsets")]) title = "Daylight Hours - Warsaw, Poland" plot = Plot(title=title, data_sources=[source, patch1_source, patch2_source, text_source], x_range=xdr, y_range=ydr, width=800, height=400) patch1 = Patch(x="dates", y="times", fill_color="skyblue", fill_alpha=0.8) patch1_glyph = Glyph(data_source=patch1_source, xdata_range=xdr, ydata_range=ydr, glyph=patch1) plot.renderers.append(patch1_glyph) patch2 = Patch(x="dates", y="times", fill_color="orange", fill_alpha=0.8) patch2_glyph = Glyph(data_source=patch2_source, xdata_range=xdr, ydata_range=ydr, glyph=patch2) plot.renderers.append(patch2_glyph) line1 = Line(x="dates", y="sunrises", line_color="yellow", line_width=2) line1_glyph = Glyph(data_source=source,
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")), ("patches", Patches(xs="xs", ys="ys", fill_color="#FB9A99")), ("quad", Quad(left="x", right="xm01", top="y", bottom="ym01", fill_color="#B3DE69")), ("quadratic", Quadratic(x0="x", y0="y", x1="xp02", y1="y", cx="xp01", cy="yp01", line_color="#4DAF4A", line_width=3)), ("ray", Ray(x="x",