当前位置: 首页>>代码示例>>Python>>正文


Python Configuration.matches方法代码示例

本文整理汇总了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)
开发者ID:jrpotter,项目名称:fifth,代码行数:55,代码来源:configuration_test.py


注:本文中的configuration.Configuration.matches方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。