Skip to content
This repository was archived by the owner on Aug 21, 2023. It is now read-only.

Update simulator tutorials not to use deprecated APIs #1400

Merged
merged 2 commits into from
Mar 2, 2023

Conversation

itoko
Copy link
Contributor

@itoko itoko commented Feb 15, 2023

  • Update 1_aer_provider.ipynb.ipynb to avoid deprecation warning.
  • Update 5_noise_transformation.ipynb not to use the deprecated arguments in approximate_quantum_error function.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@@ -117,7 +117,7 @@
"outputs": [
Copy link
Contributor

@HuangJunye HuangJunye Mar 1, 2023

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

Copy link
Contributor Author

@itoko itoko Mar 1, 2023

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",
Copy link
Contributor

@HuangJunye HuangJunye Mar 1, 2023

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

Copy link
Contributor Author

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")

Copy link
Contributor

@HuangJunye HuangJunye left a 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?

@itoko
Copy link
Contributor Author

itoko commented Mar 1, 2023

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)

@HuangJunye
Copy link
Contributor

@itoko thanks for providing the context; they are really helpful for understanding the change.

@HuangJunye HuangJunye merged commit b6c34c5 into Qiskit:master Mar 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants