From 72c13c54be3b3add10932163347b2c09e76ae8f7 Mon Sep 17 00:00:00 2001 From: Umut Date: Wed, 6 Apr 2022 15:45:27 +0200 Subject: [PATCH] refactor: rename run method of the circuit to encrypt_run_decrypt --- README.md | 2 +- concrete/numpy/compilation/circuit.py | 6 +++--- docs/user/basics/compiling_and_executing.md | 10 +++++----- tests/compilation/test_circuit.py | 12 ++++++------ tests/conftest.py | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7403fd7cc..46c92b3d7 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ circuit = add.compile(inputset) examples = [(3, 4), (1, 2), (7, 7), (0, 0)] for example in examples: - result = circuit.run(*example) + result = circuit.encrypt_run_decrypt(*example) print(f"Evaluation of {' + '.join(map(str, example))} homomorphically = {result}") ``` diff --git a/concrete/numpy/compilation/circuit.py b/concrete/numpy/compilation/circuit.py index 9be6539e0..b7c125afe 100644 --- a/concrete/numpy/compilation/circuit.py +++ b/concrete/numpy/compilation/circuit.py @@ -60,15 +60,15 @@ class Circuit: return self.graph.draw(show, horizontal, save_to) - def run( + def encrypt_run_decrypt( self, *args: Union[int, np.ndarray], ) -> Union[int, np.ndarray, Tuple[Union[int, np.ndarray], ...]]: """ - Encrypt inputs, evaluate the circuit, and decrypt the outputs in one go. + Encrypt inputs, run the circuit, and decrypt the outputs in one go. Args: - *args (List[Union[int, numpy.ndarray]]): + *args (Union[int, numpy.ndarray]): inputs to the engine Returns: diff --git a/docs/user/basics/compiling_and_executing.md b/docs/user/basics/compiling_and_executing.md index 02915d0c8..7bc0ba4b5 100644 --- a/docs/user/basics/compiling_and_executing.md +++ b/docs/user/basics/compiling_and_executing.md @@ -64,17 +64,17 @@ Here is the graph from the previous code block drawn with `draw`: ## Performing homomorphic evaluation -You can use `.run(...)` method of `Circuit` to perform fully homomorphic evaluation. Here are some examples: +You can use `.encrypt_run_decrypt(...)` method of `Circuit` to perform fully homomorphic evaluation. Here are some examples: ```python -circuit.run(3, 4) +circuit.encrypt_run_decrypt(3, 4) # 7 -circuit.run(1, 2) +circuit.encrypt_run_decrypt(1, 2) # 3 -circuit.run(7, 7) +circuit.encrypt_run_decrypt(7, 7) # 14 -circuit.run(0, 0) +circuit.encrypt_run_decrypt(0, 0) # 0 ``` diff --git a/tests/compilation/test_circuit.py b/tests/compilation/test_circuit.py index 83de20085..6c36456e0 100644 --- a/tests/compilation/test_circuit.py +++ b/tests/compilation/test_circuit.py @@ -78,7 +78,7 @@ def test_circuit_bad_run(helpers): # --------------- with pytest.raises(ValueError) as excinfo: - circuit.run(1) + circuit.encrypt_run_decrypt(1) assert str(excinfo.value) == "Expected 2 inputs but got 1" @@ -86,7 +86,7 @@ def test_circuit_bad_run(helpers): # ---------------- with pytest.raises(ValueError) as excinfo: - circuit.run(1, 2, 3) + circuit.encrypt_run_decrypt(1, 2, 3) assert str(excinfo.value) == "Expected 2 inputs but got 3" @@ -94,7 +94,7 @@ def test_circuit_bad_run(helpers): # ------------------------ with pytest.raises(ValueError) as excinfo: - circuit.run(-1, 11) + circuit.encrypt_run_decrypt(-1, 11) assert str(excinfo.value) == ( "Expected argument 0 to be EncryptedScalar but it's EncryptedScalar" @@ -104,7 +104,7 @@ def test_circuit_bad_run(helpers): # ------------------------ with pytest.raises(ValueError) as excinfo: - circuit.run(1, -11) + circuit.encrypt_run_decrypt(1, -11) assert str(excinfo.value) == ( "Expected argument 1 to be EncryptedScalar but it's EncryptedScalar" @@ -114,7 +114,7 @@ def test_circuit_bad_run(helpers): # --------------------- with pytest.raises(ValueError) as excinfo: - circuit.run(100, 10) + circuit.encrypt_run_decrypt(100, 10) assert str(excinfo.value) == ( "Expected argument 0 to be EncryptedScalar but it's EncryptedScalar" @@ -124,7 +124,7 @@ def test_circuit_bad_run(helpers): # --------------------- with pytest.raises(ValueError) as excinfo: - circuit.run(1, 100) + circuit.encrypt_run_decrypt(1, 100) assert str(excinfo.value) == ( "Expected argument 1 to be EncryptedScalar but it's EncryptedScalar" diff --git a/tests/conftest.py b/tests/conftest.py index 749a41ba3..d399dabbb 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -236,7 +236,7 @@ class Helpers: for i in range(retries): expected = function(*sample) - actual = circuit.run(*sample) + actual = circuit.encrypt_run_decrypt(*sample) if not isinstance(expected, tuple): expected = (expected,)