本文整理汇总了Python中dipy.segment.clustering.ClusterMap.refdata方法的典型用法代码示例。如果您正苦于以下问题:Python ClusterMap.refdata方法的具体用法?Python ClusterMap.refdata怎么用?Python ClusterMap.refdata使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dipy.segment.clustering.ClusterMap
的用法示例。
在下文中一共展示了ClusterMap.refdata方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cluster_map_iter
# 需要导入模块: from dipy.segment.clustering import ClusterMap [as 别名]
# 或者: from dipy.segment.clustering.ClusterMap import refdata [as 别名]
def test_cluster_map_iter():
rng = np.random.RandomState(42)
nb_clusters = 11
# Test without specifying refdata in ClusterMap
cluster_map = ClusterMap()
clusters = []
for i in range(nb_clusters):
new_cluster = Cluster(indices=rng.randint(0, len(data), size=10))
cluster_map.add_cluster(new_cluster)
clusters.append(new_cluster)
assert_true(all([c1 is c2 for c1, c2 in zip(cluster_map.clusters,
clusters)]))
assert_array_equal(cluster_map, clusters)
assert_array_equal(cluster_map.clusters, clusters)
assert_array_equal(cluster_map, [cluster.indices for cluster in clusters])
# Set refdata
cluster_map.refdata = data
for c1, c2 in zip(cluster_map, clusters):
assert_arrays_equal(c1, [data[i] for i in c2.indices])
# Remove refdata, i.e. back to indices
cluster_map.refdata = None
assert_array_equal(cluster_map, [cluster.indices for cluster in clusters])