Files
concrete/frontends/concrete-python/tests/extensions/test_array.py

38 lines
1014 B
Python

"""
Tests of 'array' extension.
"""
import pytest
from concrete import fhe
@pytest.mark.parametrize(
"function,parameters,expected_error",
[
pytest.param(
lambda x, y: fhe.array([x, y]),
{
"x": {"range": [0, 10], "status": "encrypted", "shape": ()},
"y": {"range": [0, 10], "status": "encrypted", "shape": (2, 3)},
},
"Encrypted arrays can only be created from scalars",
),
],
)
def test_bad_array(function, parameters, expected_error, helpers):
"""
Test array with bad parameters.
"""
parameter_encryption_statuses = helpers.generate_encryption_statuses(parameters)
configuration = helpers.configuration()
compiler = fhe.Compiler(function, parameter_encryption_statuses)
with pytest.raises(ValueError) as excinfo:
inputset = helpers.generate_inputset(parameters)
compiler.compile(inputset, configuration)
assert str(excinfo.value) == expected_error