@@ -28,9 +28,9 @@ class StateVector:
28
28
>>> state_vector.probabilities
29
29
array([0.25, 0.25, 0.25, 0.25])
30
30
>>> print(state_vector)
31
- State vector: [ 0.5 0.5 0.5 -0.5]
32
- Probabilities: [0.25 0.25 0.25 0.25]
33
- Number of qubits: 2
31
+ State vector: [ 0.5 0.5 0.5 -0.5]
32
+ Probabilities: [0.25 0.25 0.25 0.25]
33
+ Number of qubits: 2
34
34
35
35
"""
36
36
@@ -62,9 +62,10 @@ def amplitudes(self):
62
62
def __str__ (self ):
63
63
cleaned_vector = str (self .vector ).replace ("\n " , " " )
64
64
cleaned_probas = str (self .probabilities ).replace ("\n " , " " )
65
- return f"""State vector: { cleaned_vector }
66
- Probabilities: { cleaned_probas }
67
- Number of qubits: { self .nb_qubits } """
65
+ return f""" State vector: { cleaned_vector }
66
+ Probabilities: { cleaned_probas }
67
+ Number of qubits: { self .nb_qubits }
68
+ """
68
69
69
70
70
71
@typechecked
@@ -172,23 +173,23 @@ class Result:
172
173
173
174
Examples:
174
175
>>> print(Result(Job(), StateVector(np.array([1, 1, 1, -1])/2, 2), 0, 0))
175
- State vector: [ 0.5 0.5 0.5 -0.5]
176
- Probabilities: [0.25 0.25 0.25 0.25]
177
- Number of qubits: 2
176
+ State vector: [ 0.5 0.5 0.5 -0.5]
177
+ Probabilities: [0.25 0.25 0.25 0.25]
178
+ Number of qubits: 2
178
179
179
180
>>> print(Result(Job(), [
180
181
... Sample(2, index=0, count=250)
181
182
... Sample(2, index=3, count=250)
182
183
... ], 0.034, 500))
183
- Counts: [250, 250]
184
- Probabilities: [0.5 0.5]
185
- State: 00, Index: 0, Count: 250, Probability: None
186
- State: 11, Index: 3, Count: 250, Probability: None
187
- Error: 0.034
184
+ Counts: [250, 250]
185
+ Probabilities: [0.5 0.5]
186
+ State: 00, Index: 0, Count: 250, Probability: None
187
+ State: 11, Index: 3, Count: 250, Probability: None
188
+ Error: 0.034
188
189
189
190
>>> print(Result(Job(), -3.09834, 0.021, 2048))
190
- Expectation value: -3.09834
191
- Error: 0.021
191
+ Expectation value: -3.09834
192
+ Error: 0.021
192
193
"""
193
194
194
195
# 3M-TODO: in this class, there is a lot of manual type checking, this is an
@@ -347,21 +348,23 @@ def __str__(self):
347
348
header = f"Result: { type (self .device ).__name__ } , { self .device .name } "
348
349
349
350
if self .job .job_type == JobType .SAMPLE :
350
- samples_str = "\n " .join (map (lambda s : f" { s } " , self .samples ))
351
+ samples_str = "\n " .join (map (lambda s : f" { s } " , self .samples ))
351
352
cleaned_probas = str (self ._probabilities ).replace ("\n " , " " )
352
353
return f"""{ header }
353
- Counts: { self ._counts }
354
- Probabilities: { cleaned_probas }
354
+ Counts: { self ._counts }
355
+ Probabilities: { cleaned_probas }
355
356
{ samples_str }
356
- Error: { self .error } """
357
+ Error: { self .error }
358
+ """
357
359
358
360
if self .job .job_type == JobType .STATE_VECTOR :
359
361
return header + "\n " + str (self .state_vector )
360
362
361
363
if self .job .job_type == JobType .OBSERVABLE :
362
364
return f"""{ header }
363
- Expectation value: { self .expectation_value }
364
- Error/Variance: { self .error } """
365
+ Expectation value: { self .expectation_value }
366
+ Error/Variance: { self .error }
367
+ """
365
368
366
369
raise NotImplementedError (
367
370
f"Job type { self .job .job_type } not implemented for __str__ method"
@@ -402,18 +405,18 @@ class BatchResult:
402
405
>>> print(batch_result)
403
406
BatchResult: 3 results
404
407
Result: ATOSDevice, MYQLM_PYLINALG
405
- State vector: [ 0.5+0.j 0.5+0.j 0.5+0.j -0.5+0.j]
406
- Probabilities: [0.25 0.25 0.25 0.25]
407
- Number of qubits: 2
408
+ State vector: [ 0.5+0.j 0.5+0.j 0.5+0.j -0.5+0.j]
409
+ Probabilities: [0.25 0.25 0.25 0.25]
410
+ Number of qubits: 2
408
411
Result: ATOSDevice, MYQLM_PYLINALG
409
- Counts: [250, 0, 0, 250]
410
- Probabilities: [0.5 0. 0. 0.5]
411
- State: 00, Index: 0, Count: 250, Probability: 0.5
412
- State: 11, Index: 3, Count: 250, Probability: 0.5
413
- Error: 0.034
412
+ Counts: [250, 0, 0, 250]
413
+ Probabilities: [0.5 0. 0. 0.5]
414
+ State: 00, Index: 0, Count: 250, Probability: 0.5
415
+ State: 11, Index: 3, Count: 250, Probability: 0.5
416
+ Error: 0.034
414
417
Result: ATOSDevice, MYQLM_PYLINALG
415
- Expectation value: -3.09834
416
- Error/Variance: 0.021
418
+ Expectation value: -3.09834
419
+ Error/Variance: 0.021
417
420
>>> print(batch_result[0])
418
421
Result: ATOSDevice, MYQLM_PYLINALG
419
422
State vector: [ 0.5+0.j 0.5+0.j 0.5+0.j -0.5+0.j]
0 commit comments