Esempio n. 1
0
    def _generate_plots(self):
        dynamic_plots = []
        for kw in [dict(sheet=sheet) for sheet in self.sheets()]:
            sheet = kw['sheet']
            views = topo.sim.views[sheet.name].Maps

            im = Image(sheet.input_generator(), bounds=sheet.bounds)
            im.metadata=AttrDict(timestamp=topo.sim.time())

            if 'Activity' not in views:
                views['Activity'] = NdMapping((topo.sim.time(), im))
                views['Activity'].metadata = AttrDict(precedence=sheet.precedence,
                                                      row_precedence=sheet.row_precedence,
                                                      src_name=sheet.name,
                                                      timestamp=topo.sim.time())
            else:
                views['Activity'][topo.sim.time()] = im
            channels = {'Strength': 'Activity','Hue':None,'Confidence':None}

            view = topo.sim.views[sheet.name].Maps
            view_dict = {'Strength':view,'Hue':view,'Confidence':view}
            ### JCALERT! it is not good to have to pass '' here... maybe a test in plot would be better
            dynamic_plots.append(make_template_plot(channels, view_dict,
                                                    sheet.xdensity,sheet.bounds,self.normalize,
                                                    name=''))

        return self._static_plots[:]+dynamic_plots
Esempio n. 2
0
 def test_bokeh_server_static_numeric_values(self):
     dim = Dimension('x')
     ndmap = NdMapping({i: None for i in range(3, 12)}, kdims=['x'])
     widget, label, mapping = BokehServerWidgets.create_widget(dim, ndmap, editable=True)
     self.assertIsInstance(widget, Slider)
     self.assertEqual(widget.value, 0)
     self.assertEqual(widget.start, 0)
     self.assertEqual(widget.end, 8)
     self.assertEqual(widget.step, 1)
     self.assertIsInstance(label, AutocompleteInput)
     self.assertEqual(label.title, dim.pprint_label)
     self.assertEqual(label.value, '3')
     self.assertEqual(mapping, [(i, (k, dim.pprint_value(k))) for i, k in enumerate(ndmap.keys())])
Esempio n. 3
0
 def test_bokeh_server_static_numeric_values(self):
     dim = Dimension('x')
     ndmap = NdMapping({i: None for i in range(3, 12)}, kdims=['x'])
     widget, label, mapping = BokehServerWidgets.create_widget(dim, ndmap, editable=True)
     self.assertIsInstance(widget, Slider)
     self.assertEqual(widget.value, 0)
     self.assertEqual(widget.start, 0)
     self.assertEqual(widget.end, 8)
     self.assertEqual(widget.step, 1)
     self.assertIsInstance(label, AutocompleteInput)
     self.assertEqual(label.title, dim.pprint_label)
     self.assertEqual(label.value, '3')
     self.assertEqual(mapping, [(k, dim.pprint_value(k)) for k in ndmap.keys()])
Esempio n. 4
0
 def test_bokeh_server_dynamic_values_str_2(self):
     keys = [chr(65+i) for i in range(10)]
     ndmap = NdMapping({i: None for i in keys}, kdims=['x'])
     dim = Dimension('x')
     widget, label, mapping = BokehServerWidgets.create_widget(dim, ndmap, editable=True)
     self.assertIsInstance(widget, Select)
     self.assertEqual(widget.value, 'A')
     self.assertEqual(widget.options, list(zip(keys, keys)))
     self.assertEqual(widget.title, dim.pprint_label)
     self.assertEqual(mapping, list(enumerate(zip(keys, keys))))
Esempio n. 5
0
    def _generate_plots(self):
        dynamic_plots = []
        for kw in [dict(sheet=sheet) for sheet in self.sheets()]:
            sheet = kw['sheet']
            views = topo.sim.views[sheet.name].Maps

            im = Image(sheet.input_generator(), bounds=sheet.bounds)
            im.metadata = AttrDict(timestamp=topo.sim.time())

            if 'Activity' not in views:
                views['Activity'] = NdMapping((topo.sim.time(), im))
                views['Activity'].metadata = AttrDict(
                    precedence=sheet.precedence,
                    row_precedence=sheet.row_precedence,
                    src_name=sheet.name,
                    timestamp=topo.sim.time())
            else:
                views['Activity'][topo.sim.time()] = im
            channels = {
                'Strength': 'Activity',
                'Hue': None,
                'Confidence': None
            }

            view = topo.sim.views[sheet.name].Maps
            view_dict = {'Strength': view, 'Hue': view, 'Confidence': view}
            ### JCALERT! it is not good to have to pass '' here... maybe a test in plot would be better
            dynamic_plots.append(
                make_template_plot(channels,
                                   view_dict,
                                   sheet.xdensity,
                                   sheet.bounds,
                                   self.normalize,
                                   name=''))

        return self._static_plots[:] + dynamic_plots
