Skip to content

Commit

Permalink
Feature379 ckksvector shape (#394)
Browse files Browse the repository at this point in the history
* overridden property `shape` for `CKKSVector`

* added test for `shape` on `CKKSVector`

* applied black
  • Loading branch information
mrader1248 authored May 3, 2022
1 parent ff1793f commit 9360291
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tenseal/tensors/ckksvector.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,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()

Expand Down
6 changes: 6 additions & 0 deletions tests/python/tenseal/tensors/test_ckks_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."

0 comments on commit 9360291

Please sign in to comment.