Skip to content

base

base

Module contains base class for creating Gilbert algorithm backends (concrete implementations) and exceptions which are expected to be raised from backends.

BackendBase

Gilbert algorithm backend (implementation).

Source code in cssfinder/algorithm/backend/base.py
class BackendBase:
    """Gilbert algorithm backend (implementation)."""

    author: ClassVar[str] = ""
    description: ClassVar[str] = ""

    def __init__(
        self,
        initial: npt.NDArray[np.complex128],
        depth: int,
        quantity: int,
        mode: AlgoMode,
        visibility: float,
        *,
        is_debug: bool = False,
    ) -> None:
        self.depth = depth
        self.quantity = quantity
        self.initial = initial
        self.visibility = visibility
        self.mode = mode
        self.is_debug = is_debug

    def set_symmetries(
        self,
        symmetries: list[list[npt.NDArray[np.complex128]]],
    ) -> None:
        """Set symmetries to use during calculations.

        This operation may involve type conversion and copying of symmetries, therefore
        if may be slow and should should be done only once.

        Parameters
        ----------
        symmetries : list[list[npt.NDArray[np.complex128]]]
            Array of symmetries.

        """
        raise NotImplementedError(self.set_symmetries.__qualname__)

    def set_projection(self, projection: npt.NDArray[np.complex128]) -> None:
        """Set projection to use during calculations.

        This operation may involve type conversion and copying of symmetries, therefore
        if may be slow and should should be done only once.

        Parameters
        ----------
        projection : npt.NDArray[np.complex128]
            Projection matrix.

        """
        raise NotImplementedError(self.set_projection.__qualname__)

    def get_state(self) -> npt.NDArray[np.complex128]:
        """Return current system state with all optimizations applied."""
        raise NotImplementedError(self.get_state.__qualname__)

    def get_corrections(self) -> list[tuple[int, int, float]]:
        """Return list of all corrections found during optimization."""
        raise NotImplementedError(self.get_corrections.__qualname__)

    def get_corrections_count(self) -> int:
        """Return number of all corrections found during optimization."""
        raise NotImplementedError(self.get_corrections_count.__qualname__)

    def run_epoch(self, iterations: int, epoch_index: int) -> None:
        """Run sequence of iterations without stopping to check any stop conditions."""
        raise NotImplementedError(self.run_epoch.__qualname__)

set_symmetries

set_symmetries(
    symmetries: list[list[npt.NDArray[np.complex128]]],
) -> None

Set symmetries to use during calculations.

This operation may involve type conversion and copying of symmetries, therefore if may be slow and should should be done only once.

Parameters:

Name Type Description Default
symmetries list[list[NDArray[complex128]]]

Array of symmetries.

required
Source code in cssfinder/algorithm/backend/base.py
def set_symmetries(
    self,
    symmetries: list[list[npt.NDArray[np.complex128]]],
) -> None:
    """Set symmetries to use during calculations.

    This operation may involve type conversion and copying of symmetries, therefore
    if may be slow and should should be done only once.

    Parameters
    ----------
    symmetries : list[list[npt.NDArray[np.complex128]]]
        Array of symmetries.

    """
    raise NotImplementedError(self.set_symmetries.__qualname__)

set_projection

set_projection(
    projection: npt.NDArray[np.complex128],
) -> None

Set projection to use during calculations.

This operation may involve type conversion and copying of symmetries, therefore if may be slow and should should be done only once.

Parameters:

Name Type Description Default
projection NDArray[complex128]

Projection matrix.

required
Source code in cssfinder/algorithm/backend/base.py
def set_projection(self, projection: npt.NDArray[np.complex128]) -> None:
    """Set projection to use during calculations.

    This operation may involve type conversion and copying of symmetries, therefore
    if may be slow and should should be done only once.

    Parameters
    ----------
    projection : npt.NDArray[np.complex128]
        Projection matrix.

    """
    raise NotImplementedError(self.set_projection.__qualname__)

get_state

get_state() -> npt.NDArray[np.complex128]

Return current system state with all optimizations applied.

Source code in cssfinder/algorithm/backend/base.py
def get_state(self) -> npt.NDArray[np.complex128]:
    """Return current system state with all optimizations applied."""
    raise NotImplementedError(self.get_state.__qualname__)

get_corrections

get_corrections() -> list[tuple[int, int, float]]

Return list of all corrections found during optimization.

Source code in cssfinder/algorithm/backend/base.py
def get_corrections(self) -> list[tuple[int, int, float]]:
    """Return list of all corrections found during optimization."""
    raise NotImplementedError(self.get_corrections.__qualname__)

get_corrections_count

get_corrections_count() -> int

Return number of all corrections found during optimization.

Source code in cssfinder/algorithm/backend/base.py
def get_corrections_count(self) -> int:
    """Return number of all corrections found during optimization."""
    raise NotImplementedError(self.get_corrections_count.__qualname__)

run_epoch

run_epoch(iterations: int, epoch_index: int) -> None

Run sequence of iterations without stopping to check any stop conditions.

Source code in cssfinder/algorithm/backend/base.py
def run_epoch(self, iterations: int, epoch_index: int) -> None:
    """Run sequence of iterations without stopping to check any stop conditions."""
    raise NotImplementedError(self.run_epoch.__qualname__)