Skip to content

Exceptions

exceptions

CellNameError

Bases: ValueError

Raised if a KCell is created and the automatic assigned name is taken.

Source code in kfactory/exceptions.py
143
144
class CellNameError(ValueError):
    """Raised if a KCell is created and the automatic assigned name is taken."""

FactoriesLockedError

Bases: RuntimeError

Raised when trying to add a factory to a locked Factories collection.

Source code in kfactory/exceptions.py
37
38
class FactoriesLockedError(RuntimeError):
    """Raised when trying to add a factory to a locked Factories collection."""

InvalidLayerError

Bases: ValueError

Raised when a layer is not valid.

Source code in kfactory/exceptions.py
147
148
class InvalidLayerError(ValueError):
    """Raised when a layer is not valid."""

LockedError

Bases: AttributeError

Raised when a locked cell is being modified.

Source code in kfactory/exceptions.py
24
25
26
27
28
29
30
31
32
33
34
class LockedError(AttributeError):
    """Raised when a locked cell is being modified."""

    def __init__(self, kcell: AnyKCell | BaseKCell) -> None:
        """Throw _locked error."""
        super().__init__(
            f"{kcell.name!r} is locked and likely stored in cache. Modifications are "
            "disabled as its associated function is decorated with `cell`. To modify, "
            "update the code in the function or create a copy of "
            f"the {kcell.__class__.__name__}."
        )

__init__

__init__(kcell: AnyKCell | BaseKCell) -> None

Throw _locked error.

Source code in kfactory/exceptions.py
27
28
29
30
31
32
33
34
def __init__(self, kcell: AnyKCell | BaseKCell) -> None:
    """Throw _locked error."""
    super().__init__(
        f"{kcell.name!r} is locked and likely stored in cache. Modifications are "
        "disabled as its associated function is decorated with `cell`. To modify, "
        "update the code in the function or create a copy of "
        f"the {kcell.__class__.__name__}."
    )

MergeError

Bases: ValueError

Raised if two layout's have conflicting cell definitions.

Source code in kfactory/exceptions.py
41
42
class MergeError(ValueError):
    """Raised if two layout's have conflicting cell definitions."""

PortLayerMismatchError

Bases: ValueError

Error thrown when two ports don't have a matching layer.

Source code in kfactory/exceptions.py
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
class PortLayerMismatchError(ValueError):
    """Error thrown when two ports don't have a matching `layer`."""

    def __init__(
        self,
        kcl: KCLayout,
        inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
        other_inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any] | ProtoPort[Any],
        p1: ProtoPort[Any],
        p2: ProtoPort[Any],
        *args: Any,
    ) -> None:
        """Throw error for the two ports `p1`/`p1`."""
        from .instance import ProtoInstance
        from .layer import LayerEnum

        l1 = (
            f"{p1.layer.name}({p1.layer.__int__()})"
            if isinstance(p1.layer, LayerEnum)
            else str(kcl.layout.get_info(p1.layer))
        )
        l2 = (
            f"{p2.layer.name}({p2.layer.__int__()})"
            if isinstance(p2.layer, LayerEnum)
            else str(kcl.layout.get_info(p2.layer))
        )
        if isinstance(other_inst, ProtoInstance):
            super().__init__(
                f'Layer mismatch between the ports {inst.name}["{p1.name}"]'
                f' and {other_inst.name}["{p2.name}"] ("{l1}"/"{l2}")',
                *args,
            )
        else:
            super().__init__(
                f'Layer mismatch between the ports {inst.name}["{p1.name}"]'
                f' and Port "{p2.name}" ("{l1}"/"{l2}")',
                *args,
            )

__init__

__init__(
    kcl: KCLayout,
    inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
    other_inst: ProtoInstance[Any]
    | ProtoInstanceGroup[Any, Any]
    | ProtoPort[Any],
    p1: ProtoPort[Any],
    p2: ProtoPort[Any],
    *args: Any,
) -> None

Throw error for the two ports p1/p1.

Source code in kfactory/exceptions.py
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
def __init__(
    self,
    kcl: KCLayout,
    inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
    other_inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any] | ProtoPort[Any],
    p1: ProtoPort[Any],
    p2: ProtoPort[Any],
    *args: Any,
) -> None:
    """Throw error for the two ports `p1`/`p1`."""
    from .instance import ProtoInstance
    from .layer import LayerEnum

    l1 = (
        f"{p1.layer.name}({p1.layer.__int__()})"
        if isinstance(p1.layer, LayerEnum)
        else str(kcl.layout.get_info(p1.layer))
    )
    l2 = (
        f"{p2.layer.name}({p2.layer.__int__()})"
        if isinstance(p2.layer, LayerEnum)
        else str(kcl.layout.get_info(p2.layer))
    )
    if isinstance(other_inst, ProtoInstance):
        super().__init__(
            f'Layer mismatch between the ports {inst.name}["{p1.name}"]'
            f' and {other_inst.name}["{p2.name}"] ("{l1}"/"{l2}")',
            *args,
        )
    else:
        super().__init__(
            f'Layer mismatch between the ports {inst.name}["{p1.name}"]'
            f' and Port "{p2.name}" ("{l1}"/"{l2}")',
            *args,
        )

PortTypeMismatchError

Bases: ValueError

Error thrown when two ports don't have a matching port_type.

Source code in kfactory/exceptions.py
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
class PortTypeMismatchError(ValueError):
    """Error thrown when two ports don't have a matching `port_type`."""

    def __init__(
        self,
        inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
        other_inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any] | ProtoPort[Any],
        p1: ProtoPort[Any],
        p2: ProtoPort[Any],
        *args: Any,
    ) -> None:
        """Throw error for the two ports `p1`/`p1`."""
        from .instance import ProtoInstance

        if isinstance(other_inst, ProtoInstance):
            super().__init__(
                f'Type mismatch between the ports {inst.name}["{p1.name}"]'
                f' and {other_inst.name}["{p2.name}"]'
                f" ({p1.port_type}/{p2.port_type})",
                *args,
            )
        else:
            super().__init__(
                f'Type mismatch between the ports {inst.name}["{p1.name}"]'
                f' and Port "{p2.name}" ({p1.port_type}/{p2.port_type})',
                *args,
            )

__init__

__init__(
    inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
    other_inst: ProtoInstance[Any]
    | ProtoInstanceGroup[Any, Any]
    | ProtoPort[Any],
    p1: ProtoPort[Any],
    p2: ProtoPort[Any],
    *args: Any,
) -> None

Throw error for the two ports p1/p1.

Source code in kfactory/exceptions.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def __init__(
    self,
    inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
    other_inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any] | ProtoPort[Any],
    p1: ProtoPort[Any],
    p2: ProtoPort[Any],
    *args: Any,
) -> None:
    """Throw error for the two ports `p1`/`p1`."""
    from .instance import ProtoInstance

    if isinstance(other_inst, ProtoInstance):
        super().__init__(
            f'Type mismatch between the ports {inst.name}["{p1.name}"]'
            f' and {other_inst.name}["{p2.name}"]'
            f" ({p1.port_type}/{p2.port_type})",
            *args,
        )
    else:
        super().__init__(
            f'Type mismatch between the ports {inst.name}["{p1.name}"]'
            f' and Port "{p2.name}" ({p1.port_type}/{p2.port_type})',
            *args,
        )

PortWidthMismatchError

Bases: ValueError

Error thrown when two ports don't have a matching width.

Source code in kfactory/exceptions.py
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
class PortWidthMismatchError(ValueError):
    """Error thrown when two ports don't have a matching `width`."""

    def __init__(
        self,
        inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
        other_inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any] | ProtoPort[Any],
        p1: ProtoPort[Any],
        p2: ProtoPort[Any],
        *args: Any,
    ) -> None:
        """Throw error for the two ports `p1`/`p1`."""
        from .instance import ProtoInstance

        if isinstance(other_inst, ProtoInstance):
            super().__init__(
                f'Width mismatch between the ports {inst.name}["{p1.name}"] '
                f'and {other_inst.name}["{p2.name}"]'
                f'("{p1.width}"/"{p2.width}")',
                *args,
            )
        else:
            super().__init__(
                f'Width mismatch between the ports {inst.name}["{p1.name}"] '
                f'and Port "{p2.name}" ("{p1.width}"/"{p2.width}")',
                *args,
            )

__init__

__init__(
    inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
    other_inst: ProtoInstance[Any]
    | ProtoInstanceGroup[Any, Any]
    | ProtoPort[Any],
    p1: ProtoPort[Any],
    p2: ProtoPort[Any],
    *args: Any,
) -> None

Throw error for the two ports p1/p1.

Source code in kfactory/exceptions.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
def __init__(
    self,
    inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any],
    other_inst: ProtoInstance[Any] | ProtoInstanceGroup[Any, Any] | ProtoPort[Any],
    p1: ProtoPort[Any],
    p2: ProtoPort[Any],
    *args: Any,
) -> None:
    """Throw error for the two ports `p1`/`p1`."""
    from .instance import ProtoInstance

    if isinstance(other_inst, ProtoInstance):
        super().__init__(
            f'Width mismatch between the ports {inst.name}["{p1.name}"] '
            f'and {other_inst.name}["{p2.name}"]'
            f'("{p1.width}"/"{p2.width}")',
            *args,
        )
    else:
        super().__init__(
            f'Width mismatch between the ports {inst.name}["{p1.name}"] '
            f'and Port "{p2.name}" ("{p1.width}"/"{p2.width}")',
            *args,
        )