Skip to content

Protocols

protocols

BoxFunction

Bases: Protocol

Protocol for a box function.

Represents bbox/ibbox/dbbox functions.

Source code in kfactory/protocols.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@runtime_checkable
class BoxFunction[T: (int, float)](Protocol):
    """Protocol for a box function.

    Represents bbox/ibbox/dbbox functions.
    """

    @overload
    def __call__(self) -> BoxLike[T]: ...
    @overload
    def __call__(self, layer: LayerEnum | int) -> BoxLike[T]: ...

    def __call__(self, layer: LayerEnum | int | None = None) -> BoxLike[T]:
        """Call the box function."""
        ...

__call__

__call__() -> BoxLike[T]
__call__(layer: LayerEnum | int) -> BoxLike[T]
__call__(
    layer: LayerEnum | int | None = None,
) -> BoxLike[T]

Call the box function.

Source code in kfactory/protocols.py
65
66
67
def __call__(self, layer: LayerEnum | int | None = None) -> BoxLike[T]:
    """Call the box function."""
    ...

BoxLike

Bases: Protocol

Protocol for a box.

Mirrors some functionality of kdb.DBox, kdb.Box, but provides generic types for the units.

Source code in kfactory/protocols.py
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@runtime_checkable
class BoxLike[T: (int, float)](Protocol):
    """Protocol for a box.

    Mirrors some functionality of kdb.DBox, kdb.Box,
    but provides generic types for the units.
    """

    left: T
    bottom: T
    right: T
    top: T

    def center(self) -> PointLike[T]:
        """Get the center of the box."""
        ...

    def width(self) -> T:
        """Get the width of the box."""
        ...

    def height(self) -> T:
        """Get the height of the box."""
        ...

    def empty(self) -> bool:
        """Check if the box is empty."""
        ...

center

center() -> PointLike[T]

Get the center of the box.

Source code in kfactory/protocols.py
36
37
38
def center(self) -> PointLike[T]:
    """Get the center of the box."""
    ...

empty

empty() -> bool

Check if the box is empty.

Source code in kfactory/protocols.py
48
49
50
def empty(self) -> bool:
    """Check if the box is empty."""
    ...

height

height() -> T

Get the height of the box.

Source code in kfactory/protocols.py
44
45
46
def height(self) -> T:
    """Get the height of the box."""
    ...

width

width() -> T

Get the width of the box.

Source code in kfactory/protocols.py
40
41
42
def width(self) -> T:
    """Get the width of the box."""
    ...

PointLike

Bases: Protocol

Protocol for a point.

Mirrors some functionality of kdb.DPoint, kdb.Point, but provides generic types for the units.

Source code in kfactory/protocols.py
11
12
13
14
15
16
17
18
19
20
@runtime_checkable
class PointLike[T: (int, float)](Protocol):
    """Protocol for a point.

    Mirrors some functionality of  kdb.DPoint, kdb.Point,
    but provides generic types for the units.
    """

    x: T
    y: T