@@ -172,49 +172,43 @@ def is_available(self, cmd): # pylint: disable=too-many-return-statements,too-m
172172 if get_control_count (cmd ) == 1 :
173173 return isinstance (gate , (R , ZGate , XGate , SwapGate ))
174174 if get_control_count (cmd ) == 0 :
175- return (
176- isinstance (
177- gate ,
178- (
179- R ,
180- Rx ,
181- Ry ,
182- Rz ,
183- XGate ,
184- YGate ,
185- ZGate ,
186- HGate ,
187- SGate ,
188- TGate ,
189- SwapGate ,
190- ),
191- )
192- or gate in (Sdag , Tdag )
193- )
175+ return isinstance (
176+ gate ,
177+ (
178+ R ,
179+ Rx ,
180+ Ry ,
181+ Rz ,
182+ XGate ,
183+ YGate ,
184+ ZGate ,
185+ HGate ,
186+ SGate ,
187+ TGate ,
188+ SwapGate ,
189+ ),
190+ ) or gate in (Sdag , Tdag )
194191
195192 if self .device == 'IonQ Device' :
196193 if get_control_count (cmd ) == 1 :
197194 return isinstance (gate , XGate )
198195 if get_control_count (cmd ) == 0 :
199- return (
200- isinstance (
201- gate ,
202- (
203- Rx ,
204- Ry ,
205- Rz ,
206- XGate ,
207- YGate ,
208- ZGate ,
209- HGate ,
210- SGate ,
211- TGate ,
212- SqrtXGate ,
213- SwapGate ,
214- ),
215- )
216- or gate in (Sdag , Tdag )
217- )
196+ return isinstance (
197+ gate ,
198+ (
199+ Rx ,
200+ Ry ,
201+ Rz ,
202+ XGate ,
203+ YGate ,
204+ ZGate ,
205+ HGate ,
206+ SGate ,
207+ TGate ,
208+ SqrtXGate ,
209+ SwapGate ,
210+ ),
211+ ) or gate in (Sdag , Tdag )
218212
219213 if self .device == 'SV1' :
220214 if get_control_count (cmd ) == 2 :
@@ -224,26 +218,23 @@ def is_available(self, cmd): # pylint: disable=too-many-return-statements,too-m
224218 if get_control_count (cmd ) == 0 :
225219 # TODO: add MatrixGate to cover the unitary operation
226220 # TODO: Missing XY gate in ProjectQ
227- return (
228- isinstance (
229- gate ,
230- (
231- R ,
232- Rx ,
233- Ry ,
234- Rz ,
235- XGate ,
236- YGate ,
237- ZGate ,
238- HGate ,
239- SGate ,
240- TGate ,
241- SqrtXGate ,
242- SwapGate ,
243- ),
244- )
245- or gate in (Sdag , Tdag )
246- )
221+ return isinstance (
222+ gate ,
223+ (
224+ R ,
225+ Rx ,
226+ Ry ,
227+ Rz ,
228+ XGate ,
229+ YGate ,
230+ ZGate ,
231+ HGate ,
232+ SGate ,
233+ TGate ,
234+ SqrtXGate ,
235+ SwapGate ,
236+ ),
237+ ) or gate in (Sdag , Tdag )
247238 return False
248239
249240 def _reset (self ):
@@ -372,13 +363,12 @@ def get_probabilities(self, qureg):
372363 raise RuntimeError ("Please, run the circuit first!" )
373364
374365 probability_dict = {}
375- for state in self ._probabilities :
366+ for state , probability in self ._probabilities . items () :
376367 mapped_state = ['0' ] * len (qureg )
377368 for i , qubit in enumerate (qureg ):
378369 if self ._logical_to_physical (qubit .id ) >= len (state ): # pragma: no cover
379370 raise IndexError ('Physical ID {} > length of internal probabilities array' .format (qubit .id ))
380371 mapped_state [i ] = state [self ._logical_to_physical (qubit .id )]
381- probability = self ._probabilities [state ]
382372 mapped_state = "" .join (mapped_state )
383373 if mapped_state not in probability_dict :
384374 probability_dict [mapped_state ] = probability
0 commit comments