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


Python data.Dataset类代码示例

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


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

示例1: test_dimension_values_vdim

 def test_dimension_values_vdim(self):
     cube = Dataset(self.cube, kdims=['longitude', 'latitude'])
     self.assertEqual(cube.dimension_values('unknown', flat=False),
                      np.flipud(np.array([[ 0,  4,  8],
                                          [ 1,  5,  9],
                                          [ 2,  6, 10],
                                          [ 3,  7, 11]], dtype=np.int32).T))
开发者ID:tinloaf,项目名称:holoviews,代码行数:7,代码来源:testirisinterface.py

示例2: test_dataset_groupby_drop_dims_dynamic_with_vdim

 def test_dataset_groupby_drop_dims_dynamic_with_vdim(self):
     array = da.from_array(np.random.rand(3, 20, 10), 3)
     ds = Dataset({'x': range(10), 'y': range(20), 'z': range(3), 'Val': array, 'Val2': array*2},
                  kdims=['x', 'y', 'z'], vdims=['Val', 'Val2'])
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], (ds, Dataset)):
         partial = ds.to(Dataset, kdims=['Val'], vdims=['Val2'], groupby='y', dynamic=True)
         self.assertEqual(partial[19]['Val'], array[:, -1, :].T.flatten().compute())
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testgridinterface.py

示例3: test_dataset_2D_aggregate_partial_hm_alias

 def test_dataset_2D_aggregate_partial_hm_alias(self):
     array = da.from_array(np.random.rand(11, 11), 3)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=[('x', 'X'), ('y', 'Y')], vdims=[('z', 'Z')])
     self.assertEqual(dataset.aggregate(['X'], np.mean),
                      Dataset({'x':self.xs, 'z': np.mean(array, axis=0).compute()},
                              kdims=[('x', 'X')], vdims=[('z', 'Z')]))
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testgridinterface.py

示例4: 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:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testgridinterface.py

示例5: test_dataset_groupby_drop_dims_with_vdim

 def test_dataset_groupby_drop_dims_with_vdim(self):
     array = np.random.rand(3, 20, 10)
     ds = Dataset({'x': range(10), 'y': range(20), 'z': range(3), 'Val': array, 'Val2': array*2},
                  kdims=['x', 'y', 'z'], vdims=['Val', 'Val2'])
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], (ds, Dataset)):
         partial = ds.to(Dataset, kdims=['Val'], vdims=['Val2'], groupby='y')
     self.assertEqual(partial.last['Val'], array[:, -1, :].T.flatten())
开发者ID:basnijholt,项目名称:holoviews,代码行数:7,代码来源:testgridinterface.py

示例6: test_irregular_grid_data_values_inverted_y

 def test_irregular_grid_data_values_inverted_y(self):
     nx, ny = 20, 5
     xs, ys = np.meshgrid(np.arange(nx)+0.5, np.arange(ny)*-1+0.5)
     zs = np.arange(100).reshape(5, 20)
     ds = Dataset((xs, ys, zs), ['x', 'y'], 'z')
     self.assertEqual(ds.dimension_values(2, flat=False), zs)
     self.assertEqual(ds.interface.coords(ds, 'x'), xs)
     self.assertEqual(ds.interface.coords(ds, 'y'), ys)
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testgridinterface.py

示例7: test_dataset_2D_reduce_hm_alias

 def test_dataset_2D_reduce_hm_alias(self):
     array = np.random.rand(11, 11)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=[('x', 'X'), ('y', 'Y')], vdims=[('z', 'Z')])
     self.assertEqual(np.array(dataset.reduce(['x', 'y'], np.mean)),
                      np.mean(array))
     self.assertEqual(np.array(dataset.reduce(['X', 'Y'], np.mean)),
                      np.mean(array))
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testgridinterface.py

示例8: test_multi_dimension_groupby

 def test_multi_dimension_groupby(self):
     x, y, z = list('AB'*10), np.arange(20)%3, np.arange(20)
     ds = Dataset((x, y, z), kdims=['x', 'y'], vdims=['z'],  datatype=[self.datatype])
     keys = [('A', 0), ('B', 1), ('A', 2), ('B', 0), ('A', 1), ('B', 2)]
     grouped = ds.groupby(['x', 'y'])
     self.assertEqual(grouped.keys(), keys)
     group = Dataset({'z': [5, 11, 17]}, vdims=['z'])
     self.assertEqual(grouped.last, group)
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testpandasinterface.py

示例9: test_select_dropped_dimensions_restoration

 def test_select_dropped_dimensions_restoration(self):
     d = np.random.randn(3, 8)
     da = xr.DataArray(d, name='stuff', dims=['chain', 'value'],
         coords=dict(chain=range(d.shape[0]), value=range(d.shape[1])))
     ds = Dataset(da)
     t = ds.select(chain=0)
     self.assertEqual(t.data.dims , dict(chain=1,value=8))
     self.assertEqual(t.data.stuff.shape , (1,8))
