Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 25 additions & 5 deletions quantum/q_fourier_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,26 @@ def quantum_fourier_transform(number_of_qubits: int = 3) -> qiskit.result.counts
>>> quantum_fourier_transform(0.5)
Traceback (most recent call last):
...
ValueError: number of qubits must be exact integer.
ValueError: number of qubits must be an exact integer.

>>> result = quantum_fourier_transform(2)
>>> 2350<=result['10']<=2600
True
>>> 2350<=result['00']<=2600
True
>>> 2350<=result['11']<=2600
True
>>> 2350<=result['01']<=2600
True
>>> res = quantum_fourier_transform(3)
>>> 1150<=res['000']<=1350 and 1150<=res['001']<=1350
True
>>> 1150<=res['010']<=1350 and 1150<=res['100']<=1350
True
>>> 1150<=res['101']<=1350 and 1150<=res['110']<=1350
True
>>> 1150<=res['011']<=1350 and 1150<=res['111']<=1350
True
"""
if isinstance(number_of_qubits, str):
raise TypeError("number of qubits must be a integer.")
Expand Down Expand Up @@ -107,7 +126,8 @@ def quantum_fourier_transform(number_of_qubits: int = 3) -> qiskit.result.counts


if __name__ == "__main__":
print(
f"Total count for quantum fourier transform state is: \
{quantum_fourier_transform(3)}"
)
Comment on lines -110 to -113

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.

Why remove this?

@Jaivignesh-afk Jaivignesh-afk Oct 17, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i got error relating to more no of lines in the pre-commit.So i checked with other algorithms there were no print statements..So,but i can change it back
I think, qiskit module is not yet available for Python 3.12 +
maybe that is the reason?

import doctest

doctest.testmod()
Comment thread
cclauss marked this conversation as resolved.
print("Total count for quantum Fourier transform state is:")
print(f"{quantum_fourier_transform(3) = }")
Loading