Skip to content

Cells

Bases: _LinkNodeCell, _BaseObj

A patch cell of a RasterLayer. Subclassing this class to create a custom cell. When class attribute max_agents is assigned, the agents property will be limited to the number of agents.

Attributes:

Name Type Description
agents _CellAgentsContainer

The agents located at here.

layer PatchModule

The RasterLayer where this PatchCell belongs.

Source code in abses/cells.py
def __init__(self, layer, indices: Pos):
    _BaseObj.__init__(self, model=layer.model, observer=True)
    _LinkNodeCell.__init__(self)
    self.indices = indices
    self._set_layer(layer=layer)

layer property

layer

RasterLayer where this PatchCell belongs.

agents property

agents

The agents located at here.

coordinate property

coordinate

The position of this cell.

geo_type property

geo_type

Return the geo_type

crs property

crs

Return the crs of this cell.

get

get(attr, target=None)

Gets the value of an attribute or registered property. Automatically update the value if it is the dynamic variable of the layer.

Parameters:

Name Type Description Default
attr str

The name of attribute to get.

required

Returns:

Name Type Description
Any Any

The value of the attribute.

Raises:

Type Description
AttributeError

Attribute value of the associated patch cell.

Source code in abses/cells.py
def get(self, attr: str, target: Optional[TargetName] = None) -> Any:
    """Gets the value of an attribute or registered property.
    Automatically update the value if it is the dynamic variable of the layer.

    Parameters:
        attr:
            The name of attribute to get.

    Returns:
        Any:
            The value of the attribute.

    Raises:
        AttributeError:
            Attribute value of the associated patch cell.
    """
    if attr in self.layer.dynamic_variables:
        self.layer.dynamic_var(attr_name=attr)
    return super().get(attr=attr, target=target)

neighboring

neighboring(moore=False, radius=1, include_center=False, annular=False)

Get the grid around the patch.

Source code in abses/cells.py
def neighboring(
    self,
    moore: bool = False,
    radius: int = 1,
    include_center: bool = False,
    annular: bool = False,
) -> ActorsList[_LinkNodeCell]:
    """Get the grid around the patch."""
    return self.layer.get_neighborhood(
        self.indices,
        moore=moore,
        radius=radius,
        include_center=include_center,
        annular=annular,
    )