mirror of
https://github.com/TheAlgorithms/Python.git
synced 2026-03-13 09:50:19 +08:00
clean of unnecessary checks, imports, calls (#7993)
This commit is contained in:
@@ -55,9 +55,9 @@ def quantum_fourier_transform(number_of_qubits: int = 3) -> qiskit.result.counts
|
||||
...
|
||||
ValueError: number of qubits must be exact integer.
|
||||
"""
|
||||
if type(number_of_qubits) == str:
|
||||
if isinstance(number_of_qubits, str):
|
||||
raise TypeError("number of qubits must be a integer.")
|
||||
if not number_of_qubits > 0:
|
||||
if number_of_qubits <= 0:
|
||||
raise ValueError("number of qubits must be > 0.")
|
||||
if math.floor(number_of_qubits) != number_of_qubits:
|
||||
raise ValueError("number of qubits must be exact integer.")
|
||||
|
||||
@@ -60,7 +60,11 @@ def quantum_full_adder(
|
||||
...
|
||||
ValueError: inputs must be less or equal to 2.
|
||||
"""
|
||||
if (type(input_1) == str) or (type(input_2) == str) or (type(carry_in) == str):
|
||||
if (
|
||||
isinstance(input_1, str)
|
||||
or isinstance(input_2, str)
|
||||
or isinstance(carry_in, str)
|
||||
):
|
||||
raise TypeError("inputs must be integers.")
|
||||
|
||||
if (input_1 < 0) or (input_2 < 0) or (carry_in < 0):
|
||||
|
||||
@@ -53,7 +53,7 @@ def superdense_coding(bit_1: int = 1, bit_2: int = 1) -> qiskit.result.counts.Co
|
||||
...
|
||||
ValueError: inputs must be less or equal to 1.
|
||||
"""
|
||||
if (type(bit_1) == str) or (type(bit_2) == str):
|
||||
if isinstance(bit_1, str) or isinstance(bit_2, str):
|
||||
raise TypeError("inputs must be integers.")
|
||||
if (bit_1 < 0) or (bit_2 < 0):
|
||||
raise ValueError("inputs must be positive.")
|
||||
|
||||
Reference in New Issue
Block a user