Commit 1440a6ba authored by Tim Keil's avatar Tim Keil

[pymortest] small change for checking nested products and sums in functions

parent 58183236
......@@ -41,15 +41,17 @@ def test_lincomb_function():
GenericFunction(lambda X: np.zeros(X.shape[:-1]), dim_domain=steps)):
for one in (ConstantFunction(1.0, dim_domain=steps),
GenericFunction(lambda X: np.ones(X.shape[:-1]), dim_domain=steps), 1.0):
add = (zero + one) + 0
add = (zero + one) + 1 - 1
sub = (zero - one) + np.zeros(())
neg = - zero
assert np.allclose(sub(x), [-1])
assert np.allclose(add(x), [1.0])
assert np.allclose(neg(x), [0.0])
(repr(add), str(add), repr(one), str(one)) # just to cover the respective special funcs too
mul = neg * 1.
mul = neg * 1. * 1.
mul_ = 1. * 1. * neg
assert np.allclose(mul(x), [0.0])
assert np.allclose(mul_(x), [0.0])
with pytest.raises(AssertionError):
zero + ConstantFunction(dim_domain=steps + 1)
with pytest.raises(AssertionError):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment