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

Improves An introduction to algorithms #1445

Merged
merged 11 commits into from
Jul 26, 2023
Merged

Conversation

divshacker
Copy link
Contributor

@divshacker divshacker commented Apr 27, 2023

Summary

This PR will improve the tutorial 01_algorithms_introduction

Details and comments

fixes #1402
Part of #1401

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@divshacker divshacker marked this pull request as draft April 27, 2023 09:18
@divshacker
Copy link
Contributor Author

I have added few necessary links and changed images to SVG.

"\n",
"Algorithms are configurable and often part of the configuration will be in the form of smaller building blocks, of which different instances of the building block type can be given. For instance with `VQE`, the Variational Quantum Eigensolver, it takes a trial wavefunction, in the form of a `QuantumCircuit` and a classical optimizer among other things.\n",
"Algorithms are configurable and often part of the configuration will be in the form of smaller building blocks, of which different instances of the building block type can be given. For instance with [`VQE`](https://qiskit.org/documentation/stubs/qiskit.algorithms.VQE.html#qiskit.algorithms.VQE), the Variational Quantum Eigensolver, it takes a trial wavefunction, in the form of a [`QuantumCircuit`](https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.html#quantumcircuit) and a classical optimizer among other things.\n",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the old, now deprecated VQE that used QuantumInstance. This is the new Estimator based VQE https://qiskit.org/documentation/stubs/qiskit.algorithms.minimum_eigensolvers.VQE.html#qiskit.algorithms.minimum_eigensolvers.VQE

frankharkins
frankharkins previously approved these changes Apr 28, 2023
Copy link
Member

@frankharkins frankharkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking over this, looks good to me

@divshacker divshacker marked this pull request as ready for review April 28, 2023 09:08
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.

Thanks a lot for adding the cross-reference. Can you remove the backticks '`' around the methods when links are added? This is a known bug with nbsphinx and sphinx that the resulting html will render like the following when backticks and a link are added, even though your local jupyter notebook (and ReviewNB) render correctly.

image

As a tip, check the output by building the doc locally or check the artifact generated by the CI tests in the PR (see the images below to download artifact).

image

image

image

image

After downloading the artifcat, unzip and open index.html and find the pages that you made changes to check the changes render as expected.

