dev: add code to have the proper data type when getting an AF table

- update BaseDataType to store the underlying type constructor e.g. int
- add helper functions to get the type constructor for constant data
- update operator graph to fill the type constructor during bounds update
- add loguru as logger
- use type constructor in ArbitraryFunction.get_table, log an info if the
type_constructor of the input was None and default to int
This commit is contained in:
Arthur Meyre
2021-09-06 17:32:10 +02:00
parent 269ce01db3
commit 6fe809aece
11 changed files with 154 additions and 11 deletions

View File

@@ -8,6 +8,7 @@ from concrete.common.data_types.integers import Integer
from concrete.numpy.np_dtypes_helpers import (
convert_base_data_type_to_numpy_dtype,
convert_numpy_dtype_to_base_data_type,
get_type_constructor_for_numpy_or_python_constant_data,
)
@@ -55,3 +56,23 @@ def test_convert_numpy_dtype_to_base_data_type(numpy_dtype, expected_common_type
def test_convert_common_dtype_to_numpy_dtype(common_dtype, expected_numpy_dtype):
"""Test function for convert_common_dtype_to_numpy_dtype"""
assert expected_numpy_dtype == convert_base_data_type_to_numpy_dtype(common_dtype)
@pytest.mark.parametrize(
"constant_data,expected_constructor",
[
(10, int),
(42.0, float),
(numpy.int32(10), numpy.int32),
(numpy.array([[0, 1], [3, 4]], dtype=numpy.uint64), numpy.uint64),
(numpy.array([[0, 1], [3, 4]], dtype=numpy.float64), numpy.float64),
],
)
def test_get_type_constructor_for_numpy_or_python_constant_data(
constant_data, expected_constructor
):
"""Test function for get_type_constructor_for_numpy_or_python_constant_data"""
assert expected_constructor == get_type_constructor_for_numpy_or_python_constant_data(
constant_data
)