Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

quantum_teleportation.py #6632

Merged
merged 8 commits into from
Oct 30, 2022
Merged

quantum_teleportation.py #6632

merged 8 commits into from
Oct 30, 2022

Conversation

KevinJoven11
Copy link
Contributor

@KevinJoven11 KevinJoven11 commented Oct 4, 2022

This code is for the #hacktoberfest
This circuit run the teleportation circuit using Qiskit. You can change the teleported state as preference.

Describe your change:

I add the quantum teleportation algorithm using qiskit. This is my first Pull Request let me know if I did it well.
Best,

  • [ X] Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • [ X] I have read CONTRIBUTING.md.
  • [ X] This pull request is all my own work -- I have not plagiarized.
  • [ X] I know that pull requests will not be merged if they fail the automated tests.
  • [ X] This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • [ X] All new Python files are placed inside an existing directory.
  • [ X] All filenames are in all lowercase characters with no spaces or dashes.
  • [ X] All functions and variable names follow Python naming conventions.
  • [ X] All function parameters and return values are annotated with Python type hints.
  • [ X] All functions have doctests that pass the automated testing.
  • [ X] All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • [ X] If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

KevinJoven11 and others added 2 commits October 4, 2022 00:40
This code is for the #Hacktoberfest.
This file run the quantum teleportation circuit using Qiskit.
Copy link
Contributor

@CaedenPH CaedenPH left a comment

Choose a reason for hiding this comment

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

Please typehint the functipn return type


def quantum_teleportation(
theta: float = np.pi / 2, phi: float = np.pi / 2, lam: float = np.pi / 2
):
Copy link
Contributor

Choose a reason for hiding this comment

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

What type does this return?

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 return the counts probabilities of the qubit teleported.

Copy link
Contributor

Choose a reason for hiding this comment

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

@KevinJoven11 Then indicate that with the python return typehint.

For example:

def add(a: int, b: int) -> int:
    return a + b

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I think that I did it in one of the pull request. Name "python return typehint solved".

quantum/quantum_teleportation.py Outdated Show resolved Hide resolved
quantum/quantum_teleportation.py Outdated Show resolved Hide resolved

if __name__ == "__main__":
print(
f"Total count for teleported state is: {quantum_teleportation(np.pi/2, np.pi/2, np.pi/2)}"
Copy link
Contributor

Choose a reason for hiding this comment

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

If the function has default values then you don't need to pass anything in

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect!

Copy link
Member

Choose a reason for hiding this comment

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

Relying only on the default values sounds boring to me. We want to test multiple sets of values.

KevinJoven11 and others added 5 commits October 4, 2022 10:34
Co-authored-by: Caeden <caedenperelliharris@gmail.com>
Co-authored-by: Caeden <caedenperelliharris@gmail.com>
Corrected some typos. 
Add more comments for adding the gates.
Update the variable qc with quantum_circuit in the simulator and execute.
@algorithms-keeper algorithms-keeper bot mentioned this pull request Oct 7, 2022
14 tasks
@cclauss cclauss merged commit 87a5d91 into TheAlgorithms:master Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants