def test_replot_result_type(self): ar_downsample._loadAR() source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) expected = { "image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine" } shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if isinstance(item, ar_downsample.Shader): shaders[item] = item.out for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals( expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}".format( str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_replot_result_type(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure() plot.square('A', 'B', source=source) expected = { "image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine" } shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if isinstance(item, ar_downsample.Shader): shaders[item] = item.out for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals( expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}".format( str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def _reify_tester(self, proxy, reifyBase, kwargs): ar_downsample._loadAR() op = proxy.reify(**kwargs) self.assertIsNotNone(op, "Empty reification on %s" % type(proxy)) self.assertIsInstance( op, reifyBase, "Reify to unexpected type (%s) for %s" % (type(op), type(proxy)))
def test_replot_property_transfer(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot_width = 612 plot_height = 408 plot_title = "Test title" plot = figure(lot_width=plot_width, plot_height=plot_height, title=plot_title) plot.square('A', 'B', source=source) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_shaper_create(self): ar_downsample._loadAR() glyphspec = {'type': 'Square', 'size': {'value': 3}, 'radius': {'value': 3}} self.assertIsInstance(ar_downsample._shaper(glyphspec, False), glyphset.ToRect) self.assertIsInstance(ar_downsample._shaper(glyphspec, True), glyphset.ToPoint) self.assertIsInstance(ar_downsample._shaper(glyphspec, True), glyphset.ToPoint)
def test_replot_result_type(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure() plot.square('A', 'B', source=source) expected = {"image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine"} shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if isinstance(item, ar_downsample.Shader): shaders[item] = item.out for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals(expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}" .format(str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_source(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure() plot.square('A', 'B', source=source) agg = ar_downsample.CountCategories() info = ar_downsample.Const(val=1) shader = ar_downsample.InterpolateColor() new_source = ar_downsample.source(plot, agg=agg, info=info, shader=shader) self.assertIsNotNone(new_source.transform) trans = new_source.transform self.assertEquals(trans['resample'], 'abstract rendering') self.assertEquals(trans['agg'], agg) self.assertEquals(trans['info'], info) self.assertEquals(trans['shader'], shader) self.assertEquals(trans['glyphspec'], plot.select({'type' : GlyphRenderer})[0].glyph) self.assertEquals(trans['points'], False)
def test_source(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure() plot.square('A', 'B', source=source) agg = ar_downsample.CountCategories() info = ar_downsample.Const(val=1) shader = ar_downsample.InterpolateColor() new_source = ar_downsample.source(plot, agg=agg, info=info, shader=shader) self.assertIsNotNone(new_source.transform) trans = new_source.transform self.assertEquals(trans['resample'], 'abstract rendering') self.assertEquals(trans['agg'], agg) self.assertEquals(trans['info'], info) self.assertEquals(trans['shader'], shader) self.assertEquals(trans['glyphspec'], plot.select({'type': GlyphRenderer})[0].glyph) self.assertEquals(trans['points'], False)
def test_shaper_create(self): ar_downsample._loadAR() glyphspec = {'type': 'Square', 'size': {'value': 3}, 'radius': {'value': 3}} self.assertIsInstance(ar_downsample._shaper(glyphspec, False), glyphset.ToRect) self.assertIsInstance(ar_downsample._shaper(glyphspec, True), glyphset.ToPoint) self.assertIsInstance(ar_downsample._shaper(glyphspec, True), glyphset.ToPoint)
def test_heatmap_recipe(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure(plot_width=600, plot_height=400, title="Test Title") plot.square('A', 'B', source=source) plot2 = ar_downsample.heatmap(plot, palette="Reds9", reserve_val=0, points=True, client_color=True, title="Test Title 2") source2 = self._find_source(plot2) self.assertEquals("Test Title 2", plot2.title) self.assertEquals(type(source2), ServerDataSource) transform = source2.transform self.assertEquals(type(transform['info']), ar_downsample.Const) self.assertEquals(type(transform['agg']), ar_downsample.Count) self.assertEquals(type(transform['shader']), ar_downsample.Seq) self.assertEquals(transform['shader'].out, "image")
def test_replot_property_transfer(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot_width = 612 plot_height = 408 plot_title = "Test title" plot = figure(plot_width=plot_width, plot_height=plot_height, title=plot_title) plot.square('A', 'B', source=source) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_init_AR(self): # simulate un-loading AR.. this test fails if ar is imported elsewhere before # this test is run if 'general' in ar_downsample.__dict__: ar_downsample.__dict__.pop('general') self.assertRaises(NameError, ar_downsample.Id().reify) ar_downsample._loadAR() self.assertIsNotNone(ar_downsample.Id().reify())
def test_init_AR(self): # simulate un-loading AR.. this test fails if ar is imported elsewhere before # this test is run if 'general' in ar_downsample.__dict__: ar_downsample.__dict__.pop('general') self.assertRaises(NameError, ar_downsample.Id().reify) ar_downsample._loadAR() self.assertIsNotNone(ar_downsample.Id().reify())
def test_shaper_fail(self): ar_downsample._loadAR() with self.assertRaises(ValueError): ar_downsample._shaper({ 'type': 'blah', 'size': { 'value': 3 } }, False)
def test_replot_remove(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_replot_remove(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = figure() plot.square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_source(self): ar_downsample._loadAR() source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) agg = ar_downsample.CountCategories() info = ar_downsample.Const(val=1) shader = ar_downsample.InterpolateColor() new_source = ar_downsample.source(plot, agg=agg, info=info, shader=shader) self.assertIsNotNone(new_source.transform) trans = new_source.transform self.assertEquals(trans['resample'], 'abstract rendering') self.assertEquals(trans['agg'], agg) self.assertEquals(trans['info'], info) self.assertEquals(trans['shader'], shader) self.assertEquals(trans['glyphspec'], self._glyphspec(plot)) self.assertEquals(trans['points'], False)
def test_replot_result_type(self): ar_downsample._loadAR() source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = square('A', 'B', source=source) expected = {"image": "Image", "image_rgb": "ImageRGBA", "multi_line": "MultiLine"} shaders = dict() for name in dir(ar_downsample): item = getattr(ar_downsample, name) if hasattr(item, "out"): shaders[item] = getattr(item, "out") for shader_class in shaders: shader = shader_class() rslt = ar_downsample.replot(plot, shader=shader) self.assertEquals(expected[shader.out], self._glyphspec(rslt)['type'], "Error with {0}. Expected {1}, recieved {2}" .format(str(shader_class), expected[shader.out], self._glyphspec(rslt)))
def test_replot_remove(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure() plot.square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_source(self): ar_downsample._loadAR() source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot = figure() plot.square('A', 'B', source=source) agg = ar_downsample.CountCategories() info = ar_downsample.Const(val=1) shader = ar_downsample.InterpolateColor() new_source = ar_downsample.source(plot, agg=agg, info=info, shader=shader) self.assertIsNotNone(new_source.transform) trans = new_source.transform self.assertEquals(trans['resample'], 'abstract rendering') self.assertEquals(trans['agg'], agg) self.assertEquals(trans['info'], info) self.assertEquals(trans['shader'], shader) self.assertEquals(trans['glyphspec'], self._glyphspec(plot)) self.assertEquals(trans['points'], False)
def test_replot_remove(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure() plot.square('A', 'B', source=source) ar_downsample.replot(plot, remove_original=False) self.assertTrue(plot in curdoc().context.children, "Not retained") ar_downsample.replot(plot, remove_original=True) self.assertTrue(plot not in curdoc().context.children, "Not removed") try: ar_downsample.replot(plot, remove_original=True) except: self.assertTrue(False, "Error reploting plot not in curdoc")
def test_replot_property_transfer(self): ar_downsample._loadAR() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot_width = 612 plot_height = 408 plot_title = "Test title" plot = figure(plot_width=plot_width, plot_height=plot_height, title=plot_title) plot.square('A', 'B', source=source) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_contour_recipe(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource(expr={ 'op': 'Field', 'args': [':leaf', 'bivariate'] }) plot = figure(plot_width=600, plot_height=400, title="Test Title") plot.square('A', 'B', source=source) plot2 = ar_downsample.contours(plot, title="Contour") source2 = self._find_source(plot2) self.assertEquals("Contour", plot2.title) self.assertEquals(type(source2), ServerDataSource) transform = source2.transform self.assertEquals(type(transform['info']), ar_downsample.Const) self.assertEquals(type(transform['agg']), ar_downsample.Count) self.assertEquals(type(transform['shader']), ar_downsample.Seq) self.assertEquals(transform['shader'].out, "multi_line")
def test_replot_property_transfer(self): self.assertIsNotNone(self.bokeh_server, "Server failed to start, cannot tests") ar_downsample._loadAR() output_server("Census") source = ServerDataSource(data_url="fn://bivariate", owner_username="******") plot_width = 612 plot_height = 408 plot_title = "Test title" plot = square('A', 'B', source=source, plot_width=plot_width, plot_height=plot_height, title=plot_title) ar_plot = ar_downsample.replot(plot) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width not transfered") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height not transfered") self.assertEquals(ar_plot.title, plot_title, "Plot title not transfered") plot_width = 612 plot_height = 408 plot_title = "Test title" ar_plot = ar_downsample.replot(plot, title=plot_title, plot_width=plot_width, plot_height=plot_height) self.assertEquals(ar_plot.plot_width, plot_width, "Plot width override failed") self.assertEquals(ar_plot.plot_height, plot_height, "Plot height override failed") self.assertEquals(ar_plot.title, plot_title, "Plot title override failed")
def test_contour_recipe(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure(plot_width=600, plot_height=400, title="Test Title") plot.square('A', 'B', source=source) plot2 = ar_downsample.contours(plot, title="Contour") source2 = self._find_source(plot2) self.assertEquals("Contour", plot2.title) self.assertEquals(type(source2), ServerDataSource) transform = source2.transform self.assertEquals(type(transform['info']), ar_downsample.Const) self.assertEquals(type(transform['agg']), ar_downsample.Count) self.assertEquals(type(transform['shader']), ar_downsample.Seq) self.assertEquals(transform['shader'].out, "multi_line")
def test_heatmap_recipe(self): ar_downsample._loadAR() reset_output() sess = Session(client=app.test_client()) output_server('Census', session=sess) source = ServerDataSource( expr={'op': 'Field', 'args': [':leaf', 'bivariate']} ) plot = figure(plot_width=600, plot_height=400, title="Test Title") plot.square('A', 'B', source=source) plot2 = ar_downsample.heatmap(plot, palette="Reds9", reserve_val=0, points=True, client_color=True, title="Test Title 2") source2 = self._find_source(plot2) self.assertEquals("Test Title 2", plot2.title) self.assertEquals(type(source2), ServerDataSource) transform = source2.transform self.assertEquals(type(transform['info']), ar_downsample.Const) self.assertEquals(type(transform['agg']), ar_downsample.Count) self.assertEquals(type(transform['shader']), ar_downsample.Seq) self.assertEquals(transform['shader'].out, "image")
def test_shaper_fail(self): ar_downsample._loadAR() with self.assertRaises(ValueError): ar_downsample._shaper("circle", 3, False) ar_downsample._shaper("blah", 3, False)
def test_shaper_create(self): ar_downsample._loadAR() self.assertIsInstance(ar_downsample._shaper("square", 3, False), glyphset.ToRect) self.assertIsInstance(ar_downsample._shaper("square", 3, True), glyphset.ToPoint) self.assertIsInstance(ar_downsample._shaper("circle", 3, True), glyphset.ToPoint)
def test_init_AR(self): self.assertRaises(NameError, Id().reify) ar_downsample._loadAR() self.assertIsNotNone(Id().reify())
def _reify_tester(self, proxy, reifyBase, kwargs): ar_downsample._loadAR() op = proxy.reify(**kwargs) self.assertIsNotNone(op, "Empty reification on %s" % type(proxy)) self.assertIsInstance(op, reifyBase, "Reify to unexpected type (%s) for %s" % (type(op), type(proxy)))
def test_shaper_fail(self): ar_downsample._loadAR() with self.assertRaises(ValueError): ar_downsample._shaper({'type': 'blah', 'size': {'value': 3}}, False)
def test_init_AR(self): self.assertRaises(NameError, ar_downsample.Id().reify) ar_downsample._loadAR() self.assertIsNotNone(ar_downsample.Id().reify())