Skip to content

Commit

Permalink
Fix lint in controlled circuit and Instruction.definition change (qis…
Browse files Browse the repository at this point in the history
…kit-community#1100)

* Fix lint in controlled circuit

* Fixed change to Instruction.definition
  • Loading branch information
manoelmarques committed Jul 28, 2020
1 parent 7dc2482 commit b8ffd7e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .pylintdict
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ subscriptable
subspaces
succ
sudo
SummedOps
summands
summedops
superclass
superfast
suzuki
Expand Down
5 changes: 3 additions & 2 deletions qiskit/aqua/operators/primitive_ops/circuit_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,9 @@ def reduce(self) -> OperatorBase:
# Check if Identity or empty instruction (need to check that type is exactly
# Instruction because some gates have lazy gate.definition population)
# pylint: disable=unidiomatic-typecheck
if isinstance(gate, IGate) or (type(gate) == Instruction and gate.definition == []):
del self.primitive.data[i]
if isinstance(gate, IGate) or (type(gate) == Instruction and
gate.definition.data == []):
del self.primitive.data[i] # type: ignore
return self

def permute(self, permutation: List[int]) -> 'CircuitOp':
Expand Down
3 changes: 2 additions & 1 deletion qiskit/aqua/operators/state_fns/circuit_state_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ def reduce(self) -> OperatorBase:
# Check if Identity or empty instruction (need to check that type is exactly
# Instruction because some gates have lazy gate.definition population)
# pylint: disable=unidiomatic-typecheck
if isinstance(gate, IGate) or (type(gate) == Instruction and gate.definition == []):
if isinstance(gate, IGate) or (type(gate) == Instruction and
gate.definition.data == []):
del self.primitive.data[i]
return self

Expand Down
2 changes: 1 addition & 1 deletion qiskit/aqua/utils/controlled_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def get_controlled_circuit(circuit, ctl_qubit, tgt_circuit=None, use_basis_gates
elif op[0].name == 'u3':
apply_cu3(qc, *op[0].params, ctl_qubit, op[1][0], use_basis_gates=use_basis_gates)
elif op[0].name == 'cx':
apply_ccx(qc, ctl_qubit, *op[1], use_basis_gates=use_basis_gates)
apply_ccx(qc, ctl_qubit, op[1][0], op[1][1], use_basis_gates=use_basis_gates)
elif op[0].name == 'measure':
qc.measure(op[1], op[2])
elif op[0].name == 'barrier':
Expand Down

0 comments on commit b8ffd7e

Please sign in to comment.