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

fix(frontend-python): failure to display invalid input set value #682

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion frontends/concrete-python/concrete/fhe/compilation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def validate_input_args(
sanitized_args[index] = arg

if not is_valid:
actual_value = ValueDescription.of(arg, is_encrypted=is_encrypted)
try:
actual_value = str(ValueDescription.of(arg, is_encrypted=is_encrypted))
except ValueError:
actual_value = type(arg).__name__
message = f"Expected argument {index} to be {expected_value} but it's {actual_value}"
raise ValueError(message)

Expand Down
8 changes: 8 additions & 0 deletions frontends/concrete-python/tests/compilation/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def f(x, y):

assert str(excinfo.value) == "Expected argument 0 to be an fhe.Value but it's dict"

# with invalid argument
# ---------------------

with pytest.raises(ValueError) as excinfo:
circuit.encrypt_run_decrypt({"yes": "no"}, 10)

assert str(excinfo.value) == "Expected argument 0 to be EncryptedScalar<uint6> but it's dict"


def test_circuit_separate_args(helpers):
"""
Expand Down
Loading