Beispiel #1
0
    def test_heatmap_recipe(self):
        source = ServerDataSource(data_url="fn://bivariate",
                                  owner_username="******")
        plot = square('A',
                      'B',
                      source=source,
                      plot_width=600,
                      plot_height=400,
                      title="Test Title")

        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")
Beispiel #2
0
    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")
Beispiel #3
0
    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)))
Beispiel #4
0
    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")
Beispiel #5
0
    def test_contour_recipe(self):
        source = ServerDataSource(data_url="fn://bivariate", owner_username="******")
        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")
Beispiel #6
0
    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)
Beispiel #7
0
from bokeh.plotting import figure, output_server, show
from bokeh.models import ServerDataSource

import bokeh.transforms.ar_downsample as ar
from blaze.server.client import Client
from blaze import Data

output_server("abstractrender")

c = Client('http://localhost:5006')
d = Data(c)
source = ServerDataSource()
source.from_blaze(d.gauss, local=True)

plot = figure()
plot.square('oneA', 'oneB', color='#FF00FF', source=source)


#Server-side colored heatmap
arplot = ar.heatmap(plot, spread=3, transform=None, title="Server-rendered, uncorrected")

arplot = ar.heatmap(plot, spread=3, transform="Log", title="Server-rendered, log transformed")
arplot =  ar.heatmap(plot, spread=3, title="Server-rendered, perceptually corrected")

ar.replot(plot,
          agg=ar.Count(),
          info=ar.Const(val=1),
          shader=ar.Spread(factor=3) + ar.Cuberoot() + ar.InterpolateColor(low=(255,200,200), high=(255,0,0)),
          points=True,
          title="Manually process: perceptually corrected",
          reserve_val=0)
Beispiel #8
0
import numpy as np
from bokeh.plotting import square, output_server, image, show
from bokeh.models import ServerDataSource

import bokeh.transforms.ar_downsample as ar

output_server("abstractrender")
source = ServerDataSource(data_url="fn://gauss", owner_username="******")
plot = square('oneA', 'oneB', color='#FF00FF', source=source)

#Server-side colored heatmap
ar.heatmap(plot,
           spread=3,
           transform=None,
           title="Server-rendered, uncorrected")
ar.heatmap(plot,
           spread=3,
           transform="Log",
           title="Server-rendered, log transformed")
ar.heatmap(plot, spread=3, title="Server-rendered, perceptually corrected")

ar.replot(plot,
          agg=ar.Count(),
          info=ar.Const(val=1),
          shader=ar.Spread(factor=3) + ar.Cuberoot() +
          ar.InterpolateColor(low=(255, 200, 200), high=(255, 0, 0)),
          points=True,
          title="Manually process: perceptually corrected",
          reserve_val=0)

# Client-side colored heatmap
Beispiel #9
0
from bokeh.plotting import figure, output_server, show
from bokeh.models import ServerDataSource
import bokeh.transforms.ar_downsample as ar
from blaze.server.client import Client
from blaze import Data
output_server("Census")
# 2010 US Census tracts

c = Client('http://localhost:5006')
d = Data(c)
source = ServerDataSource()
source.from_blaze(d.census, local=True)

plot = figure()
arplot = plot.square(
            'LON', 'LAT',
            source=source,
            plot_width=600,
            plot_height=400,
            title="Census Tracts")

ar.heatmap(arplot, palette="Reds9", reserve_val=0, points=True, client_color=True, title="Census Tracts (Client Colors)")
ar.heatmap(arplot, low=(255, 200, 200), points=True, title="Census Tracts (Server Colors)")
ar.contours(arplot, title="ISO Contours")
show(plot)
from bokeh.plotting import figure, output_server, show
from bokeh.models import ServerDataSource
import bokeh.transforms.ar_downsample as ar
from blaze.server.client import Client
from blaze import Data
output_server("Census")
# 2010 US Census tracts

c = Client('http://localhost:5006')
d = Data(c)
source = ServerDataSource()
source.from_blaze(d.census, local=True)

plot = figure()
arplot = plot.square('LON',
                     'LAT',
                     source=source,
                     plot_width=600,
                     plot_height=400,
                     title="Census Tracts")

ar.heatmap(arplot,
           palette="Reds9",
           reserve_val=0,
           points=True,
           client_color=True,
           title="Census Tracts (Client Colors)")
ar.heatmap(arplot,
           low=(255, 200, 200),
           points=True,
           title="Census Tracts (Server Colors)")
Beispiel #11
0
from bokeh.plotting import square, output_server, show
from bokeh.models import ServerDataSource
import bokeh.transforms.ar_downsample as ar
"""
In order to run this example, you have to execute
./bokeh-server -D remotedata

the remote data directory in the bokeh checkout has the sample data for this example

In addition, you must install ArrayManagement from this branch (soon to be master)
https://github.com/ContinuumIO/ArrayManagement
"""

output_server("Census")
# 2010 US Census tracts
source = ServerDataSource(data_url="/defaultuser/CensusTracts.hdf5",
                          owner_username="******")
plot = square('LON',
              'LAT',
              source=source,
              plot_width=600,
              plot_height=400,
              title="Census Tracts")

ar.heatmap(plot,
           palette="Reds9",
           reserve_val=0,
           points=True,
           client_color=True,
           title="Census Tracts (Client Colors)")
ar.heatmap(plot,
           low=(255, 200, 200),