Commit 8e0f0f90 authored by René Fritze's avatar René Fritze Committed by René Fritze

[test.algorithm] adjust vector array related test executions

parent 11faf55c
......@@ -25,11 +25,11 @@ from pymortests.vectorarray import indexed, assume_old_slicing
import pymortests.strategies as pyst
@given(vectors=pyst.vector_arrays(count=2),
@pyst.implementations(count=2,
tolerances=hyst.sampled_from([(1e-5, 1e-8), (1e-10, 1e-12), (0., 1e-8), (1e-5, 1e-8)]),
norms=hyst.sampled_from([('sup', np.inf), ('l1', 1), ('l2', 2)]))
def test_almost_equal(vectors, tolerances, norms):
v1, v2 = vectors
def test_almost_equal(vector_arrays, tolerances, norms):
v1, v2 = vector_arrays
rtol, atol = tolerances
n, o = norms
try:
......@@ -77,12 +77,12 @@ def test_almost_equal_product(operator_with_arrays_and_products):
<= atol + rtol * norm(v2[ind2])))
@given(vec_ind=pyst.vector_arrays_with_ind_pairs_same_length(count=1),
@pyst.implementations(count=1, index_strategy=pyst.pairs_same_length,
tolerances=hyst.sampled_from([(1e-5, 1e-8), (1e-10, 1e-12), (0., 1e-8), (1e-5, 1e-8), (1e-12, 0.)]),
norm=hyst.sampled_from(['sup', 'l1', 'l2']))
@settings(print_blob=True)
def test_almost_equal_self(vec_ind, tolerances, norm):
v, (ind,_) = vec_ind
def test_almost_equal_self(vectors_and_indices, tolerances, norm):
v, (ind,_) = vectors_and_indices
rtol, atol = tolerances
n = norm
try:
......@@ -184,9 +184,9 @@ def test_almost_equal_self_product(operator_with_arrays_and_products):
assert not np.all(almost_equal(c[ind], v[ind], atol=atol, rtol=rtol, product=product))
@given(pyst.vector_arrays(count=2, compatible=False))
def test_almost_equal_incompatible(incompatible_vector_array_pair):
v1, v2 = incompatible_vector_array_pair
@pyst.implementations(count=2, compatible=False)
def test_almost_equal_incompatible(vector_arrays):
v1, v2 = vector_arrays
for ind1, ind2 in valid_inds_of_same_length(v1, v2):
for n in ['sup', 'l1', 'l2']:
c1, c2 = v1.copy(), v2.copy()
......
......@@ -4,7 +4,7 @@
import numpy as np
import pytest
from hypothesis import given, settings, assume, reproduce_failure, example
from hypothesis import settings, assume, given
from pymor.algorithms.basic import almost_equal
from pymor.algorithms.gram_schmidt import gram_schmidt, gram_schmidt_biorth
......@@ -16,10 +16,10 @@ from pymortests.fixtures.operator import operator_with_arrays_and_products
import pymortests.strategies as pyst
@given(pyst.vector_arrays(count=1))
@pyst.implementations()
@settings(deadline=20000)
def test_gram_schmidt(vector_array):
U = vector_array[0]
U = vector_array
# TODO assumption here masks a potential issue with the algorithm
# where it fails in del instead of a proper error
assume(len(U) > 1 or not contains_zero_vector(U))
......@@ -36,10 +36,10 @@ def test_gram_schmidt(vector_array):
assert np.all(almost_equal(onb, U))
@given(pyst.vector_arrays(count=1))
@pyst.implementations()
@settings(deadline=None)
def test_gram_schmidt_with_R(vector_array):
U = vector_array[0]
U = vector_array
# TODO assumption here masks a potential issue with the algorithm
# where it fails in del instead of a proper error
assume(len(U) > 1 or not contains_zero_vector(U))
......
......@@ -12,15 +12,15 @@ from pymor.algorithms.gram_schmidt import gram_schmidt
from pymor.algorithms.pod import pod
from pymor.algorithms.basic import contains_zero_vector
from pymortests.fixtures.operator import operator_with_arrays_and_products
from pymortests.strategies import vector_arrays
from pymortests.strategies import vector_arrays, implementations
methods = ['method_of_snapshots', 'qr_svd']
@settings(deadline=None)
@given(vector_arrays(count=1), sampled_from(methods))
@implementations(method=sampled_from(methods))
def test_pod(vector_array, method):
A = vector_array[0]
A = vector_array
product = None
print(type(A))
print(A.dim, len(A))
......
......@@ -12,15 +12,15 @@ from pymor.algorithms.svd_va import method_of_snapshots, qr_svd
from pymor.algorithms.basic import contains_zero_vector
from pymortests.base import runmodule
from pymortests.fixtures.operator import operator_with_arrays_and_products
from pymortests.strategies import vector_arrays
from pymortests.strategies import vector_arrays, implementations
methods = [method_of_snapshots, qr_svd]
@given(vector_arrays(count=1), sampled_from(methods))
@implementations(method=sampled_from(methods))
@settings(deadline=None)
def test_method_of_snapshots(vector_array, method):
A = vector_array[0]
A = vector_array
print(type(A))
print(A.dim, len(A))
......
......@@ -380,8 +380,9 @@ def base_vector_arrays(draw, count=1, dtype=None, max_dim=100):
"""
dtype = dtype or np.float_
# simplest way currently of getting a |VectorSpace| to construct our new arrays from
space = draw(vector_arrays(count=1, dtype=dtype, length=hyst.just((1,)), compatible=True)
.filter(lambda x: x[0].space.dim > 0 and x[0].space.dim < max_dim))[0].space
space_types = _picklable_vector_space_types + _other_vector_space_types
space = draw(vector_arrays(count=1, dtype=dtype, length=hyst.just((1,)), compatible=True, space_types=space_types)
.filter(lambda x: x[0].space.dim > 0 and x[0].space.dim < max_dim)).space
length = space.dim
from scipy.stats import random_correlation
# this lets hypothesis control np's random state too
......
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