From bac9792a06acba63ab75c02446e4e140ff84e783 Mon Sep 17 00:00:00 2001 From: Umut Date: Fri, 21 Oct 2022 11:56:56 +0200 Subject: [PATCH] fix: use builtin math instead of numpy for log2 and ceil to avoid overflow issues --- concrete/numpy/dtypes/integer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/concrete/numpy/dtypes/integer.py b/concrete/numpy/dtypes/integer.py index f8735fc90..1440c480a 100644 --- a/concrete/numpy/dtypes/integer.py +++ b/concrete/numpy/dtypes/integer.py @@ -2,6 +2,7 @@ Declaration of `Integer` class. """ +import math from functools import partial from typing import Any @@ -66,9 +67,9 @@ class Integer(BaseDataType): return 1 if value < 0: - bits = int(np.ceil(np.log2(abs(value)))) + 1 + bits = int(math.ceil(math.log2(abs(value)))) + 1 else: - bits = int(np.ceil(np.log2(value + 1))) + bits = int(math.ceil(math.log2(value + 1))) if force_signed: bits += 1