From b82810ff9275d0170a9e3b92b90fa90351eec89b Mon Sep 17 00:00:00 2001 From: Pedro Bressan Date: Mon, 27 Nov 2023 22:46:17 -0300 Subject: [PATCH] TST: test result type of reverse Function arithmetic. --- tests/test_function.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test_function.py b/tests/test_function.py index c67a21b30..fdaf092e3 100644 --- a/tests/test_function.py +++ b/tests/test_function.py @@ -390,3 +390,19 @@ def test_shepard_interpolation(x, y, z_expected): func = Function(source=source, inputs=["x", "y"], outputs=["z"]) z = func(x, y) assert np.isclose(z, z_expected, atol=1e-8).all() + + +def test_arithmetic_priority(): + """Test the arithmetic priority of the Function class, specially + comparing to the numpy array operations. + """ + func_lambda = Function(lambda x: x**2) + func_array = Function([(0, 0), (1, 1), (2, 4)]) + array = np.array([1]) + + assert isinstance(func_lambda + func_array, Function) + assert isinstance(func_array + func_lambda, Function) + assert isinstance(func_lambda + array, Function) + assert isinstance(array + func_lambda, Function) + assert isinstance(func_array + array, Function) + assert isinstance(array + func_array, Function)