From 7ba5ebf64f7115d2d9bec3f7fb1401b135ae9204 Mon Sep 17 00:00:00 2001 From: mrader1248 Date: Tue, 3 May 2022 08:41:35 +0200 Subject: [PATCH 1/3] overridden property `shape` for `CKKSVector` --- tenseal/tensors/ckksvector.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tenseal/tensors/ckksvector.py b/tenseal/tensors/ckksvector.py index 0b55600a..3a56c386 100644 --- a/tenseal/tensors/ckksvector.py +++ b/tenseal/tensors/ckksvector.py @@ -51,6 +51,10 @@ def decrypt(self, secret_key: "ts.enc_context.SecretKey" = None) -> List[float]: def size(self) -> int: return self.data.size() + + @property + def shape(self) -> List[int]: + return [self.size()] def ciphertext(self) -> List["ts._ts_cpp.Ciphertext"]: return self.data.ciphertext() From de32a1f5d52eef1c7c3f3c764512b1265fec3f98 Mon Sep 17 00:00:00 2001 From: mrader1248 Date: Tue, 3 May 2022 08:49:47 +0200 Subject: [PATCH 2/3] added test for `shape` on `CKKSVector` --- tests/python/tenseal/tensors/test_ckks_vector.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/python/tenseal/tensors/test_ckks_vector.py b/tests/python/tenseal/tensors/test_ckks_vector.py index cd10a8be..0136470e 100644 --- a/tests/python/tenseal/tensors/test_ckks_vector.py +++ b/tests/python/tenseal/tensors/test_ckks_vector.py @@ -1282,3 +1282,9 @@ def test_size(context): for size in range(1, 10): vec = ts.ckks_vector(context, [1] * size) assert vec.size() == size, "Size of encrypted vector is incorrect." + + +def test_shape(context): + for size in range(1, 10): + vec = ts.ckks_vector(context, [1] * size) + assert vec.shape == [size], "Shape of encrypted vector is incorrect." From ab76842478afe5fd5382e622aac5e042071b0798 Mon Sep 17 00:00:00 2001 From: mrader1248 Date: Tue, 3 May 2022 16:38:20 +0200 Subject: [PATCH 3/3] applied black --- tenseal/tensors/ckksvector.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tenseal/tensors/ckksvector.py b/tenseal/tensors/ckksvector.py index 3a56c386..4b225167 100644 --- a/tenseal/tensors/ckksvector.py +++ b/tenseal/tensors/ckksvector.py @@ -51,7 +51,7 @@ def decrypt(self, secret_key: "ts.enc_context.SecretKey" = None) -> List[float]: def size(self) -> int: return self.data.size() - + @property def shape(self) -> List[int]: return [self.size()]