How to use the holoviews.core.Dimension function in holoviews

To help you get started, we’ve selected a few holoviews examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github holoviz / holoviews / tests / core / testdimensions.py View on Github external
def test_weak_dim_equality(self):
        dim1 = Dimension('test', cyclic=True, unit='m', type=float)
        dim2 = Dimension('test', cyclic=False, unit='km', type=int)
        self.assertEqual(dim1==dim2, True)
github holoviz / holoviews / tests / plotting / matplotlib / testwidgets.py View on Github external
def test_dynamic_nonoverlap(self):
        kdims = [Dimension('File', range=(0.01, 1)),
                 Dimension('SliceDimension', range=(0.01, 1)),
                 Dimension('Coordinates', range=(0.01, 1))]
        dmap1 = DynamicMap(lambda x, y, z: Image(np.random.rand(10,10)), kdims=kdims)
        dmap2 = DynamicMap(lambda x: Curve(np.random.rand(10,2))*VLine(x),
                           kdims=kdims[:1])
        mpl_renderer.get_widget(dmap1 + dmap2, 'selection')
github holoviz / holoviews / tests / core / testdimensions.py View on Github external
def test_dimension_values_series_duplicates1(self):
        if pd is None:
            raise SkipTest("Pandas not available")
        df = pd.DataFrame({'col':self.duplicates1})
        dim = Dimension('test', values=df['col'])
        self.assertEqual(dim.values, self.values1)
github holoviz / holoviews / tests / element / testcomparisondimension.py View on Github external
def setUp(self):
        super(DimensionedComparisonTestCase, self).setUp()
        # Value dimension lists
        self.value_list1 = [Dimension('val1')]
        self.value_list2 = [Dimension('val2')]
        # Key dimension lists
        self.key_list1 = [Dimension('key1')]
        self.key_list2 = [Dimension('key2')]
        # Dimensioned instances
        self.dimensioned1 = Dimensioned('data1', vdims=self.value_list1,
                                        kdims=self.key_list1)
        self.dimensioned2 = Dimensioned('data2', vdims=self.value_list2,
                                        kdims=self.key_list1)

        self.dimensioned3 = Dimensioned('data3', vdims=self.value_list1,
                                        kdims=self.key_list2)

        self.dimensioned4 = Dimensioned('data4', vdims=[],
                                        kdims=self.key_list1)

        self.dimensioned5 = Dimensioned('data5', vdims=self.value_list1,
                                        kdims=[])
        # Value / Label comparison tests
github holoviz / holoviews / tests / plotting / bokeh / testhextilesplot.py View on Github external
def test_hex_tiles_count_aggregation(self):
        tiles = HexTiles([(0, 0), (0.5, 0.5), (-0.5, -0.5), (-0.4, -0.4)])
        binned = hex_binning(tiles, gridsize=3)
        expected = HexTiles([(0, 0, 1), (2, -1, 1), (-2, 1, 2)],
                            kdims=[Dimension('x', range=(-0.5, 0.5)),
                                   Dimension('y', range=(-0.5, 0.5))],
                            vdims='Count')
        self.assertEqual(binned, expected)
github holoviz / holoviews / tests / core / testdimensions.py View on Github external
def test_dimension_values_array1(self):
        dim = Dimension('test', values=np.array(self.values1))
        self.assertEqual(dim.values, self.values1)
github holoviz / holoviews / holoviews / element / graphs.py View on Github external
"pandas.")
            dimensions = nodes.dimensions()
            for d in node_info.vdims:
                if d in dimensions:
                    continue
                nodes = nodes.add_dimension(d, len(nodes.vdims),
                                            node_info.dimension_values(d),
                                            vdim=True)
        else:
            left_on = nodes.kdims[-1].name
            node_info_df = node_info.dframe()
            node_df = nodes.dframe()
            if node_info.kdims:
                idx = node_info.kdims[-1]
            else:
                idx = Dimension('index')
                node_info_df = node_info_df.reset_index()
            if 'index' in node_info_df.columns and not idx.name == 'index':
                node_df = node_df.rename(columns={'index': '__index'})
                left_on = '__index'
            cols = [c for c in node_info_df.columns if c not in
                    node_df.columns or c == idx.name]
            node_info_df = node_info_df[cols]
            node_df = pd.merge(node_df, node_info_df, left_on=left_on,
                               right_on=idx.name, how='left')
            nodes = nodes.clone(node_df, kdims=nodes.kdims[:2]+[idx],
                                vdims=node_info.vdims)

        self._nodes = nodes
