qarp.factories¶
Block factories. Public depth: flat. Submodules are private.
- class qarp.factories.PauliBlockFactory[source]¶
Bases:
BlockFactoryA factory class for creating PauliBlock objects from various Hamiltonian representations.
This factory supports creation from QubitOperator and FermionOperator objects, with configurable options for coefficients, basis changes, and measurements.
- create_blocks(hamiltonian: QubitOperator | FermionOperator, n_qubits: int | None = None, include_coefficients: bool = True, change_basis: bool = False, measure: bool = False, mapping: Mapping | None = None) List[PauliBlock][source]¶
Create blocks from a Hamiltonian operator.
Automatically dispatches to the appropriate method based on input type.
- Parameters:
hamiltonian – OpenFermion QubitOperator or FermionOperator representing the Hamiltonian
n_qubits – Total number of qubits/spin orbitals. If None, inferred from the operator
include_coefficients – Whether to include the coefficients in the blocks
change_basis – Whether to change basis for the Pauli blocks
measure – Whether to measure the Pauli blocks
mapping – Fermion-to-qubit mapping (only used for FermionOperator)
- Returns:
List of PauliBlock objects
- Raises:
TypeError – If hamiltonian is not a QubitOperator or FermionOperator
- static from_fermion_operator(operator: FermionOperator, spin_orbitals: int | None = None, mapping: Mapping | None = None, include_coefficients: bool = True, change_basis: bool = False, measure: bool = False) List[PauliBlock][source]¶
Create PauliBlock objects from a FermionOperator.
Requires a fermion-to-qubit mapping (e.g., Jordan-Wigner transform).
- Parameters:
operator – OpenFermion FermionOperator
spin_orbitals – Number of spin orbitals. If None, inferred from the operator
mapping – Fermion-to-qubit mapping. Defaults to Jordan-Wigner if None
include_coefficients – Whether to include the coefficients in the blocks
change_basis – Whether to change basis for the Pauli blocks
measure – Whether to measure the Pauli blocks
- Returns:
List of PauliBlock objects
- static from_qubit_operator(operator: QubitOperator, n_qubits: int | None = None, include_coefficients: bool = True, change_basis: bool = False, measure: bool = False) List[PauliBlock][source]¶
Create PauliBlock objects from a QubitOperator.
- Parameters:
operator – OpenFermion QubitOperator representing the Hamiltonian
n_qubits – Total number of qubits. If None, inferred from the operator
include_coefficients – Whether to include the coefficients in the blocks
change_basis – Whether to change basis for the Pauli blocks
measure – Whether to measure the Pauli blocks
- Returns:
List of PauliBlock objects, one for each term in the Hamiltonian