Commit b337ab07 authored by René Fritze's avatar René Fritze Committed by René Fritze

[tests] adjust POD assertions for lin.dep. input

parent c34c50c1
......@@ -8,6 +8,7 @@ from hypothesis import given, assume, reproduce_failure, settings
from hypothesis.strategies import sampled_from
from pymor.algorithms.basic import almost_equal
from pymor.algorithms.gram_schmidt import gram_schmidt
from pymor.algorithms.pod import pod
from import contains_zero_vector
from pymortests.fixtures.operator import operator_with_arrays_and_products
......@@ -20,6 +21,7 @@ methods = ['method_of_snapshots', 'qr_svd']
@given(vector_arrays(count=1), sampled_from(methods))
def test_pod(vector_array, method):
A = vector_array[0]
product = None
print(A.dim, len(A))
# TODO assumption here masks a potential issue with the algorithm
......@@ -28,9 +30,20 @@ def test_pod(vector_array, method):
assume(not contains_zero_vector(A, rtol=1e-13, atol=1e-13))
B = A.copy()
U, s = pod(A, method=method)
# we run the pod with infinite tol so we can manually check gram_schidt and adjust assertions
orth_tol = np.inf
U, s = pod(A, method=method, orth_tol=orth_tol)
assert np.all(almost_equal(A, B))
assert len(U) == len(s)
if U.dim > 0 and len(U) > 0:
orth_tol = 1e-10 # the default
err = np.max(np.abs(U.inner(U, product) - np.eye(len(U))))
U_orth = gram_schmidt(U, product=product, copy=True) if err >= orth_tol else U
if len(U_orth) < len(U):
assert len(U_orth) < len(s)
assert len(U) == len(s)
assert len(U) == len(s)
assert np.allclose(U.gramian(), np.eye(len(s)))
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment