Exemplo n.º 1
0
 def test_neighborhoodTotal(self):
     """
     Neighborhood Total.
     """
     n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
     n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
     assert len(n1) == len(self.plane2d.bits)
     assert len(n2) == len(self.plane3d.bits)
Exemplo n.º 2
0
 def test_neighborhoodTotal(self):
     """
     Neighborhood Total.
     """
     n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
     n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
     assert len(n1) == len(self.plane2d.bits)
     assert len(n2) == len(self.plane3d.bits)
Exemplo n.º 3
0
 def test_neighborhoodPlaneTotalCount(self):
     """
     Plane Total Count.
     """
     self.plane2d[10] = 1;
     self.plane3d[10] = 1;
     t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
     t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
     assert np.count_nonzero(np.array(t1)) == 200
     assert np.count_nonzero(np.array(t2)) == 20000
Exemplo n.º 4
0
 def test_neighborhoodPlaneTotalInit(self):
     """
     Plane Total Initialization.
     """
     t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
     t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
     assert len(t1) == np.product(self.plane2d.shape)
     assert len(t2) == np.product(self.plane3d.shape)
     assert np.count_nonzero(np.array(t1)) == 0
     assert np.count_nonzero(np.array(t2)) == 0
Exemplo n.º 5
0
 def test_neighboorhoodMembers(self):
     """
     Neighborhood Members.
     """
     n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
     n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
     for n in n1:
         assert len(n.neighbors) == len(self.offsets2d)
     for n in n2:
         assert len(n.neighbors) == len(self.offsets3d)
Exemplo n.º 6
0
 def test_neighborhoodPlaneTotalCount(self):
     """
     Plane Total Count.
     """
     self.plane2d[10] = 1
     self.plane3d[10] = 1
     t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
     t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
     assert np.count_nonzero(np.array(t1)) == 200
     assert np.count_nonzero(np.array(t2)) == 20000
Exemplo n.º 7
0
 def test_neighborhoodPlaneTotalInit(self):
     """
     Plane Total Initialization.
     """
     t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
     t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
     assert len(t1) == np.product(self.plane2d.shape)
     assert len(t2) == np.product(self.plane3d.shape)
     assert np.count_nonzero(np.array(t1)) == 0
     assert np.count_nonzero(np.array(t2)) == 0
Exemplo n.º 8
0
 def test_neighboorhoodMembers(self):
     """
     Neighborhood Members.
     """
     n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
     n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
     for n in n1:
         assert len(n.neighbors) == len(self.offsets2d)
     for n in n2:
         assert len(n.neighbors) == len(self.offsets3d)
Exemplo n.º 9
0
    def setUp(self):

        self.neigh2d = Neighborhood(0)
        self.offsets2d = [(-1, 0), (1, 0)]
        self.plane2d = plane.Plane((100, 100))
        self.neigh2d.populate(self.plane2d, self.offsets2d)

        self.neigh3d = Neighborhood(0)
        self.offsets3d = [(-1, 0, 0), (1, 0, 1)]
        self.plane3d = plane.Plane((100, 100, 100))
        self.neigh3d.populate(self.plane3d, self.offsets3d)
Exemplo n.º 10
0
    def setUp(self):

        self.neigh2d = Neighborhood(0)
        self.offsets2d = [(-1, 0), (1, 0)]
        self.plane2d = plane.Plane((100, 100))
        self.neigh2d.populate(self.plane2d, self.offsets2d)

        self.neigh3d = Neighborhood(0)
        self.offsets3d = [(-1, 0, 0), (1, 0, 1)]
        self.plane3d = plane.Plane((100, 100, 100))
        self.neigh3d.populate(self.plane3d, self.offsets3d)
Exemplo n.º 11
0
    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
                                      })
