Skip to content

Commit

Permalink
fix: remove union from singledispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
AthenaCaesura committed Mar 29, 2024
1 parent 5c16b06 commit e189f2e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 12 additions & 3 deletions src/benchq/conversions/_operator_translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
# Numpy throws deprecation warnings due to the scipy import
from openfermion import QubitOperator, IsingOperator, InteractionOperator

import openfermion
from orquestra.integrations.cirq.conversions._openfermion_conversions import (
to_openfermion,
)
Expand All @@ -27,12 +26,22 @@ def get_pyliqtr_operator(hamiltonian):


@get_pyliqtr_operator.register
def _(hamiltonian: Union[PauliTerm, PauliSum]) -> Hamiltonian:
def _(hamiltonian: PauliSum) -> Hamiltonian:
return openfermion_to_pyliqtr(to_openfermion(hamiltonian))


@get_pyliqtr_operator.register
def _(hamiltonian: Union[QubitOperator, IsingOperator]) -> Hamiltonian:
def _(hamiltonian: PauliTerm) -> Hamiltonian:
return openfermion_to_pyliqtr(to_openfermion(hamiltonian))


@get_pyliqtr_operator.register
def _(hamiltonian: QubitOperator) -> Hamiltonian:
return openfermion_to_pyliqtr(hamiltonian)


@get_pyliqtr_operator.register
def _(hamiltonian: IsingOperator) -> Hamiltonian:
return openfermion_to_pyliqtr(hamiltonian)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
get_implementation_compiler,
get_ruby_slippers_circuit_compiler,
)
from benchq.compilation.graph_states.compiled_data_structures import GSCInfo
from benchq.decoder_modeling import DecoderModel
from benchq.problem_embeddings.quantum_program import QuantumProgram
from benchq.quantum_hardware_modeling import (
Expand Down

0 comments on commit e189f2e

Please sign in to comment.