当前位置: 首页>>代码示例>>Python>>正文


Python holoviews.DynamicMap方法代码示例

本文整理汇总了Python中holoviews.DynamicMap方法的典型用法代码示例。如果您正苦于以下问题:Python holoviews.DynamicMap方法的具体用法?Python holoviews.DynamicMap怎么用?Python holoviews.DynamicMap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在holoviews的用法示例。


在下文中一共展示了holoviews.DynamicMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_render_dynamicmap_with_stream_dims

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_render_dynamicmap_with_stream_dims(self):
        stream = Stream.define(str('Custom'), y=2)()
        dmap = DynamicMap(lambda x, y: Curve([x, 1, y]), kdims=['x', 'y'],
                          streams=[stream]).redim.values(x=[1, 2, 3])
        obj, _ = self.renderer._validate(dmap, None)
        self.renderer.components(obj)
        [(plot, pane)] = obj._plots.values()
        cds = plot.handles['cds']

        self.assertEqual(cds.data['y'][2], 2)
        stream.event(y=3)
        self.assertEqual(cds.data['y'][2], 3)

        self.assertEqual(cds.data['y'][0], 1)
        slider = obj.layout.select(DiscreteSlider)[0]
        slider.value = 3
        self.assertEqual(cds.data['y'][0], 3) 
开发者ID:holoviz,项目名称:holoviews,代码行数:19,代码来源:testrenderer.py

示例2: __init__

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def __init__(self, shiftds, sampling=2, pct_thres=99.9, on=0):
        self.shiftds = shiftds
        self.temps = shiftds['temps']
        self.on = on
        self.pct_thres = pct_thres
        self.hh = self.temps.sizes['height']
        self.ww = self.temps.sizes['width']
        self.mask = xr.zeros_like(self.temps, dtype=bool)
        self.ls_anm = np.unique(shiftds.coords['animal'].values)
        self.ls_ss = np.unique(shiftds.coords['session'].values)
        Selection = Stream.define(
            'selection',
            anm=param.Selector(self.ls_anm),
            ss=param.Selector(self.ls_ss))
        self.str_sel = Selection(anm=self.ls_anm[0], ss=self.ls_ss[0])
        # self.sampling = sampling
        self.str_box = BoxEdit()
        self.box = hv.DynamicMap(self._box, streams=[self.str_box])
        self.box = self.box.opts(
            style=dict(fill_alpha=0.3, line_color='white'))
        self.wgts = self._widgets()
        self.hvobjs = self._get_objs() 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:24,代码来源:visualization.py

示例3: map_view

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def map_view(self):
        options = dict(tools=['box_select'], clone=False)
        annotated = DynamicMap(self.annotated_points, streams=[self.table_stream])
        return self.tiles * self.polys * self.points.options(**options) * annotated 
开发者ID:pyviz-topics,项目名称:EarthSim,代码行数:6,代码来源:annotators.py

示例4: table_view

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def table_view(self):
        return DynamicMap(self.group_table, streams=[self.table_stream]) 
开发者ID:pyviz-topics,项目名称:EarthSim,代码行数:4,代码来源:annotators.py

示例5: __init__

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def __init__(self, image, fg_data=[], bg_data=[], **params):
        super(GrabCutPanel, self).__init__(image=image, **params)
        self._bg_data = bg_data
        self._fg_data = fg_data
        self.bg_paths = DynamicMap(self.bg_path_view)
        self.fg_paths = DynamicMap(self.fg_path_view)
        self.draw_bg = FreehandDraw(source=self.bg_paths)
        self.draw_fg = FreehandDraw(source=self.fg_paths)
        self._initialized = False
        self._clear = False 
开发者ID:pyviz-topics,项目名称:EarthSim,代码行数:12,代码来源:grabcut.py

示例6: view

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def view(self):
        height = self.height
        if height is None:
            h, w = self.image.dimension_values(2, flat=False).shape[:2]
            height = int(self.width*(h/w))
        options = dict(width=self.width, height=height, xaxis=None, yaxis=None,
                       projection=self.image.crs)
        dmap = hv.DynamicMap(self.extract_foreground)
        dmap = hv.util.Dynamic(dmap, operation=self._filter_contours)
        dmap = hv.util.Dynamic(dmap, operation=self._simplify_contours)
        return (regrid(self.image).options(**options) * self.bg_paths * self.fg_paths +
                dmap.options(**options)) 
