@@ -265,14 +265,17 @@ def _binary_encoder_hopf(
265265 targets .append (k )
266266 targets_and_controls .append ([targets , controls , anticontrols ])
267267
268+ untouched = list (range (nqubits ))
268269 circuit = Circuit (nqubits , ** kwargs )
269270 for targets , controls , anticontrols in targets_and_controls :
271+ anticontrols = [qubit for qubit in anticontrols if qubit not in untouched ]
270272 gate_list = []
271273 if len (anticontrols ) > 0 :
272274 gate_list .append (gates .X (qubit ) for qubit in anticontrols )
273275 gate_list .append (
274276 gates .RY (targets [0 ], 0.0 ).controlled_by (* (controls + anticontrols ))
275277 )
278+ untouched = [qubit for qubit in untouched if qubit != targets [0 ]]
276279 if len (anticontrols ) > 0 :
277280 gate_list .append (gates .X (qubit ) for qubit in anticontrols )
278281 circuit .add (gate_list )
@@ -484,7 +487,7 @@ def _gate_params(
484487def _generate_rbs_angles (
485488 data : ArrayLike ,
486489 architecture : str ,
487- nqubits : Optional [int ] = None ,
490+ dims : Optional [int ] = None ,
488491 backend : Optional [Backend ] = None ,
489492) -> List [float ]:
490493 """Generate list of angles for RBS gates based on ``architecture``.
@@ -510,16 +513,16 @@ def _generate_rbs_angles(
510513 phases .append (backend .arctan2 (data [- 1 ], data [- 2 ]))
511514
512515 if architecture == "tree" :
513- if nqubits is None : # pragma: no cover
516+ if dims is None : # pragma: no cover
514517 raise_error (
515518 TypeError ,
516519 '``nqubits`` must be specified when ``architecture=="tree"``.' ,
517520 )
518521
519- j_max = int (nqubits / 2 )
522+ j_max = int (dims / 2 )
520523
521- r_array = np .zeros (nqubits - 1 , dtype = float )
522- phases = np .zeros (nqubits - 1 , dtype = float )
524+ r_array = np .zeros (dims - 1 , dtype = float )
525+ phases = np .zeros (dims - 1 , dtype = float )
523526 for j in range (1 , j_max + 1 ):
524527 r_array [j_max + j - 2 ] = math .sqrt (
525528 data [2 * j - 1 ] ** 2 + data [2 * j - 2 ] ** 2
0 commit comments