Skip to content

Neighorboods

CircularNeighborhoodBuilder

Bases: DistanceNeighborhoodBuilder

A semantic class for generating Circular neighborhoods in any structure.

Source code in pylattica/structures/square_grid/neighborhoods.py
69
70
class CircularNeighborhoodBuilder(DistanceNeighborhoodBuilder):
    """A semantic class for generating Circular neighborhoods in any structure."""

MooreNbHoodBuilder

Bases: MotifNeighborhoodBuilder

A helper class for generating Moore type neighborhoods in square structures.

Source code in pylattica/structures/square_grid/neighborhoods.py
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class MooreNbHoodBuilder(MotifNeighborhoodBuilder):
    """A helper class for generating Moore type neighborhoods in square structures."""

    def __init__(self, size=1, dim=2):
        """Constructs the MooreNbHoodBuilder

        Parameters
        ----------
        size : int, optional
            The size of the neighborhood, by default 1
        dim : int, optional
            The dimension of the structures to which this builder will apply, by default 2
        """
        points = get_points_in_cube(-size, size + 1, dim)
        super().__init__(points)

__init__(size=1, dim=2)

Constructs the MooreNbHoodBuilder

Parameters
int, optional

The size of the neighborhood, by default 1

int, optional

The dimension of the structures to which this builder will apply, by default 2

Source code in pylattica/structures/square_grid/neighborhoods.py
55
56
57
58
59
60
61
62
63
64
65
66
def __init__(self, size=1, dim=2):
    """Constructs the MooreNbHoodBuilder

    Parameters
    ----------
    size : int, optional
        The size of the neighborhood, by default 1
    dim : int, optional
        The dimension of the structures to which this builder will apply, by default 2
    """
    points = get_points_in_cube(-size, size + 1, dim)
    super().__init__(points)

PseudoHexagonalNeighborhoodBuilder3D

Bases: StochasticNeighborhoodBuilder

A helper class for generating Pseudohexagonal neighborhoods in 3D.

Source code in pylattica/structures/square_grid/neighborhoods.py
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
class PseudoHexagonalNeighborhoodBuilder3D(StochasticNeighborhoodBuilder):
    """A helper class for generating Pseudohexagonal neighborhoods in 3D."""

    def __init__(self):
        common_neighbors = [
            (1, 0, 0),
            (-1, 0, 0),
            (0, 1, 0),
            (0, -1, 0),
            (0, 0, 1),
            (0, 0, -1),
        ]
        motifs = [
            [
                *common_neighbors,
                (-1, -1, 1),
                (1, 1, -1),
            ],
            [
                *common_neighbors,
                (-1, 1, 1),
                (1, -1, -1),
            ],
            [
                *common_neighbors,
                (1, 1, 1),
                (-1, -1, -1),
            ],
            [
                *common_neighbors,
                (1, -1, 1),
                (-1, 1, -1),
            ],
        ]
        super().__init__([MotifNeighborhoodBuilder(m) for m in motifs])

PseudoPentagonalNeighborhoodBuilder

Bases: StochasticNeighborhoodBuilder

A helper class for generating Pseudopentagonal neighborhoods in 2D.

Source code in pylattica/structures/square_grid/neighborhoods.py
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
class PseudoPentagonalNeighborhoodBuilder(StochasticNeighborhoodBuilder):
    """A helper class for generating Pseudopentagonal neighborhoods in 2D."""

    def __init__(self):
        motifs = [
            [
                (-1, 0),
                (1, 0),
                (-1, -1),
                (0, -1),
                (1, -1),
            ],
            [
                (-1, 1),
                (0, 1),
                (1, 1),
                (-1, 0),
                (1, 0),
            ],
            [
                (0, 1),
                (1, 1),
                (1, 0),
                (0, -1),
                (1, -1),
            ],
            [
                (-1, 1),
                (0, 1),
                (-1, 0),
                (-1, -1),
                (0, -1),
            ],
        ]
        self.builders = [MotifNeighborhoodBuilder(m) for m in motifs]

VonNeumannNbHood2DBuilder

Bases: MotifNeighborhoodBuilder

A helper class for generating von Neumann type neighborhoods in square 2D structures.

Source code in pylattica/structures/square_grid/neighborhoods.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
class VonNeumannNbHood2DBuilder(MotifNeighborhoodBuilder):
    """A helper class for generating von Neumann type neighborhoods in square 2D structures."""

    def __init__(self, size=1):
        """Constructs the VonNeumannNbHood2DBuilder.

        Parameters
        ----------
        size : int, optional
            The size of the neighborhood, the traditional von Neumann neighborhood would have a size of 1
        """
        points = get_points_in_cube(-size, size + 1, 2)

        filtered_points = []
        for point in points:
            if sum(np.abs(p) for p in point) <= size:
                filtered_points.append(point)

        super().__init__(filtered_points)

__init__(size=1)

Constructs the VonNeumannNbHood2DBuilder.

Parameters
int, optional

The size of the neighborhood, the traditional von Neumann neighborhood would have a size of 1

Source code in pylattica/structures/square_grid/neighborhoods.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def __init__(self, size=1):
    """Constructs the VonNeumannNbHood2DBuilder.

    Parameters
    ----------
    size : int, optional
        The size of the neighborhood, the traditional von Neumann neighborhood would have a size of 1
    """
    points = get_points_in_cube(-size, size + 1, 2)

    filtered_points = []
    for point in points:
        if sum(np.abs(p) for p in point) <= size:
            filtered_points.append(point)

    super().__init__(filtered_points)

VonNeumannNbHood3DBuilder

Bases: MotifNeighborhoodBuilder

A helper class for generating von Neumann type neighborhoods in square 3D structures.

Source code in pylattica/structures/square_grid/neighborhoods.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class VonNeumannNbHood3DBuilder(MotifNeighborhoodBuilder):
    """A helper class for generating von Neumann type neighborhoods in square 3D structures."""

    def __init__(self, size: int):
        """Constructs the VonNeumannNbHood3D Builder

        Parameters
        ----------
        size : int
            The size of the neighborhood.
        """
        points = get_points_in_cube(-size, size + 1, 3)

        filtered_points = []
        for point in points:
            if sum(np.abs(p) for p in point) <= size:
                filtered_points.append(point)

        super().__init__(filtered_points)

__init__(size)

Constructs the VonNeumannNbHood3D Builder

Parameters
int

The size of the neighborhood.

Source code in pylattica/structures/square_grid/neighborhoods.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
def __init__(self, size: int):
    """Constructs the VonNeumannNbHood3D Builder

    Parameters
    ----------
    size : int
        The size of the neighborhood.
    """
    points = get_points_in_cube(-size, size + 1, 3)

    filtered_points = []
    for point in points:
        if sum(np.abs(p) for p in point) <= size:
            filtered_points.append(point)

    super().__init__(filtered_points)