From 2e459a344cf6c85a6bc8a6978745022e70fee493 Mon Sep 17 00:00:00 2001 From: youben11 Date: Fri, 3 Sep 2021 07:49:09 +0100 Subject: [PATCH] refactor(dtype_helpers): homogenize functions --- hdk/common/data_types/dtypes_helpers.py | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/hdk/common/data_types/dtypes_helpers.py b/hdk/common/data_types/dtypes_helpers.py index 7c2c027b3..0879521ee 100644 --- a/hdk/common/data_types/dtypes_helpers.py +++ b/hdk/common/data_types/dtypes_helpers.py @@ -31,11 +31,7 @@ def value_is_encrypted_scalar_integer(value_to_check: BaseValue) -> bool: Returns: bool: True if the passed value_to_check is an encrypted ScalarValue of type Integer """ - return ( - isinstance(value_to_check, ScalarValue) - and value_to_check.is_encrypted - and isinstance(value_to_check.data_type, INTEGER_TYPES) - ) + return value_is_scalar_integer(value_to_check) and value_to_check.is_encrypted def value_is_encrypted_scalar_unsigned_integer(value_to_check: BaseValue) -> bool: @@ -63,11 +59,7 @@ def value_is_clear_scalar_integer(value_to_check: BaseValue) -> bool: Returns: bool: True if the passed value_to_check is a clear ScalarValue of type Integer """ - return ( - isinstance(value_to_check, ScalarValue) - and value_to_check.is_clear - and isinstance(value_to_check.data_type, INTEGER_TYPES) - ) + return value_is_scalar_integer(value_to_check) and value_to_check.is_clear def value_is_scalar_integer(value_to_check: BaseValue) -> bool: @@ -93,11 +85,7 @@ def value_is_encrypted_tensor_integer(value_to_check: BaseValue) -> bool: Returns: bool: True if the passed value_to_check is an encrypted TensorValue of type Integer """ - return ( - isinstance(value_to_check, TensorValue) - and value_to_check.is_encrypted - and isinstance(value_to_check.data_type, INTEGER_TYPES) - ) + return value_is_tensor_integer(value_to_check) and value_to_check.is_encrypted def value_is_encrypted_tensor_unsigned_integer(value_to_check: BaseValue) -> bool: @@ -125,11 +113,7 @@ def value_is_clear_tensor_integer(value_to_check: BaseValue) -> bool: Returns: bool: True if the passed value_to_check is a clear TensorValue of type Integer """ - return ( - isinstance(value_to_check, TensorValue) - and value_to_check.is_clear - and isinstance(value_to_check.data_type, INTEGER_TYPES) - ) + return value_is_tensor_integer(value_to_check) and value_to_check.is_clear def value_is_tensor_integer(value_to_check: BaseValue) -> bool: