Skip to content

Reference

T_Instance

Type variable for an instance.

Reference

Reference object. Do not subscript this class, use inferred generic types.

Source code in gdsr/_gdsr.pyi
class Reference(Generic[T_Instance]):
    """Reference object. Do not subscript this class, use inferred generic types."""

    instance: T_Instance
    """The instance to reference."""
    grid: Grid
    """The grid to reference the cell."""
    def __init__(self, instance: T_Instance, grid: Grid = Grid()) -> None:
        """Initialize the Reference with an instance and a grid.

        :param Instance instance: The instance to reference.
        :param Grid grid: The grid to reference the cell.
        """
    @property
    def bounding_box(self) -> tuple[Point, Point]:
        """Return the bounding box of the reference."""
    def copy(self) -> Self:
        """Return a copy of the reference."""
    def move_to(self, point: PointLike) -> Self:
        """Move the reference to a point.

        This method modifies the reference in place and returns itself.

        :param PointLike point: Point to move the reference to.
        """
    def move_by(self, vector: PointLike) -> Self:
        """Move the reference by a vector.

        This method modifies the reference in place and returns itself.

        :param PointLike vector: Vector to move the reference by.
        """
    def rotate(self, angle: float, centre: PointLike = Point(0, 0)) -> Self:
        """Rotate the reference by an angle around a centre point.

        This method modifies the reference in place and returns itself.

        :param float angle: Counter-clockwise rotation angle in degrees.
        :param PointLike centre: Centre point of rotation, defaults to (0, 0).
        """
    def scale(self, factor: float, centre: PointLike = Point(0, 0)) -> Self:
        """Scale the reference by a factor around a centre point.

        This method modifies the reference in place and returns itself.

        :param float factor: Scaling factor.
        :param PointLike centre: Centre point of scaling, defaults to (0, 0).
        """
    def flatten(
        self, *layer_data_types: LayerDataType, depth: int | None = None
    ) -> list[Element]:
        """Return a list of the elements in the reference.

        When depth is None, the reference is flattened to the deepest level.

        :param LayerDataType layer_data_types: the layer, data_type pairs to flatten on
        :param int depth: Depth of the flattening, defaults to None.
        """
    def is_on(self, *layer_data_types: LayerDataType) -> bool:
        """Return True if the instance is on any of the layer, data_type pairs."""
    def __str__(self) -> str:
        """Return a string representation of the reference."""
    def __repr__(self) -> str:
        """Return a string representation of the reference."""
    def __eq__(self, value: object) -> bool:
        """Return True if the reference is equal to another object."""

instance instance-attribute

instance: T_Instance

The instance to reference.

grid instance-attribute

grid: Grid

The grid to reference the cell.

bounding_box property

bounding_box: tuple[Point, Point]

Return the bounding box of the reference.

__init__

__init__(instance: T_Instance, grid: Grid = Grid()) -> None

Initialize the Reference with an instance and a grid.

Parameters:

  • instance (Instance) –

    The instance to reference.

  • grid (Grid, default: Grid() ) –

    The grid to reference the cell.

Source code in gdsr/_gdsr.pyi
def __init__(self, instance: T_Instance, grid: Grid = Grid()) -> None:
    """Initialize the Reference with an instance and a grid.

    :param Instance instance: The instance to reference.
    :param Grid grid: The grid to reference the cell.
    """

copy

copy() -> Self

Return a copy of the reference.

Source code in gdsr/_gdsr.pyi
def copy(self) -> Self:
    """Return a copy of the reference."""

move_to

move_to(point: PointLike) -> Self

Move the reference to a point.

This method modifies the reference in place and returns itself.

Parameters:

  • point (PointLike) –

    Point to move the reference to.

Source code in gdsr/_gdsr.pyi
def move_to(self, point: PointLike) -> Self:
    """Move the reference to a point.

    This method modifies the reference in place and returns itself.

    :param PointLike point: Point to move the reference to.
    """

move_by

move_by(vector: PointLike) -> Self

Move the reference by a vector.

This method modifies the reference in place and returns itself.

Parameters:

  • vector (PointLike) –

    Vector to move the reference by.

Source code in gdsr/_gdsr.pyi
def move_by(self, vector: PointLike) -> Self:
    """Move the reference by a vector.

    This method modifies the reference in place and returns itself.

    :param PointLike vector: Vector to move the reference by.
    """

rotate

rotate(angle: float, centre: PointLike = Point(0, 0)) -> Self

Rotate the reference by an angle around a centre point.

This method modifies the reference in place and returns itself.

Parameters:

  • angle (float) –

    Counter-clockwise rotation angle in degrees.

  • centre (PointLike, default: Point(0, 0) ) –

    Centre point of rotation, defaults to (0, 0).

Source code in gdsr/_gdsr.pyi
def rotate(self, angle: float, centre: PointLike = Point(0, 0)) -> Self:
    """Rotate the reference by an angle around a centre point.

    This method modifies the reference in place and returns itself.

    :param float angle: Counter-clockwise rotation angle in degrees.
    :param PointLike centre: Centre point of rotation, defaults to (0, 0).
    """

scale

scale(factor: float, centre: PointLike = Point(0, 0)) -> Self

Scale the reference by a factor around a centre point.

This method modifies the reference in place and returns itself.

Parameters:

  • factor (float) –

    Scaling factor.

  • centre (PointLike, default: Point(0, 0) ) –

    Centre point of scaling, defaults to (0, 0).

Source code in gdsr/_gdsr.pyi
def scale(self, factor: float, centre: PointLike = Point(0, 0)) -> Self:
    """Scale the reference by a factor around a centre point.

    This method modifies the reference in place and returns itself.

    :param float factor: Scaling factor.
    :param PointLike centre: Centre point of scaling, defaults to (0, 0).
    """

flatten

flatten(*layer_data_types: LayerDataType, depth: int | None = None) -> list[Element]

Return a list of the elements in the reference.

When depth is None, the reference is flattened to the deepest level.

Parameters:

  • layer_data_types (LayerDataType, default: () ) –

    the layer, data_type pairs to flatten on

  • depth (int, default: None ) –

    Depth of the flattening, defaults to None.

Source code in gdsr/_gdsr.pyi
def flatten(
    self, *layer_data_types: LayerDataType, depth: int | None = None
) -> list[Element]:
    """Return a list of the elements in the reference.

    When depth is None, the reference is flattened to the deepest level.

    :param LayerDataType layer_data_types: the layer, data_type pairs to flatten on
    :param int depth: Depth of the flattening, defaults to None.
    """

is_on

is_on(*layer_data_types: LayerDataType) -> bool

Return True if the instance is on any of the layer, data_type pairs.

Source code in gdsr/_gdsr.pyi
def is_on(self, *layer_data_types: LayerDataType) -> bool:
    """Return True if the instance is on any of the layer, data_type pairs."""

__str__

__str__() -> str

Return a string representation of the reference.

Source code in gdsr/_gdsr.pyi
def __str__(self) -> str:
    """Return a string representation of the reference."""

__repr__

__repr__() -> str

Return a string representation of the reference.

Source code in gdsr/_gdsr.pyi
def __repr__(self) -> str:
    """Return a string representation of the reference."""

__eq__

__eq__(value: object) -> bool

Return True if the reference is equal to another object.

Source code in gdsr/_gdsr.pyi
def __eq__(self, value: object) -> bool:
    """Return True if the reference is equal to another object."""