Skip to content

Commit

Permalink
fix(frontend-python): failure to display invalid input set value
Browse files Browse the repository at this point in the history
  • Loading branch information
rudy-6-4 authored and BourgerieQuentin committed Feb 15, 2024
1 parent 34628ec commit 9fdb959
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
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

0 comments on commit 9fdb959

Please sign in to comment.