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


Python holoviews.Dataset类代码示例

本文整理汇总了Python中holoviews.Dataset的典型用法代码示例。如果您正苦于以下问题:Python Dataset类的具体用法?Python Dataset怎么用?Python Dataset使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_dataset_2D_aggregate_partial_hm

 def test_dataset_2D_aggregate_partial_hm(self):
     array = np.random.rand(11, 11)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=['x', 'y'], vdims=['z'])
     self.assertEqual(dataset.aggregate(['x'], np.mean),
                      Dataset({'x':self.xs, 'z': np.mean(array, axis=0)},
                              kdims=['x'], vdims=['z']))
开发者ID:RafalSkolasinski,项目名称:holoviews,代码行数:7,代码来源:testdataset.py

示例2: test_dataset_sort_vdim_hm

 def test_dataset_sort_vdim_hm(self):
     xs_2 = np.array(self.xs_2)
     dataset = Dataset(np.column_stack([self.xs, -xs_2]),
                       kdims=['x'], vdims=['y'])
     dataset_sorted = Dataset(np.column_stack([self.xs[::-1], -xs_2[::-1]]),
                              kdims=['x'], vdims=['y'])
     self.assertEqual(dataset.sort('y'), dataset_sorted)
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:base.py

示例3: test_dataset_redim_with_alias_dframe

 def test_dataset_redim_with_alias_dframe(self):
     test_df = pd.DataFrame({'x': range(10), 'y': range(0,20,2)})
     dataset = Dataset(test_df, kdims=[('x', 'X-label')], vdims=['y'])
     redim_df = pd.DataFrame({'X': range(10), 'y': range(0,20,2)})
     dataset_redim = Dataset(redim_df, kdims=['X'], vdims=['y'])
     self.assertEqual(dataset.redim(**{'X-label':'X'}), dataset_redim)
     self.assertEqual(dataset.redim(**{'x':'X'}), dataset_redim)
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:base.py

示例4: test_dataset_reindex_non_constant

 def test_dataset_reindex_non_constant(self):
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe', 'grid'], self.rgb):
         ds = Dataset(self.rgb)
         reindexed = ds.reindex(['y'], ['R'])
     data = Dataset(ds.columns(['y', 'R']),
                    kdims=['y'], vdims=[ds.vdims[0]])
     self.assertEqual(reindexed, data)
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testimageinterface.py

示例5: test_dataset_sort_reverse_vdim_hm

 def test_dataset_sort_reverse_vdim_hm(self):
     xs_2 = np.array(self.xs_2)
     dataset = Dataset(np.column_stack([self.xs, -xs_2]),
                       kdims=['x'], vdims=['y'])
     dataset_sorted = Dataset(np.column_stack([self.xs, -xs_2]),
                              kdims=['x'], vdims=['y'])
     self.assertEqual(dataset.sort('y', reverse=True), dataset_sorted)
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:base.py

示例6: test_dataset_reindex_constant

 def test_dataset_reindex_constant(self):
     with DatatypeContext([self.datatype, 'dictionary', 'dataframe', 'grid'], self.image):
         selected = Dataset(self.image.select(x=0))
         reindexed = selected.reindex(['y'])
     data = Dataset(selected.columns(['y', 'z']),
                    kdims=['y'], vdims=['z'])
     self.assertEqual(reindexed, data)
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testimageinterface.py

示例7: test_aggregate_ndoverlay

 def test_aggregate_ndoverlay(self):
     ds = Dataset([(0.2, 0.3, 0), (0.4, 0.7, 1), (0, 0.99, 2)], kdims=['x', 'y', 'z'])
     ndoverlay = ds.to(Points, ['x', 'y'], [], 'z').overlay()
     expected = Image(([0.25, 0.75], [0.25, 0.75], [[1, 0], [2, 0]]),
                      vdims=['Count'])
     img = aggregate(ndoverlay, dynamic=False,  x_range=(0, 1), y_range=(0, 1),
                     width=2, height=2)
     self.assertEqual(img, expected)
开发者ID:mforbes,项目名称:holoviews,代码行数:8,代码来源:testdatashader.py

示例8: test_dataset_sort_vdim_hm_alias

 def test_dataset_sort_vdim_hm_alias(self):
     xs_2 = np.array(self.xs_2)
     dataset = Dataset(np.column_stack([self.xs, -xs_2]),
                       kdims=[('x', 'X-label')], vdims=[('y', 'Y-label')])
     dataset_sorted = Dataset(np.column_stack([self.xs[::-1], -xs_2[::-1]]),
                              kdims=[('x', 'X-label')], vdims=[('y', 'Y-label')])
     self.assertEqual(dataset.sort('y'), dataset_sorted)
     self.assertEqual(dataset.sort('Y-label'), dataset_sorted)
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:base.py

示例9: test_dataset_2D_aggregate_spread_fn_with_duplicates

 def test_dataset_2D_aggregate_spread_fn_with_duplicates(self):
     dataset = Dataset({'x': np.array([0, 0, 1, 1]), 'y': np.array([0, 1, 2, 3]),
                        'z': np.array([1, 2, 3, 4])},
                       kdims=['x', 'y'], vdims=['z'])
     agg = dataset.aggregate('x', function=np.mean, spreadfn=np.var)
     self.assertEqual(agg, Dataset({'x': np.array([0, 1]), 'z': np.array([1.5, 3.5]),
                                    'z_var': np.array([0.25, 0.25])},
                                   kdims=['x'], vdims=['z', 'z_var']))
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:base.py

示例10: init_column_data

    def init_column_data(self):
        self.xs = np.array(range(11))
        self.xs_2 = self.xs**2

        self.y_ints = self.xs*2
        self.dataset_hm = Dataset((self.xs, self.y_ints),
                                  kdims=['x'], vdims=['y'])
        self.dataset_hm_alias = Dataset((self.xs, self.y_ints),
                                        kdims=[('x', 'X')], vdims=[('y', 'Y')])
开发者ID:basnijholt,项目名称:holoviews,代码行数:9,代码来源:base.py

示例11: init_data

    def init_data(self):
        self.kdims = ['Gender', 'Age']
        self.vdims = ['Weight', 'Height']
        self.gender, self.age = ['M','M','F'], [10,16,12]
        self.weight, self.height = [15,18,10], [0.8,0.6,0.8]
        self.table = Dataset({'Gender':self.gender, 'Age':self.age,
                              'Weight':self.weight, 'Height':self.height},
                             kdims=self.kdims, vdims=self.vdims)

        super(HeterogeneousColumnTypes, self).init_data()
        self.ys = np.linspace(0, 1, 11)
        self.zs = np.sin(self.xs)
        self.dataset_ht = Dataset({'x':self.xs, 'y':self.ys},
                                  kdims=['x'], vdims=['y'])
开发者ID:RafalSkolasinski,项目名称:holoviews,代码行数:14,代码来源:testdataset.py

示例12: HoloMapTest

class HoloMapTest(ComparisonTestCase):

    def setUp(self):
        self.xs = range(11)
        self.y_ints = [i*2 for i in range(11)]
        self.ys = np.linspace(0, 1, 11)
        self.columns = Dataset(np.column_stack([self.xs, self.y_ints]),
                               kdims=['x'], vdims=['y'])

    def test_holomap_redim(self):
        hmap = HoloMap({i: Dataset({'x':self.xs, 'y': self.ys * i},
                                   kdims=['x'], vdims=['y'])
                        for i in range(10)}, kdims=['z'])
        redimmed = hmap.redim(x='Time')
        self.assertEqual(redimmed.dimensions('all', True),
                         ['z', 'Time', 'y'])

    def test_holomap_redim_nested(self):
        hmap = HoloMap({i: Dataset({'x':self.xs, 'y': self.ys * i},
                                   kdims=['x'], vdims=['y'])
                        for i in range(10)}, kdims=['z'])
        redimmed = hmap.redim(x='Time', z='Magnitude')
        self.assertEqual(redimmed.dimensions('all', True),
                         ['Magnitude', 'Time', 'y'])

    def test_columns_collapse_heterogeneous(self):
        collapsed = HoloMap({i: Dataset({'x':self.xs, 'y': self.ys * i},
                                        kdims=['x'], vdims=['y'])
                             for i in range(10)}, kdims=['z']).collapse('z', np.mean)
        expected = Dataset({'x':self.xs, 'y': self.ys * 4.5}, kdims=['x'], vdims=['y'])
        self.compare_dataset(collapsed, expected)


    def test_columns_sample_homogeneous(self):
        samples = self.columns.sample([0, 5, 10]).dimension_values('y')
        self.assertEqual(samples, np.array([0, 10, 20]))

    def test_holomap_map_with_none(self):
        hmap = HoloMap({i: Dataset({'x':self.xs, 'y': self.ys * i},
                                   kdims=['x'], vdims=['y'])
                        for i in range(10)}, kdims=['z'])
        mapped = hmap.map(lambda x: x if x.range(1)[1] > 0 else None, Dataset)
        self.assertEqual(hmap[1:10], mapped)

    def test_holomap_hist_two_dims(self):
        hmap = HoloMap({i: Dataset({'x':self.xs, 'y': self.ys * i},
                                   kdims=['x'], vdims=['y'])
                        for i in range(10)}, kdims=['z'])
        hists = hmap.hist(dimension=['x', 'y'])
        self.assertEqual(hists['right'].last.kdims, ['y'])
        self.assertEqual(hists['top'].last.kdims, ['x'])
开发者ID:basnijholt,项目名称:holoviews,代码行数:51,代码来源:testndmapping.py

示例13: HoloMapTest

class HoloMapTest(ComparisonTestCase):

    def setUp(self):
        self.xs = range(11)
        self.y_ints = [i*2 for i in range(11)]
        self.ys = np.linspace(0, 1, 11)
        self.columns = Dataset(np.column_stack([self.xs, self.y_ints]),
                               kdims=['x'], vdims=['y'])


    def test_columns_collapse_heterogeneous(self):
        collapsed = HoloMap({i: Dataset({'x':self.xs, 'y': self.ys * i},
                                        kdims=['x'], vdims=['y'])
                             for i in range(10)}, kdims=['z']).collapse('z', np.mean)
        expected = Dataset({'x':self.xs, 'y': self.ys * 4.5}, kdims=['x'], vdims=['y'])
        self.compare_dataset(collapsed, expected)


    def test_columns_sample_homogeneous(self):
        samples = self.columns.sample([0, 5, 10]).dimension_values('y')
        self.assertEqual(samples, np.array([0, 10, 20]))
开发者ID:RafalSkolasinski,项目名称:holoviews,代码行数:21,代码来源:testndmapping.py

示例14: test_dataset_scalar_empty_select

 def test_dataset_scalar_empty_select(self):
     ds = Dataset({'A': 1, 'B': np.arange(10)}, kdims=['A', 'B'])
     self.assertEqual(ds.select(A=0).dimension_values('B'), np.array([]))
开发者ID:basnijholt,项目名称:holoviews,代码行数:3,代码来源:base.py

示例15: test_dataset_scalar_array

 def test_dataset_scalar_array(self):
     ds = Dataset({'A': 1, 'B': np.arange(10)}, kdims=['A', 'B'])
     self.assertEqual(ds.array(), np.column_stack([np.ones(10), np.arange(10)]))
开发者ID:basnijholt,项目名称:holoviews,代码行数:3,代码来源:base.py


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