Source code for pennylane.core.operator.state_prep

# Copyright 2018-2026 Xanadu Quantum Technologies Inc.

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#     http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
This module defines StatePrepBase.
"""

import abc

from pennylane.core.operator.operator2 import StatePrepBase2
from pennylane.typing import TensorLike
from pennylane.wires import WiresLike

from .base import Operation


[docs] class StatePrepBase(Operation): """An interface for state-prep operations.""" grad_method = None
[docs] @abc.abstractmethod def state_vector(self, wire_order: WiresLike | None = None) -> TensorLike: """ Returns the initial state vector for a circuit given a state preparation. Args: wire_order (Iterable): global wire order, must contain all wire labels from the operator's wires Returns: array: A state vector for all wires in a circuit """
[docs] def label( self, decimals: int | None = None, base_label: str | None = None, cache: dict | None = None, ) -> str: return "|Ψ⟩"
@classmethod def __subclasshook__(cls, subclass): if cls is StatePrepBase and issubclass(subclass, StatePrepBase2): return True return NotImplemented
__all__ = ["StatePrepBase"]