Skip to content

Geometric Shapes

siapy.entities.shapes.geometric_shapes

GeometricShapes dataclass

GeometricShapes(
    image: SpectralImage[Any],
    geometric_shapes: list[Shape] | None = None,
)
Source code in siapy/entities/shapes/geometric_shapes.py
20
21
22
23
24
25
26
27
def __init__(
    self,
    image: "SpectralImage[Any]",
    geometric_shapes: list["Shape"] | None = None,
):
    self._image = image
    self._geometric_shapes = geometric_shapes if geometric_shapes is not None else []
    _check_shape_type(self._geometric_shapes, is_list=True)

shapes property writable

shapes: list[Shape]

append

append(shape: Shape) -> None
Source code in siapy/entities/shapes/geometric_shapes.py
64
65
66
def append(self, shape: "Shape") -> None:
    _check_shape_type(shape, is_list=False)
    self._geometric_shapes.append(shape)

extend

extend(shapes: Iterable[Shape]) -> None
Source code in siapy/entities/shapes/geometric_shapes.py
68
69
70
def extend(self, shapes: Iterable["Shape"]) -> None:
    _check_shape_type(shapes, is_list=True)
    self._geometric_shapes.extend(shapes)

insert

insert(index: int, shape: Shape) -> None
Source code in siapy/entities/shapes/geometric_shapes.py
72
73
74
def insert(self, index: int, shape: "Shape") -> None:
    _check_shape_type(shape, is_list=False)
    self._geometric_shapes.insert(index, shape)

remove

remove(shape: Shape) -> None
Source code in siapy/entities/shapes/geometric_shapes.py
76
77
78
def remove(self, shape: "Shape") -> None:
    _check_shape_type(shape, is_list=False)
    self._geometric_shapes.remove(shape)

pop

pop(index: int = -1) -> Shape
Source code in siapy/entities/shapes/geometric_shapes.py
80
81
def pop(self, index: int = -1) -> "Shape":
    return self._geometric_shapes.pop(index)

clear

clear() -> None
Source code in siapy/entities/shapes/geometric_shapes.py
83
84
def clear(self) -> None:
    self._geometric_shapes.clear()

index

index(
    shape: Shape, start: int = 0, stop: int = maxsize
) -> int
Source code in siapy/entities/shapes/geometric_shapes.py
86
87
88
def index(self, shape: "Shape", start: int = 0, stop: int = sys.maxsize) -> int:
    _check_shape_type(shape, is_list=False)
    return self._geometric_shapes.index(shape, start, stop)

count

count(shape: Shape) -> int
Source code in siapy/entities/shapes/geometric_shapes.py
90
91
92
def count(self, shape: "Shape") -> int:
    _check_shape_type(shape, is_list=False)
    return self._geometric_shapes.count(shape)

reverse

reverse() -> None
Source code in siapy/entities/shapes/geometric_shapes.py
94
95
def reverse(self) -> None:
    self._geometric_shapes.reverse()

sort

sort(key: Any = None, reverse: bool = False) -> None
Source code in siapy/entities/shapes/geometric_shapes.py
97
98
def sort(self, key: Any = None, reverse: bool = False) -> None:
    self._geometric_shapes.sort(key=key, reverse=reverse)

get_by_name

get_by_name(name: str) -> Optional[Shape]
Source code in siapy/entities/shapes/geometric_shapes.py
100
101
102
103
104
105
def get_by_name(self, name: str) -> Optional["Shape"]:
    names = [shape.label for shape in self.shapes]
    if name in names:
        index = names.index(name)
        return self.shapes[index]
    return None