开发者ID:ioam,项目名称:holoviews,代码行数:8,代码来源:testxarrayinterface.py

示例10: test_zero_sized_coordinates_range

 def test_zero_sized_coordinates_range(self):
     da = xr.DataArray(np.empty((2, 0)), dims=('y', 'x'), coords={'x': [], 'y': [0 ,1]}, name='A')
     ds = Dataset(da)
     x0, x1 = ds.range('x')
     self.assertTrue(np.isnan(x0))
     self.assertTrue(np.isnan(x1))
     z0, z1 = ds.range('A')
     self.assertTrue(np.isnan(z0))
     self.assertTrue(np.isnan(z1))
开发者ID:basnijholt,项目名称:holoviews,代码行数:9,代码来源:testxarrayinterface.py

示例11: test_dataset_groupby_multiple_dims

 def test_dataset_groupby_multiple_dims(self):
     dataset = Dataset((range(8), range(8), range(8), range(8),
                        da.from_array(np.random.rand(8, 8, 8, 8), 4)),
                       kdims=['a', 'b', 'c', 'd'], vdims=['Value'])
     grouped = dataset.groupby(['c', 'd'])
     keys = list(product(range(8), range(8)))
     self.assertEqual(list(grouped.keys()), keys)
     for c, d in keys:
         self.assertEqual(grouped[c, d], dataset.select(c=c, d=d).reindex(['a', 'b']))
开发者ID:basnijholt,项目名称:holoviews,代码行数:9,代码来源:testgridinterface.py

示例12: test_dataset_groupby_dynamic_alias

 def test_dataset_groupby_dynamic_alias(self):
     array = da.from_array(np.random.rand(11, 11), 3)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=[('x', 'X'), ('y', 'Y')], vdims=[('z', 'Z')])
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], dataset):
         grouped = dataset.groupby('X', dynamic=True)
     first = Dataset({'y': self.y_ints, 'z': array[:, 0].compute()},
                     kdims=[('y', 'Y')], vdims=[('z', 'Z')])
     self.assertEqual(grouped[0], first)
开发者ID:basnijholt,项目名称:holoviews,代码行数:9,代码来源:testgridinterface.py

示例13: test_dataset_groupby_dynamic

 def test_dataset_groupby_dynamic(self):
     array = np.random.rand(11, 11)
     dataset = Dataset({'x':self.xs, 'y':self.y_ints, 'z': array},
                       kdims=['x', 'y'], vdims=['z'])
     with DatatypeContext([self.datatype, 'dictionary' , 'dataframe'], dataset):
         grouped = dataset.groupby('x', dynamic=True)
     first = Dataset({'y': self.y_ints, 'z': array[:, 0]},
                     kdims=['y'], vdims=['z'])
     self.assertEqual(grouped[0], first)
开发者ID:basnijholt,项目名称:holoviews,代码行数:9,代码来源:testgridinterface.py

示例14: test_xarray_dataset_with_scalar_dim_canonicalize

 def test_xarray_dataset_with_scalar_dim_canonicalize(self):
     xs = [0, 1]
     ys = [0.1, 0.2, 0.3]
     zs = np.array([[[0, 1], [2, 3], [4, 5]]])
     xrarr = xr.DataArray(zs, coords={'x': xs, 'y': ys, 't': [1]}, dims=['t', 'y', 'x'])
     xrds = xr.Dataset({'v': xrarr})
     ds = Dataset(xrds, kdims=['x', 'y'], vdims=['v'], datatype=['xarray'])
     canonical = ds.dimension_values(2, flat=False)
     self.assertEqual(canonical.ndim, 2)
     expected = np.array([[0, 1], [2, 3], [4, 5]])
     self.assertEqual(canonical, expected)
开发者ID:basnijholt,项目名称:holoviews,代码行数:11,代码来源:testxarrayinterface.py

示例15: test_xarray_dataset_names_and_units

 def test_xarray_dataset_names_and_units(self):
     xs = [0.1, 0.2, 0.3]
     ys = [0, 1]
     zs = np.array([[0, 1], [2, 3], [4, 5]])
     da = xr.DataArray(zs, coords=[('x_dim', xs), ('y_dim', ys)], name="data_name", dims=['y_dim', 'x_dim'])
     da.attrs['long_name'] = "data long name"
     da.attrs['units'] = "array_unit"
     da.x_dim.attrs['units'] = "x_unit"
     da.y_dim.attrs['long_name'] = "y axis long name"
     dataset = Dataset(da)
     self.assertEqual(dataset.get_dimension("x_dim"), Dimension("x_dim", unit="x_unit"))
     self.assertEqual(dataset.get_dimension("y_dim"), Dimension("y_dim", label="y axis long name"))
     self.assertEqual(dataset.get_dimension("data_name"),
                      Dimension("data_name", label="data long name", unit="array_unit"))
开发者ID:basnijholt,项目名称:holoviews,代码行数:14,代码来源:testxarrayinterface.py


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