From 3865956e3ee2ab758c75acbf519785523285794d Mon Sep 17 00:00:00 2001 From: Toru Kawakubo Date: Wed, 22 Jun 2022 15:32:23 +0900 Subject: [PATCH] Improve runtime type checking in symmetry_conserving_bravyi_kitaev --- .../transforms/opconversions/remove_symmetry_qubits.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/openfermion/transforms/opconversions/remove_symmetry_qubits.py b/src/openfermion/transforms/opconversions/remove_symmetry_qubits.py index 09ae27a6f..e914e758f 100644 --- a/src/openfermion/transforms/opconversions/remove_symmetry_qubits.py +++ b/src/openfermion/transforms/opconversions/remove_symmetry_qubits.py @@ -61,12 +61,12 @@ def symmetry_conserving_bravyi_kitaev(fermion_hamiltonian, active_orbitals, with an arbitrary number of fermions. """ # Catch errors if inputs are of wrong type. - if type(fermion_hamiltonian) is not FermionOperator: + if not isinstance(fermion_hamiltonian, FermionOperator): raise ValueError( "Supplied operator should be an instance of FermionOperator class") - if type(active_orbitals) is not int: + if not isinstance(active_orbitals, int): raise ValueError("Number of active orbitals should be an integer.") - if type(active_fermions) is not int: + if not isinstance(active_fermions, int): raise ValueError("Number of active fermions should be an integer.") # Arrange spins up then down, then BK map to qubit Hamiltonian.