3434import cmath as cm
3535from scipy .linalg import block_diag
3636
37- from perceval .components import Circuit , Port , Unitary
37+ from perceval .components import Circuit , Port , Unitary , Processor , Experiment
3838from perceval .components .component_catalog import CatalogItem
3939from perceval .utils import Encoding , PostSelect , Matrix
4040
@@ -93,7 +93,7 @@ class PostProcessedControlledRotationsItem(CatalogItem):
9393 def __init__ (self ):
9494 super ().__init__ ("postprocessed controlled gate" )
9595
96- def build_circuit (self , ** kwargs ):
96+ def build_circuit (self , ** kwargs ) -> Circuit :
9797 """
9898 kwargs:
9999 - n : int, number of qubit of the gate.
@@ -116,17 +116,17 @@ def build_circuit(self, **kwargs):
116116 m = build_control_gate_unitary (n , alpha )
117117 return Circuit (4 * n , name = "postprocessed controlled gate" ).add (0 , Unitary (m ))
118118
119- def build_processor (self , ** kwargs ):
120- p = self ._init_processor (** kwargs )
119+ def build_experiment (self , ** kwargs ) -> Experiment :
120+ e = Experiment ( self .build_circuit (** kwargs ) )
121121 n = kwargs ["n" ]
122122
123- p .set_postselection (PostSelect ('&' .join ([f"[{ 2 * n } ,{ 2 * n + 1 } ]==1" for n in range (n )])))
123+ e .set_postselection (PostSelect ('&' .join ([f"[{ 2 * n } ,{ 2 * n + 1 } ]==1" for n in range (n )])))
124124
125125 for i in range (n - 1 ):
126- p .add_port (2 * i , Port (Encoding .DUAL_RAIL , f"ctrl{ i } " ))
127- p .add_port (2 * (n - 1 ), Port (Encoding .DUAL_RAIL , "data" ))
126+ e .add_port (2 * i , Port (Encoding .DUAL_RAIL , f"ctrl{ i } " ))
127+ e .add_port (2 * (n - 1 ), Port (Encoding .DUAL_RAIL , "data" ))
128128
129129 for i in range (2 * n , 4 * n ):
130- p .add_herald (i , 0 )
130+ e .add_herald (i , 0 )
131131
132- return p
132+ return e
0 commit comments