Spaces:
Runtime error
Runtime error
import pytest | |
import numpy as np | |
from quantum_perceptron.utils.data_utils import ( | |
get_vector_from_int, | |
get_num_bits, | |
get_possible_state_strings | |
) | |
def test_get_num_bits(data, expected_result): | |
if isinstance(expected_result, bool) and not expected_result: | |
with pytest.raises(ValueError): | |
get_num_bits(data) | |
else: | |
assert expected_result == get_num_bits(data) | |
def test_get_vector_from_int(data, expected_result): | |
if isinstance(expected_result, bool) and not expected_result: | |
with pytest.raises(ValueError): | |
get_vector_from_int(data) | |
else: | |
np.array_equal( | |
expected_result, | |
get_vector_from_int(data) | |
) | |
def test_get_possible_state_strings(num_bits, expected_result): | |
if isinstance(expected_result, bool) and not expected_result: | |
with pytest.raises(ValueError): | |
get_possible_state_strings(num_bits) | |
else: | |
np.array_equal( | |
expected_result, | |
get_possible_state_strings(num_bits) | |
) | |