本文整理汇总了Python中holoviews.Dataset.clone方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.clone方法的具体用法?Python Dataset.clone怎么用?Python Dataset.clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holoviews.Dataset
的用法示例。
在下文中一共展示了Dataset.clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HeterogeneousColumnTests
# 需要导入模块: from holoviews import Dataset [as 别名]
# 或者: from holoviews.Dataset import clone [as 别名]
class HeterogeneousColumnTests(HomogeneousColumnTests):
"""
Tests for data formats that allow dataset to have varied types
"""
def init_column_data(self):
self.kdims = ['Gender', 'Age']
self.vdims = ['Weight', 'Height']
self.gender, self.age = np.array(['M','M','F']), np.array([10,16,12])
self.weight, self.height = np.array([15,18,10]), np.array([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)
self.alias_kdims = [('gender', 'Gender'), ('age', 'Age')]
self.alias_vdims = [('weight', 'Weight'), ('height', 'Height')]
self.alias_table = Dataset({'gender':self.gender, 'age':self.age,
'weight':self.weight, 'height':self.height},
kdims=self.alias_kdims, vdims=self.alias_vdims)
super(HeterogeneousColumnTests, self).init_column_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'])
# Test the constructor to be supported by all interfaces supporting
# heterogeneous column types.
@pd_skip
def test_dataset_dataframe_init_ht(self):
"Tests support for heterogeneous DataFrames"
dataset = Dataset(pd.DataFrame({'x':self.xs, 'y':self.ys}), kdims=['x'], vdims=['y'])
self.assertTrue(isinstance(dataset.data, self.data_type))
@pd_skip
def test_dataset_dataframe_init_ht_alias(self):
"Tests support for heterogeneous DataFrames"
dataset = Dataset(pd.DataFrame({'x':self.xs, 'y':self.ys}),
kdims=[('x', 'X')], vdims=[('y', 'Y')])
self.assertTrue(isinstance(dataset.data, self.data_type))
# Test literal formats
def test_dataset_expanded_dimvals_ht(self):
self.assertEqual(self.table.dimension_values('Gender', expanded=False),
np.array(['M', 'F']))
def test_dataset_implicit_indexing_init(self):
dataset = Scatter(self.ys, kdims=['x'], vdims=['y'])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_tuple_init(self):
dataset = Dataset((self.xs, self.ys), kdims=['x'], vdims=['y'])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_tuple_init_alias(self):
dataset = Dataset((self.xs, self.ys), kdims=[('x', 'X')], vdims=[('y', 'Y')])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_simple_zip_init(self):
dataset = Dataset(zip(self.xs, self.ys), kdims=['x'], vdims=['y'])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_simple_zip_init_alias(self):
dataset = Dataset(zip(self.xs, self.ys), kdims=[('x', 'X')], vdims=[('y', 'Y')])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_zip_init(self):
dataset = Dataset(zip(self.gender, self.age,
self.weight, self.height),
kdims=self.kdims, vdims=self.vdims)
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_zip_init_alias(self):
dataset = self.alias_table.clone(zip(self.gender, self.age,
self.weight, self.height))
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_odict_init(self):
dataset = Dataset(OrderedDict(zip(self.xs, self.ys)), kdims=['A'], vdims=['B'])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_odict_init_alias(self):
dataset = Dataset(OrderedDict(zip(self.xs, self.ys)),
kdims=[('a', 'A')], vdims=[('b', 'B')])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_dict_init(self):
dataset = Dataset(dict(zip(self.xs, self.ys)), kdims=['A'], vdims=['B'])
self.assertTrue(isinstance(dataset.data, self.data_type))
def test_dataset_range_with_dimension_range(self):
dt64 = np.array([np.datetime64(datetime.datetime(2017, 1, i)) for i in range(1, 4)])
ds = Dataset(dt64, [Dimension('Date', range=(dt64[0], dt64[-1]))])
self.assertEqual(ds.range('Date'), (dt64[0], dt64[-1]))
# Operations
@pd_skip
#.........这里部分代码省略.........