mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
feat: raise error if tracers are tried to be converted to bool
This commit is contained in:
@@ -175,6 +175,12 @@ class Tracer:
|
||||
def __hash__(self) -> int:
|
||||
return id(self)
|
||||
|
||||
def __bool__(self) -> bool:
|
||||
# pylint: disable=invalid-bool-returned
|
||||
|
||||
message = "Branching within circuits is not possible"
|
||||
raise RuntimeError(message)
|
||||
|
||||
@staticmethod
|
||||
def sanitize(value: Any) -> Any:
|
||||
"""
|
||||
|
||||
@@ -45,6 +45,12 @@ from concrete.numpy.values import EncryptedTensor
|
||||
"`astype` method must be called with a "
|
||||
"numpy type for compilation (e.g., value.astype(np.int64))",
|
||||
),
|
||||
pytest.param(
|
||||
lambda x: x + 1 if x else x + x,
|
||||
{"x": EncryptedTensor(UnsignedInteger(7), shape=())},
|
||||
RuntimeError,
|
||||
"Branching within circuits is not possible",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_tracer_bad_trace(function, parameters, expected_error, expected_message):
|
||||
|
||||
Reference in New Issue
Block a user