qiskit-advocate / qamp-spring-23

Qiskit advocate mentorship program (QAMP) Spring 23 cohort (April - July 2023)
12 stars 2 forks source link

Improve type hint in quantum_info #24

Open ikkoham opened 1 year ago

ikkoham commented 1 year ago

Description

There are currently many codes in Qiskit that do not have type hints. Types are important in the quality of the code. The goal of this project is to improve type hinting with the goal of improving documentation.

Deliverables

Pull request to Qiskit-terra

Mentors details

Number of mentees

1

Type of mentees

derwind commented 1 year ago

I am interested in this assignment. I added a class - AerDensityMatrix - to the Qiskit Aer quantum_info at the previous QAMP. In conversations with my mentor, the issue was raised that the documentation area was not up to date or maintained. Partly for that reason, I have had trouble several times what types were allowed or not allowed as arguments for the added class. Because I will continue to utilize the quantum_info, I have a desire to improve the documentation for quantum_info in Terra and Aer to the extent possible.

BramDo commented 1 year ago

I am interested in the assignment

derwind commented 1 year ago

Checkpoint 1

The presentation slide is: Improve-type-hint-in-quantum_info.pdf

derwind commented 1 year ago

Checkpoint 2

Review of Checkpoint 1

Review briefly what we have accomplished up to checkpoint 1.

Tasks and progress

Remaining tasks and progress to this point are listed below. Checked areas are those that are complete or nearly complete:

typehint_example

Current impression

At the start I knew about type hints at a simple level, but not the ones I had never used such as TypeVar, Generic, Protocol, etc. I am glad that I was able to gradually learn these through weekly discussions with my mentor. I could not master them just by looking at them, so I learned how to use them practically by actually trying to use them in my main business. When I gave type hints, I found some difficult cases: Sometimes circular references occurred, and sometimes I found it difficult to cover everything with type hints due to overly generic implementations, such as too many possible types for a given argument. We have discussed these cases, and decided whether to take care of them with type hints or to slightly modify the code as well. I am confident that we can continue to move forward with this manner.

derwind commented 1 year ago

Final Showcase

I attached the slide used in the Final Showcase and the Jupyter notebook used in the showing-type-hints demo.

Improve-type-hint-in-quantum_info.pdf check_type_hints.ipynb.zip

Now all milestones declared in Checkpoint 2 have been achieved. Our only remaining task is to keep an eye on that the PR created this time is successfully merged. Please look forward to Qiskit Terra 0.25.0, which will incorporate our achievement!