Exemplo n.º 12
0
class TestNeighborhood:
    """

    """
    def setUp(self):

        self.neigh2d = Neighborhood(0)
        self.offsets2d = [(-1, 0), (1, 0)]
        self.plane2d = plane.Plane((100, 100))
        self.neigh2d.populate(self.plane2d, self.offsets2d)

        self.neigh3d = Neighborhood(0)
        self.offsets3d = [(-1, 0, 0), (1, 0, 1)]
        self.plane3d = plane.Plane((100, 100, 100))
        self.neigh3d.populate(self.plane3d, self.offsets3d)

    def test_neighborhoodLength(self):
        """
        Neighborhood Length.
        """
        assert len(self.neigh2d.neighbors) == len(self.offsets2d)
        assert len(self.neigh3d.neighbors) == len(self.offsets3d)

    def test_neighborhoodValues(self):
        """
        Neighborhood Values.
        """
        self.plane2d[(1, 0)] = 1
        self.plane2d[(99, 0)] = 1
        self.neigh2d.neighbors = [1, 1]

        self.plane3d[(1, 0, 1)] = 1
        self.plane3d[(99, 0, 0)] = 1
        self.neigh3d.neighbors = [1, 1, 1]

    @SkipTest
    def test_neighborhoodTotal(self):
        """
        Neighborhood Total.
        """
        n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
        n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
        assert len(n1) == len(self.plane2d.bits)
        assert len(n2) == len(self.plane3d.bits)

    @SkipTest
    def test_neighboorhoodMembers(self):
        """
        Neighborhood Members.
        """
        n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
        n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
        for n in n1:
            assert len(n.neighbors) == len(self.offsets2d)
        for n in n2:
            assert len(n.neighbors) == len(self.offsets3d)

    def test_neighborhoodPlaneTotalInit(self):
        """
        Plane Total Initialization.
        """
        t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
        t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
        assert len(t1) == np.product(self.plane2d.shape)
        assert len(t2) == np.product(self.plane3d.shape)
        assert np.count_nonzero(np.array(t1)) == 0
        assert np.count_nonzero(np.array(t2)) == 0

    def test_neighborhoodPlaneTotalCount(self):
        """
        Plane Total Count.
        """
        self.plane2d[10] = 1;
        self.plane3d[10] = 1;
        t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
        t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
        assert np.count_nonzero(np.array(t1)) == 200
        assert np.count_nonzero(np.array(t2)) == 20000

    def test_neighborhoodPopulate(self):
        """
        Neighborhood Populate.
        """
        self.plane2d[10] = 1
        self.neigh2d.populate(self.plane2d, self.offsets2d)
        assert self.neigh2d.neighbors.count() == 0
        self.plane2d[1] = 1
        self.neigh2d.populate(self.plane2d, self.offsets2d)
        assert self.neigh2d.neighbors.count() == 1
        self.plane2d[self.offsets2d] = 1
        self.neigh2d.populate(self.plane2d, self.offsets2d)
        assert self.neigh2d.neighbors.count() == 2
Exemplo n.º 13
0
class TestNeighborhood:
    """

    """
    def setUp(self):

        self.neigh2d = Neighborhood(0)
        self.offsets2d = [(-1, 0), (1, 0)]
        self.plane2d = plane.Plane((100, 100))
        self.neigh2d.populate(self.plane2d, self.offsets2d)

        self.neigh3d = Neighborhood(0)
        self.offsets3d = [(-1, 0, 0), (1, 0, 1)]
        self.plane3d = plane.Plane((100, 100, 100))
        self.neigh3d.populate(self.plane3d, self.offsets3d)

    def test_neighborhoodLength(self):
        """
        Neighborhood Length.
        """
        assert len(self.neigh2d.neighbors) == len(self.offsets2d)
        assert len(self.neigh3d.neighbors) == len(self.offsets3d)

    def test_neighborhoodValues(self):
        """
        Neighborhood Values.
        """
        self.plane2d[(1, 0)] = 1
        self.plane2d[(99, 0)] = 1
        self.neigh2d.neighbors = [1, 1]

        self.plane3d[(1, 0, 1)] = 1
        self.plane3d[(99, 0, 0)] = 1
        self.neigh3d.neighbors = [1, 1, 1]

    @SkipTest
    def test_neighborhoodTotal(self):
        """
        Neighborhood Total.
        """
        n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
        n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
        assert len(n1) == len(self.plane2d.bits)
        assert len(n2) == len(self.plane3d.bits)

    @SkipTest
    def test_neighboorhoodMembers(self):
        """
        Neighborhood Members.
        """
        n1 = Neighborhood.get_neighborhoods(self.plane2d, self.offsets2d)
        n2 = Neighborhood.get_neighborhoods(self.plane3d, self.offsets3d)
        for n in n1:
            assert len(n.neighbors) == len(self.offsets2d)
        for n in n2:
            assert len(n.neighbors) == len(self.offsets3d)

    def test_neighborhoodPlaneTotalInit(self):
        """
        Plane Total Initialization.
        """
        t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
        t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
        assert len(t1) == np.product(self.plane2d.shape)
        assert len(t2) == np.product(self.plane3d.shape)
        assert np.count_nonzero(np.array(t1)) == 0
        assert np.count_nonzero(np.array(t2)) == 0

    def test_neighborhoodPlaneTotalCount(self):
        """
        Plane Total Count.
        """
        self.plane2d[10] = 1
        self.plane3d[10] = 1
        t1 = Neighborhood.get_totals(self.plane2d, self.offsets2d)
        t2 = Neighborhood.get_totals(self.plane3d, self.offsets3d)
        assert np.count_nonzero(np.array(t1)) == 200
        assert np.count_nonzero(np.array(t2)) == 20000

    def test_neighborhoodPopulate(self):
        """
        Neighborhood Populate.
        """
        self.plane2d[10] = 1
        self.neigh2d.populate(self.plane2d, self.offsets2d)
        assert self.neigh2d.neighbors.count() == 0
        self.plane2d[1] = 1
        self.neigh2d.populate(self.plane2d, self.offsets2d)
        assert self.neigh2d.neighbors.count() == 1
        self.plane2d[self.offsets2d] = 1
        self.neigh2d.populate(self.plane2d, self.offsets2d)
        assert self.neigh2d.neighbors.count() == 2