Esempio n. 6
0
    def setUp(self):
        ### Simple case: we only pass a dictionary to Plot()
        ### that does not belong to a Sheet:
        views = {}

        time = 0
        metadata = AttrDict(timestamp=time)

        ### SheetView1:
        ### Find a way to assign randomly the matrix.
        self.matrix1 = np.zeros((10,10),dtype=np.float) + np.random.random((10,10))
        self.bounds1 = BoundingBox(points=((-0.5,-0.5),(0.5,0.5)))
        sv = Matrix(self.matrix1, self.bounds1)
        sv.metadata=metadata
        self.sheet_view1 = NdMapping((None, sv))
        self.sheet_view1.metadata = AttrDict(src_name='TestInputParam',
                                            precedence=0.1, row_precedence=0.1,
                                            cyclic_range=None, timestamp=time)
        self.key1 = 'SV1'
        views[self.key1] = self.sheet_view1

        ### SheetView2:
        ### Find a way to assign randomly the matrix.
        self.matrix2 = np.zeros((10,10),dtype=np.float) + 0.3
        self.bounds2 = BoundingBox(points=((-0.5,-0.5),(0.5,0.5)))
        sv = Matrix(self.matrix2, self.bounds2)
        sv.metadata=metadata
        self.sheet_view2 = NdMapping((None, sv))
        self.sheet_view2.metadata = AttrDict(src_name='TestInputParam',
                                             precedence=0.2, row_precedence=0.2,
                                             cyclic_range=None, timestamp=time)
        self.key2 = 'SV2'
        views[self.key2] = self.sheet_view2

        ### SheetView3:
        ### Find a way to assign randomly the matrix.
        self.matrix3 = np.zeros((10,10),dtype=np.float) + np.random.random((10,10))
        self.bounds3 = BoundingBox(points=((-0.5,-0.5),(0.5,0.5)))
        sv = Matrix(self.matrix3, self.bounds3)
        sv.metadata=metadata
        self.sheet_view3 = NdMapping((None, sv))
        self.sheet_view3.metadata = AttrDict(src_name='TestInputParam',
                                             precedence=0.3, row_precedence=0.3,
                                             cyclic_range=None, timestamp=time)
        self.key3 = 'SV3'
        views[self.key3] = self.sheet_view3

        ### SheetView4: for testing clipping + different bounding box
        ### Find a way to assign randomly the matrix.
        self.matrix4 = np.zeros((10,10),dtype=np.float) + 1.6
        self.bounds4 = BoundingBox(points=((-0.7,-0.7),(0.7,0.7)))
        sv = Matrix(self.matrix4, self.bounds4)
        sv.metadata=metadata
        self.sheet_view4 = NdMapping((None, sv))
        self.sheet_view4.metadata = AttrDict(src_name='TestInputParam',
                                             precedence=0.4, row_precedence=0.4,
                                             cyclic_range=None, timestamp=time)
        self.key4 = 'SV4'
        views[self.key4] = self.sheet_view4

        self.view_dict = {'Strength': views, 'Hue': views, 'Confidence': views}

        ### JCALERT! for the moment we can only pass a triple when creating plot
        ### adding more sheetView to test when plot will be fixed for accepting
        ### as much as you want.

        # plot0: empty plot + no sheetviewdict passed: error or empty plot?
        ### JCALERT! It has to be fixed what to do in this case in plot..
        ### disabled test for the moment.
        #self.plot0 = Plot((None,None,None),None,name='plot0')
        ### CATCH EXCEPTION

        plot_channels1 = {'Strength':None,'Hue':None,'Confidence':None}
        # plot1: empty plot
        self.plot1 = make_template_plot(plot_channels1,self.view_dict,density=10.0,name='plot1')

        plot_channels2 = {'Strength':self.key1,'Hue':None,'Confidence':None}
        # plot2: sheetView 1, no normalize, no clipping
        self.plot2 = make_template_plot(plot_channels2,self.view_dict,density=10.0,name='plot2')

        plot_channels3 = {'Strength':self.key1,'Hue':self.key2,'Confidence':None}
        # plot3: sheetView 1+2, no normalize, no clipping
        self.plot3 = make_template_plot(plot_channels3,self.view_dict,density=10.0,name='plot3')

        plot_channels4 = {'Strength':self.key1,'Hue':self.key2,'Confidence':self.key3}
        # plot4: sheetView 1+2+3, no normalize , no clipping
        self.plot4 = make_template_plot(plot_channels4,self.view_dict,density=10.0,name='plot4')

        plot_channels5 = {'Strength':self.key1,'Hue':None,'Confidence':self.key3}
        # plot5: sheetView 1+3, no normalize, no clipping
        self.plot5 = make_template_plot(plot_channels5,self.view_dict,density=10.0,name='plot5')

        plot_channels6 = {'Strength':None,'Hue':self.key2,'Confidence':self.key3}
        # plot6: sheetView 2+3, no normalize , no clipping
        self.plot6 = make_template_plot(plot_channels6,self.view_dict,density=10.0,name='plot6')

        plot_channels7 = {'Strength':self.key4,'Hue':self.key2,'Confidence':self.key3}
        # plot7: sheetView 1+2+3, no normalize , clipping
        self.plot7 = make_template_plot(plot_channels7,self.view_dict,density=10.0,name='plot7')

        plot_channels8 = {'Strength':self.key1,'Hue':self.key2,'Confidence':self.key3}
        # plot8: sheetView 1+2+3, normalize , no clipping
        self.plot8 = make_template_plot(plot_channels8,self.view_dict,density=10.0,normalize=True,name='plot8')

        ### JCALERT! FOR THE MOMENT I TAKE THE DEFAULT FOR NORMALIZE.
        ### WE WILL SEE IF IT REMAINS IN PLOT FIRST.

        ### also makes a sheet to test realease_sheetviews

        self.sheet = Sheet()
        self.sheet.views.Maps[self.key1]=self.sheet_view1
        self.sheet.views.Maps[self.key2]=self.sheet_view2
        self.sheet.views.Maps[self.key3]=self.sheet_view3
        self.sheet.views.Maps[self.key4]=self.sheet_view4

        plot_channels9 = {'Strength':self.key1,'Hue':self.key2,'Confidence':self.key3}
        self.plot9 = make_template_plot(plot_channels9,self.sheet.views.Maps,density=10.0,name='plot9')