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

Improves 03_vqe_simulation_with_noise#1467

Merged
Eric-Arellano merged 6 commits intoQiskit:masterfrom
divshacker:QAMP_3
Jul 26, 2023
Merged

Improves 03_vqe_simulation_with_noise#1467
Eric-Arellano merged 6 commits intoQiskit:masterfrom
divshacker:QAMP_3

Conversation

@divshacker
Copy link
Copy Markdown
Contributor

Summary

This PR will Improve 03_vqe_simulation_with_noise

Details and comments

fixes #1404
Part of #1401

@review-notebook-app
Copy link
Copy Markdown

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 June 3, 2023 21:00
@divshacker
Copy link
Copy Markdown
Contributor Author

Screenshot from 2023-06-04 02-56-28
This code was intentional, or do I update it ? @woodsp-ibm @HuangJunye
Asking because this tutorial already have Qiskit primitives and updated functions. So It might be left out intentionally? If There is anything like that please let me know
Thanks

@divshacker
Copy link
Copy Markdown
Contributor Author

Till now
I have updated a few broken links and added some more links to predefined functions.
Also, all the images are converted to SVGs.

@woodsp-ibm
Copy link
Copy Markdown
Member

This code was intentional, or do I update it ?

It needs updating - it should have been when algorithms were switched to primitives but seems to have been an oversight. See #1456

@divshacker divshacker marked this pull request as ready for review June 5, 2023 09:27
"\n",
"numpy_solver = NumPyMinimumEigensolver()\n",
"result = numpy_solver.compute_minimum_eigenvalue(operator=PauliSumOp(H2_op))\n",
"result = numpy_solver.compute_minimum_eigenvalue(operator=SparsePauliOp(H2_op))\n",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since it was created as SparsePauliOp this cast is not needed. Before it needed to be converted to a PauliSumOp for the older Numpy solver and PauliSumOp takes such an object in its constructor.

This was referenced Jul 6, 2023
Copy link
Copy Markdown
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! Were the figure changes intentional?

@divshacker
Copy link
Copy Markdown
Contributor Author

Thanks! Were the figure changes intentional?

No they were not intentional, but it was by default. There won't be any problem as SVG diagrams are better than existing PNG one.

@divshacker
Copy link
Copy Markdown
Contributor Author

This PR is ready for review.
Thanks

Copy link
Copy Markdown
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.

Links work and this runs correctly for me, 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
@Eric-Arellano Eric-Arellano merged commit 3f2fdda into Qiskit:master Jul 26, 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 VQE on Aer simulator with noise tutorial if needed

4 participants