开发者ID:pyviz-topics,项目名称:EarthSim,代码行数:14,代码来源:grabcut.py

示例7: _sample

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def _sample(self, obj, data):
        """
        Rasterizes the supplied object across times returning
        an Image of the sampled data across time and distance.
        """
        if self.path_stream.data is None:
            path = self.path
        else:
            path = self.path_stream.element
        if isinstance(obj, TriMesh): 
            vdim = obj.nodes.vdims[0]
        else:
            vdim = obj.vdims[0]

        if len(path) > 2:
            x_range = path.range(0)
            y_range = path.range(1)
        else:
            return Image([], ['Distance', 'Time'], vdim.name)

        g= path.geom()[-1]
        xs, ys, distance = self._gen_samples(g)
        sections = []

        if isinstance(self.obj, DynamicMap):
            times = self.obj.kdims[0].values
        else:
            times = self.obj.keys()

        (x0, x1), (y0, y1) = x_range, y_range
        width, height = (max([min([(x1-x0)/self.resolution, 500]), 10]),
                         max([min([(y1-y0)/self.resolution, 500]), 10]))
        for t in times:
            raster = rasterize(self.obj[t], x_range=x_range, y_range=y_range,
                               aggregator=self.aggregator, width=int(width),
                               height=int(height), dynamic=False)
            x, y = raster.kdims
            indexes = {x.name: xs, y.name: ys}
            points = raster.data.sel_points(method='nearest', **indexes).to_dataframe()
            sections.append(points[vdim.name])
        return Image((distance, times, np.vstack(sections)), ['Distance', self.obj.kdims[0]], vdim) 
开发者ID:pyviz-topics,项目名称:EarthSim,代码行数:43,代码来源:analysis.py

示例8: init_plot

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def init_plot(self, plot: Callable, data=None, *args, **kwargs) -> None:
        """
        Initialize the holoviews plot to accept streaming data.

        Args:
            plot: Callable that returns an holoviews plot.
            data: Passed to :class:`Plot`.``get_plot_data``. Contains the necessary data to \
                  initialize the plot.
            args: Passed to ``opts``.
            kwargs: Passed to ``opts``.

        """
        self.plot = holoviews.DynamicMap(plot, streams=[self.data_stream])
        self.opts(*args, **kwargs) 
开发者ID:FragileTech,项目名称:fragile,代码行数:16,代码来源:streaming.py

示例9: create_selectors_players

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def create_selectors_players(self, graph):
        """
        Converts the sliders generated by hvplot into selectors/players.

        This is applicable only when both `x` and `y` are present in variable
        coordinates. It converts any sliders generated by hvplot into
        selectors/players and moves them to the bottom of graph.
        """
        if len(self.data[self.var].dims) > 2 and self.kwargs['extract along']:
            self.taps_graph = hv.DynamicMap(self.create_taps_graph,
                                            streams=[self.tap_stream,
                                                     self.clear_points])
            self.clear_series_button.disabled = False
            graph = graph * self.taps_graph
        else:
            self.clear_series_button.disabled = True
        graph = pn.Row(graph)

        self.output[0] = look_for_class(graph, pn.pane.HoloViews)[0]
        sliders = look_for_class(graph, pn.widgets.Widget)
        for slider in sliders:
            for dim in self.kwargs['dims_to_select_animate']:
                long_name = self.data[dim].long_name if hasattr(
                    self.data[dim], 'long_name') else None
                if slider.name == dim or slider.name == long_name:
                    if self.kwargs[dim] == 'select':
                        selector = convert_widget(slider, pn.widgets.Select)
                    else:
                        selector = convert_widget(slider, pn.widgets.DiscretePlayer)
                    self.index_selectors.append(selector)

        for selector in self.index_selectors:
            if isinstance(selector, pn.widgets.Select):
                self.output[1].append(selector)
            else:
                player = player_with_name_and_value(selector)
                self.output[1].append(player) 
开发者ID:intake,项目名称:xrviz,代码行数:39,代码来源:dashboard.py

示例10: test_render_dynamicmap_with_dims

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_render_dynamicmap_with_dims(self):
        dmap = DynamicMap(lambda y: Curve([1, 2, y]), kdims=['y']).redim.range(y=(0.1, 5))
        obj, _ = self.renderer._validate(dmap, None)
        self.renderer.components(obj)
        [(plot, pane)] = obj._plots.values()
        cds = plot.handles['cds']

        self.assertEqual(cds.data['y'][2], 0.1)
        slider = obj.layout.select(FloatSlider)[0]
        slider.value = 3.1
        self.assertEqual(cds.data['y'][2], 3.1) 
开发者ID:holoviz,项目名称:holoviews,代码行数:13,代码来源:testrenderer.py

示例11: test_render_dynamicmap_with_stream

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_render_dynamicmap_with_stream(self):
        stream = Stream.define(str('Custom'), y=2)()
        dmap = DynamicMap(lambda y: Curve([1, 2, y]), kdims=['y'], streams=[stream])
        obj, _ = self.renderer._validate(dmap, None)
        self.renderer.components(obj)
        [(plot, pane)] = obj._plots.values()
        cds = plot.handles['cds']

        self.assertEqual(cds.data['y'][2], 2)
        stream.event(y=3)
        self.assertEqual(cds.data['y'][2], 3) 
开发者ID:holoviz,项目名称:holoviews,代码行数:13,代码来源:testrenderer.py

示例12: test_points_selection

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_points_selection(self, dynamic=False, show_regions=True):
        points = Points(self.data)
        if dynamic:
            # Convert points to DynamicMap that returns the element
            points = hv.util.Dynamic(points)

        lnk_sel = link_selections.instance(show_regions=show_regions,
                                           unselected_color='#ff0000')
        linked = lnk_sel(points)
        current_obj = linked[()]

        # Check initial state of linked dynamic map
        self.assertIsInstance(current_obj, hv.Overlay)
        unselected, selected, region, region2 = current_obj.values()

        # Check initial base layer
        self.check_base_points_like(unselected, lnk_sel)

        # Check selection layer
        self.check_overlay_points_like(selected, lnk_sel, self.data)

        # Perform selection of second and third point
        boundsxy = lnk_sel._selection_expr_streams[0]._source_streams[0]
        self.assertIsInstance(boundsxy, hv.streams.SelectionXY)
        boundsxy.event(bounds=(0, 1, 5, 5))
        unselected, selected, region, region2 = linked[()].values()

        # Check that base layer is unchanged
        self.check_base_points_like(unselected, lnk_sel)

        # Check selection layer
        self.check_overlay_points_like(selected, lnk_sel, self.data.iloc[1:])

        if show_regions:
            self.assertEqual(region, Rectangles([(0, 1, 5, 5)]))
        else:
            self.assertEqual(region, Rectangles([])) 
开发者ID:holoviz,项目名称:holoviews,代码行数:39,代码来源:testselection.py

示例13: test_unique_keys_no_overlap_dynamicmap_uninitialized

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_unique_keys_no_overlap_dynamicmap_uninitialized(self):
        dmap1 = DynamicMap(lambda A: Curve(range(10)), kdims=['A'])
        dmap2 = DynamicMap(lambda B: Curve(range(10)), kdims=['B'])
        dims, keys = unique_dimkeys(dmap1+dmap2)
        self.assertEqual(dims, dmap1.kdims+dmap2.kdims)
        self.assertEqual(keys, []) 
开发者ID:holoviz,项目名称:holoviews,代码行数:8,代码来源:testtraversal.py

示例14: test_unique_keys_no_overlap_dynamicmap_initialized

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_unique_keys_no_overlap_dynamicmap_initialized(self):
        dmap1 = DynamicMap(lambda A: Curve(range(10)), kdims=['A'])
        dmap2 = DynamicMap(lambda B: Curve(range(10)), kdims=['B'])
        dmap1[0]
        dmap2[1]
        dims, keys = unique_dimkeys(dmap1+dmap2)
        self.assertEqual(dims, dmap1.kdims+dmap2.kdims)
        self.assertEqual(keys, [(0, 1)]) 
开发者ID:holoviz,项目名称:holoviews,代码行数:10,代码来源:testtraversal.py

示例15: test_opts_method_dynamicmap_grouped

# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import DynamicMap [as 别名]
def test_opts_method_dynamicmap_grouped(self):
        dmap = DynamicMap(lambda X: Curve([1, 2, X]),
                          kdims=['X']).redim.range(X=(0, 3))
        retval = dmap.opts({'plot': dict(width=700)})
        assert retval is not dmap
        self.assertEqual(self.lookup_options(retval[0], 'plot').options,
                         {'width':700}) 
开发者ID:holoviz,项目名称:holoviews,代码行数:9,代码来源:testoptions.py


注:本文中的holoviews.DynamicMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。