Skip to content

Library

Source code in gdsr/_gdsr.pyi
class Library:
    name: str
    @property
    def cells(self) -> Mapping[str, Cell]:
        """Return the cells in the library."""
    def __init__(self, name: str = "library") -> None:
        """Initialize the Library with a name.

        :param str name: Library name
        """
    def add(self, *cells: Cell, replace_pre_existing: bool = False) -> None:
        """Add cells to the library.

        The cells that are added are not copied and are added by reference.
        This means that modifying the cells after adding them to the library will
        also modify the cells in the library.

        If replace_pre_existing is True, this will also look at cells in references and
        add those to the library as well.

        :param Cell cells: Cells to add to the library.
        :param bool replace_pre_existing: Replace pre-existing cells with the same name,
        defaults to False. If this is False and a cell with the same name already exists
        in the library, a ValueError will be raised.

        ```python

        import gdsr

        lib = gdsr.Library()

        cell = gdsr.Cell("cell")

        lib.add(cell)

        cell_from_lib = lib.cells["cell"]

        cell_from_lib.add(gdsr.Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]))

        assert cell is cell_from_lib
        ```
        """
    def remove(self, *cells: Cell) -> None:
        """Remove cells from the library."""
    def contains(self, cell: Cell) -> bool:
        """Return True if the library contains the cell."""
    def copy(self, deep: bool = False) -> Self:
        """Return a copy of the library.

        :param bool deep: If True, a deep copy is returned, defaults to False.
        """
    def to_gds(
        self,
        file_name: PathLike | None = None,
        units: float = 1e-6,
        precision: float = 1e-10,
    ) -> str:
        """Write the Library to a GDS file.

        :param PathLike file_name: Output GDS file name.
        :param float units: GDS file units in meters, defaults to 1e-6.
        :param float precision: GDS file precision, defaults to 1e-10.
        :return: GDS file path
        """
    @staticmethod
    def from_gds(file_name: PathLike) -> Library:
        """Read a Library from a GDS file.

        :param PathLike file_name: Input GDS file name.
        :return: Library
        """
    def __add__(self, other: Cell) -> Self:
        """Add a cell to the library.

        This simple calls the add method with the cell as an argument,
        and replace_pre_existing as True.

        :param Cell other: Cell to add to the library.

        This can be used in the following way:
        ```python
        import gdsr

        library = gdsr.Library()

        cell = gdsr.Cell("cell")

        library = library + cell
        # or
        library += cell
        # or
        library + cell
        ```
        """
    def __contains__(self, cell: Cell) -> bool:
        """Return True if the library contains the cell."""
    def __eq__(self, value: object) -> bool:
        """Return True if the library is equal to another object."""
    def __str__(self) -> str:
        """Return a string representation of the library."""
    def __repr__(self) -> str:
        """Return a string representation of the library."""

name instance-attribute

name: str

cells property

cells: Mapping[str, Cell]

Return the cells in the library.

__init__

__init__(name: str = 'library') -> None

Initialize the Library with a name.

Parameters:

  • name (str, default: 'library' ) –

    Library name

Source code in gdsr/_gdsr.pyi
def __init__(self, name: str = "library") -> None:
    """Initialize the Library with a name.

    :param str name: Library name
    """

add

add(*cells: Cell, replace_pre_existing: bool = False) -> None

Add cells to the library.

The cells that are added are not copied and are added by reference. This means that modifying the cells after adding them to the library will also modify the cells in the library.

If replace_pre_existing is True, this will also look at cells in references and add those to the library as well.

Parameters:

  • cells (Cell, default: () ) –

    Cells to add to the library.

  • replace_pre_existing (bool, default: False ) –

    Replace pre-existing cells with the same name, defaults to False. If this is False and a cell with the same name already exists in the library, a ValueError will be raised. python import gdsr lib = gdsr.Library() cell = gdsr.Cell("cell") lib.add(cell) cell_from_lib = lib.cells["cell"] cell_from_lib.add(gdsr.Polygon([(0, 0), (1, 0), (1, 1), (0, 1)])) assert cell is cell_from_lib

Source code in gdsr/_gdsr.pyi
def add(self, *cells: Cell, replace_pre_existing: bool = False) -> None:
    """Add cells to the library.

    The cells that are added are not copied and are added by reference.
    This means that modifying the cells after adding them to the library will
    also modify the cells in the library.

    If replace_pre_existing is True, this will also look at cells in references and
    add those to the library as well.

    :param Cell cells: Cells to add to the library.
    :param bool replace_pre_existing: Replace pre-existing cells with the same name,
    defaults to False. If this is False and a cell with the same name already exists
    in the library, a ValueError will be raised.

    ```python

    import gdsr

    lib = gdsr.Library()

    cell = gdsr.Cell("cell")

    lib.add(cell)

    cell_from_lib = lib.cells["cell"]

    cell_from_lib.add(gdsr.Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]))

    assert cell is cell_from_lib
    ```
    """

remove

remove(*cells: Cell) -> None

Remove cells from the library.

Source code in gdsr/_gdsr.pyi
def remove(self, *cells: Cell) -> None:
    """Remove cells from the library."""

contains

contains(cell: Cell) -> bool

Return True if the library contains the cell.

Source code in gdsr/_gdsr.pyi
def contains(self, cell: Cell) -> bool:
    """Return True if the library contains the cell."""

copy

copy(deep: bool = False) -> Self

Return a copy of the library.

Parameters:

  • deep (bool, default: False ) –

    If True, a deep copy is returned, defaults to False.

Source code in gdsr/_gdsr.pyi
def copy(self, deep: bool = False) -> Self:
    """Return a copy of the library.

    :param bool deep: If True, a deep copy is returned, defaults to False.
    """

to_gds

to_gds(file_name: PathLike | None = None, units: float = 1e-06, precision: float = 1e-10) -> str

Write the Library to a GDS file.

Parameters:

  • file_name (PathLike, default: None ) –

    Output GDS file name.

  • units (float, default: 1e-06 ) –

    GDS file units in meters, defaults to 1e-6.

  • precision (float, default: 1e-10 ) –

    GDS file precision, defaults to 1e-10.

Returns:

  • str

    GDS file path

Source code in gdsr/_gdsr.pyi
def to_gds(
    self,
    file_name: PathLike | None = None,
    units: float = 1e-6,
    precision: float = 1e-10,
) -> str:
    """Write the Library to a GDS file.

    :param PathLike file_name: Output GDS file name.
    :param float units: GDS file units in meters, defaults to 1e-6.
    :param float precision: GDS file precision, defaults to 1e-10.
    :return: GDS file path
    """

from_gds staticmethod

from_gds(file_name: PathLike) -> Library

Read a Library from a GDS file.

Parameters:

  • file_name (PathLike) –

    Input GDS file name.

Returns:

Source code in gdsr/_gdsr.pyi
@staticmethod
def from_gds(file_name: PathLike) -> Library:
    """Read a Library from a GDS file.

    :param PathLike file_name: Input GDS file name.
    :return: Library
    """

__add__

__add__(other: Cell) -> Self

Add a cell to the library.

This simple calls the add method with the cell as an argument, and replace_pre_existing as True.

Parameters:

  • other (Cell) –

    Cell to add to the library. This can be used in the following way: python import gdsr library = gdsr.Library() cell = gdsr.Cell("cell") library = library + cell # or library += cell # or library + cell

Source code in gdsr/_gdsr.pyi
def __add__(self, other: Cell) -> Self:
    """Add a cell to the library.

    This simple calls the add method with the cell as an argument,
    and replace_pre_existing as True.

    :param Cell other: Cell to add to the library.

    This can be used in the following way:
    ```python
    import gdsr

    library = gdsr.Library()

    cell = gdsr.Cell("cell")

    library = library + cell
    # or
    library += cell
    # or
    library + cell
    ```
    """

__contains__

__contains__(cell: Cell) -> bool

Return True if the library contains the cell.

Source code in gdsr/_gdsr.pyi
def __contains__(self, cell: Cell) -> bool:
    """Return True if the library contains the cell."""

__eq__

__eq__(value: object) -> bool

Return True if the library is equal to another object.

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

__str__

__str__() -> str

Return a string representation of the library.

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

__repr__

__repr__() -> str

Return a string representation of the library.

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