-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Update simulator tutorials not to use deprecated APIs #1400
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@@ -117,7 +117,7 @@ | |||
"outputs": [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line #14. print("Circuit unitary:\n", np.asarray(unitary).round(5))
What is the reason for this change? It seems to me that the outcome is the same.
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is because Aer's save_unitary
changed its return type from numpy.array to quantum_info.Operator. Without this change, this line will raise DeprecationWarning like
DeprecationWarning: The return type of saved unitaries has been changed from a `numpy.ndarray` to a `qiskit.quantum_info.Operator` as of qiskit-aer 0.10. Accessing numpy array attributes is deprecated and will result in an error in a future release. To continue using saved result objects as arrays you can explicitly cast them using `np.asarray(object)`.
print("Circuit unitary:\n", unitary.round(5))
@@ -57,7 +57,9 @@ | |||
"import numpy as np\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line #4. results = approximate_quantum_error(Kraus([K0, K1]), operator_string="reset")
I am not familiar with this function in Aer. Can you provide a bit of context for this change?
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is because approximate_quantum_error
changed the acceptable type of the first argument to be QuantumError
or QuantumChannel
. Without this change, this line will raise
DeprecationWarning: Support of types other than QuantumError or QuantumChannel for error to be approximated has been deprecated as of qiskit-aer 0.10.0 and will be removed no earlier than 3 months from that release date.
results = approximate_quantum_error([K0, K1], operator_string="reset")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look reasonable however I don't have the full context on why the changes are necessary. Can you please provide some context in the PR descriptions and link to related PRs so that people (me and others, and in the future) can understand better?
Thanks, @HuangJunye. Excuse me for not providing a context of this PR. All changes in this PR are updates for avoiding the use of deprecated APIs in Aer so that these tutorials continue to work after removing the deprecated functions. (Actually, some deprecated functions are about to remove in Aer: Qiskit/qiskit-aer#1624) |
@itoko thanks for providing the context; they are really helpful for understanding the change. |
1_aer_provider.ipynb.ipynb
to avoid deprecation warning.5_noise_transformation.ipynb
not to use the deprecated arguments inapproximate_quantum_error
function.