本文整理汇总了Python中holoviews.core.data.Dataset.dimension_values方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.dimension_values方法的具体用法?Python Dataset.dimension_values怎么用?Python Dataset.dimension_values使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holoviews.core.data.Dataset
的用法示例。
在下文中一共展示了Dataset.dimension_values方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_construct_3d_from_xarray
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_construct_3d_from_xarray(self):
try:
import xarray as xr
except:
raise SkipTest("Test requires xarray")
zs = np.arange(48).reshape(2, 4, 6)
da = xr.DataArray(zs, dims=['z', 'y', 'x'],
coords = {'lat': (('y', 'x'), self.ys),
'lon': (('y', 'x'), self.xs),
'z': [0, 1]}, name='A')
dataset = Dataset(da, ['lon', 'lat', 'z'], 'A')
self.assertEqual(dataset.dimension_values('lon'), self.xs.T.flatten())
self.assertEqual(dataset.dimension_values('lat'), self.ys.T.flatten())
self.assertEqual(dataset.dimension_values('z', expanded=False), np.array([0, 1]))
self.assertEqual(dataset.dimension_values('A'), zs.T.flatten())
示例2: test_dimension_values_vdim
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
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))
示例3: test_irregular_grid_data_values_inverted_y
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
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)
示例4: test_construct_from_xarray
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_construct_from_xarray(self):
try:
import xarray as xr
except:
raise SkipTest("Test requires xarray")
coords = OrderedDict([('lat', (('y', 'x'), self.ys)),
('lon', (('y', 'x'), self.xs))])
da = xr.DataArray(self.zs, dims=['y', 'x'],
coords=coords, name='z')
dataset = Dataset(da)
# Ensure that dimensions are inferred correctly
self.assertEqual(dataset.kdims, [Dimension('lat'), Dimension('lon')])
self.assertEqual(dataset.vdims, [Dimension('z')])
# Ensure that canonicalization works on multi-dimensional coordinates
self.assertEqual(dataset.dimension_values('lon', flat=False), self.xs)
self.assertEqual(dataset.dimension_values('lat', flat=False), self.ys)
self.assertEqual(dataset.dimension_values('z'), self.zs.T.flatten())
示例5: test_xarray_dataset_with_scalar_dim_canonicalize
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
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)
示例6: test_3d_xarray_with_constant_dim_canonicalized_to_2d
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_3d_xarray_with_constant_dim_canonicalized_to_2d(self):
try:
import xarray as xr
except:
raise SkipTest("Test requires xarray")
zs = np.arange(24).reshape(1, 4, 6)
# Construct DataArray with additional constant dimension
da = xr.DataArray(zs, dims=['z', 'y', 'x'],
coords = {'lat': (('y', 'x'), self.ys),
'lon': (('y', 'x'), self.xs),
'z': [0]}, name='A')
# Declare Dataset without declaring constant dimension
dataset = Dataset(da, ['lon', 'lat'], 'A')
# Ensure that canonicalization drops the constant dimension
self.assertEqual(dataset.dimension_values('A', flat=False), zs[0])
示例7: test_dimension_values_kdim
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_dimension_values_kdim(self):
cube = Dataset(self.cube, kdims=['longitude', 'latitude'])
self.assertEqual(cube.dimension_values('longitude', expanded=False),
np.array([-1, 0, 1, 2], dtype=np.int32))
示例8: test_dataset_empty_list_init_dtypes
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_dataset_empty_list_init_dtypes(self):
dataset = Dataset([], kdims=['x'], vdims=['y'])
for d in 'xy':
self.assertEqual(dataset.dimension_values(d).dtype, np.float64)
示例9: test_graph_node_info_merge_on_index
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_graph_node_info_merge_on_index(self):
node_info = Dataset((np.arange(8), np.arange(1,9)), 'index', 'label')
graph = Graph(((self.source, self.target), node_info))
self.assertEqual(graph.nodes.dimension_values(3),
node_info.dimension_values(1))
示例10: test_graph_node_info_no_index
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_graph_node_info_no_index(self):
node_info = Dataset(np.arange(8), vdims=['Label'])
graph = Graph(((self.source, self.target), node_info))
self.assertEqual(graph.nodes.dimension_values(3),
node_info.dimension_values(0))
示例11: test_construct_from_dict
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_construct_from_dict(self):
dataset = Dataset((self.xs, self.ys, self.zs), ['x', 'y'], 'z')
self.assertEqual(dataset.dimension_values('x'), self.xs.T.flatten())
self.assertEqual(dataset.dimension_values('y'), self.ys.T.flatten())
self.assertEqual(dataset.dimension_values('z'), self.zs.T.flatten())
示例12: test_irregular_and_regular_coordinate_explicit_irregular_coords_inverted
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_irregular_and_regular_coordinate_explicit_irregular_coords_inverted(self):
data = self.get_irregular_dataarray(False)
ds = Dataset(data, ['xc', 'yc'], vdims='Value')
self.assertEqual(ds.kdims, [Dimension('xc'), Dimension('yc')])
self.assertEqual(ds.dimension_values(2, flat=False), data.values[0])
示例13: test_irregular_and_regular_coordinate_inference_inverted
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_irregular_and_regular_coordinate_inference_inverted(self):
data = self.get_irregular_dataarray(False)
ds = Dataset(data, vdims='Value')
self.assertEqual(ds.kdims, [Dimension('band'), Dimension('x'), Dimension('y')])
self.assertEqual(ds.dimension_values(3, flat=False), data.values.transpose([1, 2, 0]))
示例14: test_dataset_allow_none_values
# 需要导入模块: from holoviews.core.data import Dataset [as 别名]
# 或者: from holoviews.core.data.Dataset import dimension_values [as 别名]
def test_dataset_allow_none_values(self):
ds = Dataset({'x': None, 'y': [0, 1]}, kdims=['x', 'y'])
self.assertEqual(ds.dimension_values(0), np.array([None, None]))