本文整理汇总了Python中ClusterShell.RangeSet.RangeSetND.intersection_update方法的典型用法代码示例。如果您正苦于以下问题:Python RangeSetND.intersection_update方法的具体用法?Python RangeSetND.intersection_update怎么用?Python RangeSetND.intersection_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClusterShell.RangeSet.RangeSetND
的用法示例。
在下文中一共展示了RangeSetND.intersection_update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_intersection_update
# 需要导入模块: from ClusterShell.RangeSet import RangeSetND [as 别名]
# 或者: from ClusterShell.RangeSet.RangeSetND import intersection_update [as 别名]
def test_intersection_update(self):
rn1 = RangeSetND([["10", "10-13"], ["10", "9-12"]])
self.assertEqual(len(rn1), 5)
self.assertEqual(str(rn1), "10; 9-13\n")
# self test:
rn1.intersection_update(rn1)
self.assertEqual(len(rn1), 5)
self.assertEqual(str(rn1), "10; 9-13\n")
#
rn2 = RangeSetND([["10", "10"]])
rn1.intersection_update(rn2)
self.assertEqual(len(rn1), 1)
self.assertEqual(str(rn1), "10; 10\n")
rn1 = RangeSetND([["10", "10-13"], ["10", "9-12"], ["8-9", "12-15"]])
rn2 = RangeSetND([["10", "10"], ["9", "12-15"]])
rn1.intersection_update(rn2)
self.assertEqual(len(rn1), 5)
self.assertEqual(str(rn1), "9; 12-15\n10; 10\n")
rn1 = RangeSetND([["10", "10-13"], ["10", "9-12"], ["8-9", "12-15"]])
rn2 = RangeSetND([["10", "10"], ["9", "12-15"], ["10-12", "11-15"], ["11", "14"]])
rn1.intersection_update(rn2)
self.assertEqual(len(rn1), 8)
self.assertEqual(str(rn1), "9; 12-15\n10; 10-13\n")
rn1 = RangeSetND([["10", "10-13"], ["10", "9-12"], ["8-9", "12-15"], ["10", "10-13"], ["10", "12-16"], ["9", "13-16"]])
rn2 = RangeSetND([["10", "10"], ["9", "12-15"], ["10-12", "11-15"], ["11", "14"]])
rn1.intersection_update(rn2)
self.assertEqual(len(rn1), 10)
self.assertEqual(str(rn1), "10; 10-15\n9; 12-15\n")
rn1 = RangeSetND([["10", "10-13"], ["10", "9-12"], ["8-9", "12-15"], ["10", "10-13"], ["10", "12-16"], ["9", "13-16"]])
rn2 = RangeSetND([["10", "10"], ["9", "12-16"], ["10-12", "11-15"], ["11", "14"], ["8", "10-20"]])
rn1.intersection_update(rn2)
self.assertEqual(len(rn1), 15)
# no pre-fold (self._veclist)
self.assertEqual(str(rn1), "10; 10-15\n9; 12-16\n8; 12-15\n")
# pre-fold (self.veclist)
#self.assertEqual(str(rn1), "8-9; 12-15\n10; 10-15\n9; 16\n")
# binary error
if sys.version_info >= (2, 5, 0):
rn1 = RangeSetND([["10", "10-13"], ["10", "9-12"]])
rn2 = RangeSetND([["10", "10"]])
rn1 &= rn2
self.assertEqual(len(rn1), 1)
self.assertEqual(str(rn1), "10; 10\n")
rn2 = set([3, 5])
self.assertRaises(TypeError, rn1.__iand__, rn2)