@@ -15,11 +15,11 @@
"source": [
"## How is the algorithm library structured?\n",
"\n",
"Qiskit provides a number of [Algorithms](https://qiskit.org/documentation/apidoc/algorithms.html) and they are grouped by category according to the task they can perform. For instance `Minimum Eigensolvers` to find the smallest eigen value of an operator, for example ground state energy of a chemistry Hamiltonian or a solution to an optimization problem when expressed as an Ising Hamiltonian. There are `Time Evolvers` for the time evolution of quantum systems and `Amplitude Estimators` for value estimation that can be used say in financial applications. The full set of categories can be seen in the Algorithms documentation link above.\n",
"Qiskit provides a number of [Algorithms](https://qiskit.org/documentation/apidoc/algorithms.html) and they are grouped by category according to the task they can perform. For instance [`Minimum Eigensolvers`](https://qiskit.org/documentation/stubs/qiskit.algorithms.minimum_eigensolvers.html#module-qiskit.algorithms.minimum_eigensolvers) to find the smallest eigen value of an operator, for example ground state energy of a chemistry Hamiltonian or a solution to an optimization problem when expressed as an Ising Hamiltonian. There are [`Time Evolvers`](https://qiskit.org/documentation/apidoc/algorithms.html#time-evolvers) for the time evolution of quantum systems and [`Amplitude Estimators`](https://qiskit.org/documentation/apidoc/algorithms.html#amplitude-estimators) for value estimation that can be used say in financial applications. The full set of categories can be seen in the Algorithms documentation link above.\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Qiskit provides a number of [Algorithms](https://qiskit.org/documentation/apidoc/algorithms.html) and they are grouped by category according to the task they can perform. For instance [`Minimum Eigensolvers`](https://qiskit.org/documentation/stubs/qiskit.algorithms.minimum_eigensolvers.html#module-qiskit.algorithms.minimum_eigensolvers) to find the smallest eigen value of an operator, for example ground state energy of a chemistry Hamiltonian or a solution to an optimization problem when expressed as an Ising Hamiltonian. There are [`Time Evolvers`](https://qiskit.org/documentation/apidoc/algorithms.html#time-evolvers) for the time evolution of quantum systems and [`Amplitude Estimators`](https://qiskit.org/documentation/apidoc/algorithms.html#amplitude-estimators) for value estimation that can be used say in financial applications. The full set of categories can be seen in the Algorithms documentation link above.\n",
"Qiskit provides a number of [Algorithms](https://qiskit.org/documentation/apidoc/algorithms.html) and they are grouped by category according to the task they can perform. For instance [`Minimum Eigensolvers`](https://qiskit.org/documentation/stubs/qiskit.algorithms.minimum_eigensolvers.html#module-qiskit.algorithms.minimum_eigensolvers) to find the smallest eigen value of an operator, for example ground state energy of a chemistry Hamiltonian or a solution to an optimization problem when expressed as an Ising Hamiltonian. There are [Time Evolvers](https://qiskit.org/documentation/apidoc/algorithms.html#time-evolvers) for the time evolution of quantum systems and [Amplitude Estimators](https://qiskit.org/documentation/apidoc/algorithms.html#amplitude-estimators) for value estimation that can be used say in financial applications. The full set of categories can be seen in the Algorithms documentation link above.\n",

Can you remove the backticks '`' around the methods when links are added? See the main PR review comment for the reason.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I thought if it had rendered correctly on Github then it would be fine but as you said there's a bug that is creating a problem then I would remove them.
Also, thanks for suggesting about artifact generated by the CI tests as I was not aware about that bug so I didn't check that but will fix this now.

@divshacker divshacker requested a review from HuangJunye April 28, 2023 11:02
@divshacker
Copy link
Contributor Author

@HuangJunye I have checked the docs locally and it's working fine now.

This was referenced Jul 6, 2023
Eric-Arellano
Eric-Arellano previously approved these changes Jul 11, 2023
Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks good to me. Can you please confirm you're happy with this? If so, I'll set to merge.

@divshacker
Copy link
Contributor Author

Yeah Sure, Please go Ahead

@divshacker
Copy link
Contributor Author

This PR is ready for review.
Thanks

Eric-Arellano pushed a commit that referenced this pull request Jul 26, 2023
<!--
⚠️ If you do not respect this template, your pull request will be
closed.
⚠️ Your pull request title should be short detailed and understandable
for all.
⚠️ If your pull request fixes an open issue, please link to the issue.

✅ I have added the tests to cover my changes.
✅ I have updated the documentation accordingly.
✅ I have read the CONTRIBUTING document.
-->

### Summary
I have coded a script which (when directory is specified) checks for the
broken links in the Jupyter notebooks and tells its exact place and the
error it shows.
```
import os
import nbformat as nbf
import re
import requests
# Code to populate file_list with relevant .ipynb files
file_list = []

for root, dirs, files in os.walk("qiskit-tutorials/tutorials/"):
    for file in files:
        if file.endswith(".ipynb"):
            file_list.append(os.path.join(root, file))  # Including the relative path of the file

INLINE_LINK_RE = re.compile(r'\[([^\]]+)\]\(([^)]+)\)')
for file_path in file_list:
    try:
        with open(file_path) as file:
            nb = nbf.read(file, 4)
    except OSError as e:
        print(f"Error occurred while reading file: {file_path}")
        print("Error message:", str(e))
        print()
        continue

    for cell in nb["cells"]:
        if cell["cell_type"] != "markdown":
            continue
        links = list(INLINE_LINK_RE.findall(cell["source"]))
        for link in links:
            if not link:
                continue
            link_text, link_url = link
            if link_url.lower().endswith(('.png', '.jpg', '.jpeg', '.gif')):
                continue  # Skip image links
            try:
                response = requests.get(link_url)
                if response.status_code != 200:
                    print(f"Broken link found in file: {file_path}")
                    print(f"Link: {link_text}")
                    print(f"URL: {link_url}")
                    print("HTTP status code:", response.status_code)
                    print()
            except requests.RequestException as e:
                print(f"Error occurred while checking link in file: {file_path}")
                print(f"Link: {link_text}")
                print(f"URL: {link_url}")
                print("Error message:", str(e))
                print()

```

### Details and comments

This code is part of QAMP Project [Issues in Qiskit Tutorials
#37](qiskit-advocate/qamp-spring-23#37)
which can read many files at once and can find broken links with their
exact position and error code it is showing.

I ran this above code throughout the repo and checked each and every
Jupyter notebook files, based on the output I have fixed many links.
This PR is just the Last PR of the of project, which fixes the remaining
broken links. All the other broken links are already fixed in the past
PRs which are made throughout this project. #1445 #1446 #1467 #1483
#1484.
This project also fixes #1402
Copy link
Collaborator

@Eric-Arellano Eric-Arellano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@Eric-Arellano Eric-Arellano merged commit 4599829 into Qiskit:master Jul 26, 2023
ElePT pushed a commit to ElePT/qiskit-algorithms that referenced this pull request Aug 17, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Improve An introduction to algorithms in qiskit tutorial if needed
5 participants