github holoviz / holoviews / holoviews / element / annotation.py View on Github external
if not isinstance(data, basestring):
            raise ValueError("Div element html data must be a string "
                             "type, found %s type." % type(data).__name__)
        super(Div, self).__init__(data, **params)



class Labels(Dataset, Element2D):
    """
    Labels represents a collection of text labels associated with 2D
    coordinates. Unlike the Text annotation, Labels is a Dataset type
    which allows drawing vectorized labels from tabular or gridded
    data.
    """

    kdims = param.List(default=[Dimension('x'), Dimension('y')],
                       bounds=(2, 2), constant=True, doc="""
        The label of the x- and y-dimension of the Labels element in form
        of a string or dimension object.""")

    group = param.String(default='Labels', constant=True)

    vdims = param.List([Dimension('Label')], bounds=(1, None), doc="""
        Defines the value dimension corresponding to the label text.""")
github holoviz / geoviews / geoviews / element / geo.py View on Github external
"""
    QuadMesh is a Raster type to hold x- and y- bin values
    with associated values. The x- and y-values of the QuadMesh
    may be supplied either as the edges of each bin allowing
    uneven sampling or as the bin centers, which will be converted
    to evenly sampled edges.

    As a secondary but less supported mode QuadMesh can contain
    a mesh of quadrilateral coordinates that is not laid out in
    a grid. The data should then be supplied as three separate
    2D arrays for the x-/y-coordinates and grid values.
    """

    datatype = param.List(default=['grid', 'xarray'])

    vdims = param.List(default=[Dimension('z')], bounds=(1, 1))

    group = param.String(default='QuadMesh')

    _binned = True

    def trimesh(self):
        trimesh = super(QuadMesh, self).trimesh()
        node_params = get_param_values(trimesh.nodes)
        nodes = TriMesh.node_type(trimesh.nodes.data, **node_params)
        return TriMesh((trimesh.data, nodes), crs=self.crs,
                       **get_param_values(trimesh))


class RGB(_Element, HvRGB):
    """
    An RGB element is a Image containing channel data for the the
github holoviz / holoviews / holoviews / element / chart.py View on Github external
location along the x-axis and the first value dimension 
    corresponds to the location along the y-axis and one or two 
    extra value dimensions corresponding to the symmetric or 
    asymetric errors either along x-axis or y-axis. If two value
    dimensions are given, then the last value dimension will be 
    taken as symmetric errors. If three value dimensions are given 
    then the last two value dimensions will be taken as negative and
    positive errors. By default the errors are defined along y-axis.
    A parameter `horizontal`, when set `True`, will define the errors
    along the x-axis.
    """
    group = param.String(default='ErrorBars', constant=True, doc="""
        A string describing the quantity measured by the ErrorBars
        object.""")

    vdims = param.List(default=[Dimension('y'), Dimension('yerror')],
                       bounds=(1, None), constant=True)

    horizontal = param.Boolean(default=False, doc="""
        Whether the errors are along y-axis (vertical) or x-axis.""")

    def range(self, dim, data_range=True, dimension_range=True):
        """Return the lower and upper bounds of values along dimension.

        Range of the y-dimension includes the symmetric or assymetric
        error.

        Args:
            dimension: The dimension to compute the range on.
            data_range (bool): Compute range from data values
            dimension_range (bool): Include Dimension ranges
                Whether to include Dimension range and soft_range