44from collections import defaultdict
55from enum import Enum
66from functools import partial
7- from typing import Generator , List , Tuple , Callable , Dict
7+ from typing import Generator , List , Tuple , Callable , Dict , Union
88
99import netqasm .lang .instr .core as core_instructions
1010import netqasm .lang .instr .vanilla as vanilla_instructions
@@ -35,7 +35,11 @@ class UnknownQubitError(RuntimeError):
3535 """
3636 pass
3737
38- _VanillaRotInstr = vanilla_instructions .RotXInstruction | vanilla_instructions .RotYInstruction | vanilla_instructions .RotZInstruction
38+
39+ _VanillaRotInstr = Union [vanilla_instructions .RotXInstruction ,
40+ vanilla_instructions .RotYInstruction ,
41+ vanilla_instructions .RotZInstruction ]
42+
3943
4044# TODO - This class is candidate to be deleted! Test and delete if not needed!
4145class NetworkStack (BaseNetworkStack ):
@@ -62,6 +66,7 @@ def setup_epr_socket(self, epr_socket_id, remote_node_id, remote_epr_socket_id,
6266 def get_purpose_id (self , remote_node_id : int , epr_socket_id : int ) -> int :
6367 pass
6468
69+
6570class VanillaSimulaQronExecutioner (Executor ):
6671 SIMULAQRON_OPS = {
6772 vanilla_instructions .GateXInstruction : "apply_X" ,
@@ -213,7 +218,13 @@ def _do_single_qubit_instr(self, instr, subroutine_id, address):
213218 qubit_id = position ,
214219 )
215220
216- def _do_single_qubit_rotation (self , instr : core_instructions .RotationInstruction , subroutine_id : int , address : int , angle : float ):
221+ def _do_single_qubit_rotation (
222+ self ,
223+ instr : core_instructions .RotationInstruction ,
224+ subroutine_id : int ,
225+ address : int ,
226+ angle : float
227+ ):
217228 assert isinstance (instr , _VanillaRotInstr )
218229 position = self ._get_position (subroutine_id = subroutine_id , address = address )
219230 axis = self ._get_axis (instr = instr )
@@ -356,7 +367,7 @@ def cmd_measure(self, qubit_id: int, inplace=True):
356367 return outcome
357368
358369 @inlineCallbacks
359- def cmd_reset (self , qubit_id : int , correct : bool = True ):
370+ def cmd_reset (self , qubit_id : int , correct : bool = True ):
360371 r"""
361372 Reset the given qubit to the state :math:`|0>`.
362373
@@ -373,7 +384,7 @@ def cmd_reset(self, qubit_id: int, correct: bool=True):
373384 if correct and outcome :
374385 yield call_method (virt_qubit , "apply_X" )
375386
376- def _do_wait (self , delay : float = 0.1 ):
387+ def _do_wait (self , delay : float = 0.1 ):
377388 d = task .deferLater (reactor , delay , lambda : self ._logger .debug ("Wait finished" ))
378389 self ._logger .debug ("waiting a bit" )
379390 yield d
0 commit comments