mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-08 19:44:57 -05:00
chore: remove unnecessary lambda in tests
This commit is contained in:
committed by
Benoit Chevallier
parent
eedbe0606b
commit
23d4dead30
5
Makefile
5
Makefile
@@ -46,8 +46,9 @@ pylint_src:
|
||||
.PHONY: pylint_src
|
||||
|
||||
pylint_tests:
|
||||
@# Disable duplicate code detection in tests
|
||||
find ./tests/ -type f -name "*.py" | xargs poetry run pylint --disable=R0801 --rcfile=pylintrc
|
||||
@# Disable duplicate code detection (R0801) in tests
|
||||
@# Disable unnecessary lambda (W0108) for tests
|
||||
find ./tests/ -type f -name "*.py" | xargs poetry run pylint --disable=R0801,W0108 --rcfile=pylintrc
|
||||
.PHONY: pylint_tests
|
||||
|
||||
pylint_benchmarks:
|
||||
|
||||
@@ -739,7 +739,7 @@ def test_compile_function_with_direct_tlu_overflow(default_compilation_configura
|
||||
)
|
||||
|
||||
|
||||
# pylint: disable=line-too-long,unnecessary-lambda
|
||||
# pylint: disable=line-too-long
|
||||
@pytest.mark.parametrize(
|
||||
"function,parameters,inputset,match",
|
||||
[
|
||||
@@ -910,7 +910,7 @@ def test_compile_function_with_direct_tlu_overflow(default_compilation_configura
|
||||
),
|
||||
],
|
||||
)
|
||||
# pylint: enable=line-too-long,unnecessary-lambda
|
||||
# pylint: enable=line-too-long
|
||||
def test_fail_compile(function, parameters, inputset, match, default_compilation_configuration):
|
||||
"""Test function compile_numpy_function_into_op_graph for a program with signed values"""
|
||||
|
||||
@@ -993,7 +993,6 @@ def test_small_inputset_treat_warnings_as_errors():
|
||||
@pytest.mark.parametrize(
|
||||
"function,params,shape,ref_graph_str",
|
||||
[
|
||||
# pylint: disable=unnecessary-lambda
|
||||
(
|
||||
lambda x, y: numpy.dot(x, y),
|
||||
{
|
||||
@@ -1011,7 +1010,6 @@ def test_small_inputset_treat_warnings_as_errors():
|
||||
"# EncryptedScalar<Integer<unsigned, 6 bits>>"
|
||||
"\nreturn(%2)\n",
|
||||
),
|
||||
# pylint: enable=unnecessary-lambda
|
||||
],
|
||||
)
|
||||
def test_compile_function_with_dot(
|
||||
@@ -1129,7 +1127,7 @@ def test_compile_too_high_bitwidth(default_compilation_configuration):
|
||||
|
||||
def test_failure_for_signed_output(default_compilation_configuration):
|
||||
"""Test that we don't accept signed output"""
|
||||
function = lambda x: x + (-3) # pylint: disable=unnecessary-lambda # noqa: E731
|
||||
function = lambda x: x + (-3) # noqa: E731
|
||||
input_ranges = ((0, 10),)
|
||||
list_of_arg_names = ["x"]
|
||||
|
||||
|
||||
@@ -190,7 +190,6 @@ def test_print_and_draw_graph_with_direct_tlu(lambda_f, params, ref_graph_str):
|
||||
@pytest.mark.parametrize(
|
||||
"lambda_f,params,ref_graph_str",
|
||||
[
|
||||
# pylint: disable=unnecessary-lambda
|
||||
(
|
||||
lambda x, y: numpy.dot(x, y),
|
||||
{
|
||||
@@ -199,7 +198,6 @@ def test_print_and_draw_graph_with_direct_tlu(lambda_f, params, ref_graph_str):
|
||||
},
|
||||
"%0 = x\n%1 = y\n%2 = Dot(%0, %1)\nreturn(%2)\n",
|
||||
),
|
||||
# pylint: enable=unnecessary-lambda
|
||||
],
|
||||
)
|
||||
def test_print_and_draw_graph_with_dot(lambda_f, params, ref_graph_str):
|
||||
|
||||
@@ -394,9 +394,7 @@ def test_tracing_astype(
|
||||
# We really need a lambda (because numpy functions are not playing
|
||||
# nice with inspect.signature), but pylint is not happy
|
||||
# with it
|
||||
# pylint: disable=unnecessary-lambda
|
||||
[lambda x: numpy.invert(x), lambda x: numpy.bitwise_not(x)],
|
||||
# pylint: enable=unnecessary-lambda
|
||||
)
|
||||
def test_trace_numpy_fails_for_invert(inputs, function_to_trace):
|
||||
"""Check we catch calls to numpy.invert and tell user to change their code"""
|
||||
@@ -446,9 +444,9 @@ def test_trace_numpy_supported_unary_ufuncs(inputs, expected_output_node, functi
|
||||
# We really need a lambda (because numpy functions are not playing
|
||||
# nice with inspect.signature), but pylint and flake8 are not happy
|
||||
# with it
|
||||
# pylint: disable=unnecessary-lambda,cell-var-from-loop
|
||||
# pylint: disable=cell-var-from-loop
|
||||
function_to_trace = lambda x: function_to_trace_def(x) # noqa: E731
|
||||
# pylint: enable=unnecessary-lambda,cell-var-from-loop
|
||||
# pylint: enable=cell-var-from-loop
|
||||
|
||||
op_graph = tracing.trace_numpy_function(function_to_trace, inputs)
|
||||
|
||||
@@ -483,9 +481,7 @@ def test_trace_numpy_ufuncs_not_supported():
|
||||
# We really need a lambda (because numpy functions are not playing
|
||||
# nice with inspect.signature), but pylint and flake8 are not happy
|
||||
# with it
|
||||
# pylint: disable=unnecessary-lambda
|
||||
function_to_trace = lambda x: numpy.add.reduce(x) # noqa: E731
|
||||
# pylint: enable=unnecessary-lambda
|
||||
|
||||
with pytest.raises(NotImplementedError) as excinfo:
|
||||
tracing.trace_numpy_function(function_to_trace, inputs)
|
||||
@@ -504,9 +500,7 @@ def test_trace_numpy_ufuncs_no_kwargs_no_extra_args():
|
||||
# We really need a lambda (because numpy functions are not playing
|
||||
# nice with inspect.signature), but pylint and flake8 are not happy
|
||||
# with it
|
||||
# pylint: disable=unnecessary-lambda
|
||||
function_to_trace = lambda x, y, z: numpy.add(x, y, z) # noqa: E731
|
||||
# pylint: enable=unnecessary-lambda
|
||||
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
tracing.trace_numpy_function(function_to_trace, inputs)
|
||||
@@ -517,9 +511,7 @@ def test_trace_numpy_ufuncs_no_kwargs_no_extra_args():
|
||||
# We really need a lambda (because numpy functions are not playing
|
||||
# nice with inspect.signature), but pylint and flake8 are not happy
|
||||
# with it
|
||||
# pylint: disable=unnecessary-lambda
|
||||
function_to_trace = lambda x, y, z: numpy.add(x, y, out=z) # noqa: E731
|
||||
# pylint: enable=unnecessary-lambda
|
||||
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
tracing.trace_numpy_function(function_to_trace, inputs)
|
||||
@@ -530,7 +522,6 @@ def test_trace_numpy_ufuncs_no_kwargs_no_extra_args():
|
||||
@pytest.mark.parametrize(
|
||||
"function_to_trace,inputs,expected_output_node,expected_output_value",
|
||||
[
|
||||
# pylint: disable=unnecessary-lambda
|
||||
pytest.param(
|
||||
lambda x, y: numpy.dot(x, y),
|
||||
{
|
||||
@@ -566,7 +557,6 @@ def test_trace_numpy_ufuncs_no_kwargs_no_extra_args():
|
||||
ir.Dot,
|
||||
EncryptedScalar(Integer(64, True)),
|
||||
),
|
||||
# pylint: enable=unnecessary-lambda
|
||||
],
|
||||
)
|
||||
def test_trace_numpy_dot(function_to_trace, inputs, expected_output_node, expected_output_value):
|
||||
|
||||
Reference in New Issue
Block a user