本文整理汇总了Python中dipy.segment.clustering.ClusterMap.remove_cluster方法的典型用法代码示例。如果您正苦于以下问题:Python ClusterMap.remove_cluster方法的具体用法?Python ClusterMap.remove_cluster怎么用?Python ClusterMap.remove_cluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dipy.segment.clustering.ClusterMap
的用法示例。
在下文中一共展示了ClusterMap.remove_cluster方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cluster_map_remove_cluster
# 需要导入模块: from dipy.segment.clustering import ClusterMap [as 别名]
# 或者: from dipy.segment.clustering.ClusterMap import remove_cluster [as 别名]
def test_cluster_map_remove_cluster():
clusters = ClusterMap()
cluster1 = Cluster(indices=[1])
clusters.add_cluster(cluster1)
cluster2 = Cluster(indices=[1, 2])
clusters.add_cluster(cluster2)
cluster3 = Cluster(indices=[1, 2, 3])
clusters.add_cluster(cluster3)
assert_equal(len(clusters), 3)
clusters.remove_cluster(cluster2)
assert_equal(len(clusters), 2)
assert_array_equal(list(itertools.chain(*clusters)),
list(itertools.chain(*[cluster1, cluster3])))
assert_equal(clusters[0], cluster1)
assert_equal(clusters[1], cluster3)
clusters.remove_cluster(cluster3)
assert_equal(len(clusters), 1)
assert_array_equal(list(itertools.chain(*clusters)), list(cluster1))
assert_equal(clusters[0], cluster1)
clusters.remove_cluster(cluster1)
assert_equal(len(clusters), 0)
assert_array_equal(list(itertools.chain(*clusters)), [])
# Test removing multiple clusters at once.
clusters = ClusterMap()
clusters.add_cluster(cluster1, cluster2, cluster3)
clusters.remove_cluster(cluster3, cluster2)
assert_equal(len(clusters), 1)
assert_array_equal(list(itertools.chain(*clusters)), list(cluster1))
assert_equal(clusters[0], cluster1)
clusters = ClusterMap()
clusters.add_cluster(cluster2, cluster1, cluster3)
clusters.remove_cluster(cluster1, cluster3, cluster2)
assert_equal(len(clusters), 0)
assert_array_equal(list(itertools.chain(*clusters)), [])