Skip to content

Commit

Permalink
TST: test result type of reverse Function arithmetic.
Browse files Browse the repository at this point in the history
  • Loading branch information
phmbressan committed Nov 28, 2023
1 parent 657ae95 commit b82810f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit b82810f

Please sign in to comment.