@@ -111,13 +111,9 @@ class _ProjectQDevice(Device): # pylint: disable=abstract-method
111111 wires (int or Iterable[Number, str]]): Number of subsystems represented by the device,
112112 or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
113113 or strings (``['ancilla', 'q1', 'q2']``). Default 1 if not specified.
114- shots (int): How many times the circuit should be evaluated (or sampled) to estimate
115- the expectation values. Defaults to 1024 if not specified.
116- If ``analytic == True``, then the number of shots is ignored
117- in the calculation of expectation values and variances, and only controls the number
118- of samples returned by ``sample``.
119- analytic (bool): indicates if the device should calculate expectations
120- and variances analytically
114+ shots (None, int): How many times the circuit should be evaluated (or sampled) to estimate
115+ the expectation values. Defaults to ``None`` if not specified, which means that the device
116+ returns analytical results.
121117
122118 Keyword Args:
123119 backend (string): Name of the backend, i.e., either "Simulator",
@@ -165,7 +161,7 @@ def _observable_map(self):
165161 def _backend_kwargs (self ):
166162 raise NotImplementedError
167163
168- def __init__ (self , wires = 1 , shots = 1024 , analytic = True , * , backend , ** kwargs ):
164+ def __init__ (self , wires = 1 , shots = None , * , backend , ** kwargs ):
169165 # overwrite shots with num_runs if given
170166 if "num_runs" in kwargs :
171167 shots = kwargs ["num_runs" ]
@@ -176,7 +172,6 @@ def __init__(self, wires=1, shots=1024, analytic=True, *, backend, **kwargs):
176172 if "verbose" not in kwargs :
177173 kwargs ["verbose" ] = False
178174
179- self .analytic = analytic
180175 self ._backend = backend
181176 self ._kwargs = kwargs
182177 self ._eng = None
@@ -276,13 +271,9 @@ class ProjectQSimulator(_ProjectQDevice):
276271 wires (int or Iterable[Number, str]]): Number of subsystems represented by the device,
277272 or iterable that contains unique labels for the subsystems as numbers (i.e., ``[-1, 0, 2]``)
278273 or strings (``['ancilla', 'q1', 'q2']``).
279- shots (int): How many times the circuit should be evaluated (or sampled) to estimate
280- the expectation values. Defaults to 1000 if not specified.
281- If ``analytic == True``, then the number of shots is ignored
282- in the calculation of expectation values and variances, and only controls the number
283- of samples returned by ``sample``.
284- analytic (bool): indicates if the device should calculate expectations
285- and variances analytically
274+ shots (None, int): How many times the circuit should be evaluated (or sampled) to estimate
275+ the expectation values. Defaults to ``None`` if not specified, which means that the device
276+ returns analytical results.
286277
287278 Keyword Args:
288279 gate_fusion (bool): If True, operations are cached and only executed once a
@@ -337,9 +328,9 @@ class ProjectQSimulator(_ProjectQDevice):
337328 _circuits = {}
338329 _backend_kwargs = ["gate_fusion" , "rnd_seed" ]
339330
340- def __init__ (self , wires = 1 , shots = 1024 , analytic = True , ** kwargs ):
331+ def __init__ (self , wires = 1 , shots = None , ** kwargs ):
341332 kwargs ["backend" ] = "Simulator"
342- super ().__init__ (wires = wires , shots = shots , analytic = analytic , ** kwargs )
333+ super ().__init__ (wires = wires , shots = shots , ** kwargs )
343334
344335 def reset (self ):
345336 """Reset/initialize the device by initializing the backend and engine, and allocating qubits."""
@@ -372,7 +363,7 @@ def expval(self, observable, wires, par):
372363 # pq.ops.QubitOperator("Z"+'0'), [qubit])
373364 # for qubit in self._reg]
374365
375- if not self .analytic and observable != "Identity" :
366+ if not self .shots is None and observable != "Identity" :
376367 p0 = (expval + 1 ) / 2
377368 p0 = max (min (p0 , 1 ), 0 )
378369 n0 = np .random .binomial (self .shots , p0 )
@@ -516,7 +507,7 @@ def __init__(self, wires=1, shots=1024, **kwargs):
516507 ) # pylint: disable=line-too-long
517508
518509 kwargs ["backend" ] = "IBMBackend"
519- super ().__init__ (wires = wires , shots = shots , analytic = False , ** kwargs )
510+ super ().__init__ (wires = wires , shots = shots , ** kwargs )
520511
521512 def reset (self ):
522513 """Reset/initialize the device by initializing the backend and engine, and allocating qubits."""
@@ -658,7 +649,7 @@ class ProjectQClassicalSimulator(_ProjectQDevice):
658649
659650 def __init__ (self , wires = 1 , ** kwargs ):
660651 kwargs ["backend" ] = "ClassicalSimulator"
661- super ().__init__ (wires = wires , shots = 1024 , analytic = True , ** kwargs )
652+ super ().__init__ (wires = wires , shots = None , ** kwargs )
662653
663654 def reset (self ):
664655 """Reset/initialize the device by initializing the backend and engine, and allocating qubits."""
0 commit comments