本文整理汇总了Python中configuration.Configuration.matches方法的典型用法代码示例。如果您正苦于以下问题:Python Configuration.matches方法的具体用法?Python Configuration.matches怎么用?Python Configuration.matches使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类configuration.Configuration
的用法示例。
在下文中一共展示了Configuration.matches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from configuration import Configuration [as 别名]
# 或者: from configuration.Configuration import matches [as 别名]
class TestConfiguration:
"""
"""
def setUp(self):
self.neighborhood = Neighborhood(0)
self.plane2d = plane.Plane((10, 10))
self.config2d = Configuration(0, plane=self.plane2d, offsets={
(-1, -1): 1,
(-1, 0): 1,
(1, -1): 1,
(0, 0): 1
})
self.plane3d = plane.Plane((100, 100, 100))
self.config3d = Configuration(1, plane=self.plane3d, offsets={
(-1, 0, 1): 1,
(-2, 1, 1): 1,
(-1, 0, 0): 0
})
def test_mooreNeighborhoodOffsets(self):
"""
"""
assert len(Configuration.moore(self.plane2d)) == 8
assert len(Configuration.moore(self.plane3d)) == 26
def test_neumannNeighborhoodOffsets(self):
"""
"""
assert len(Configuration.neumann(self.plane2d)) == 4
assert len(Configuration.neumann(self.plane3d)) == 6
def test_matchNeighborhood(self):
"""
"""
assert not self.config2d.matches(self.plane2d, self.neighborhood)
self.plane2d[[(-1, -1), (-1, 0), (1, -1), (0, 0)]] = 1
assert self.config2d.matches(self.plane2d, self.neighborhood)
def test_toleranceNeighborhood(self):
"""
"""
assert not self.config2d.tolerates(self.plane2d, self.neighborhood, 0.5)
self.plane2d[(-1, -1)] = 1
assert not self.config2d.tolerates(self.plane2d, self.neighborhood, 0.5)
self.plane2d[(-1, 0)] = 1
assert self.config2d.tolerates(self.plane2d, self.neighborhood, 0.5)