Commit 86ad2265 authored by René Fritze's avatar René Fritze Committed by René Fritze

[tests] remove superfluous "wrong_ind" tests

These tests were all checking if `VectorArray.__getitem__` raises _any_
Exception given a "wrong" index. Nothing in these tests was actually
specific to `dot`, `almost_equal`, etc.
parent 9f87aef0
......@@ -194,21 +194,6 @@ def test_almost_equal_incompatible(incompatible_vector_array_pair):
almost_equal(c1[ind1], c2[ind2], norm=n)
@given(vectors_indices=pyst.vector_arrays_with_invalid_inds(count=2))
def test_almost_equal_wrong_ind(vectors_indices):
def _check(ind, v):
return ind is None and len(v) == 1 or isinstance(ind, Number) or hasattr(ind, '__len__') and len(ind) == 1
v1, v2 = vectors_indices[0]
ind1, ind2 = vectors_indices[1]
for n in ['sup', 'l1', 'l2']:
if _check(ind1, v1) or _check(ind2, v2):
continue
c1, c2 = v1.copy(), v2.copy()
with pytest.raises(Exception):
almost_equal(c1[ind1], c2[ind2], norm=n)
@given(pyst.base_vector_arrays(count=2))
@settings(deadline=None)
def test_project_array(bases):
......
......@@ -1024,38 +1024,12 @@ def test_isub_incompatible(incompatible_vector_array_pair):
@given(pyst.vector_arrays(count=1))
def test_copy_wrong_ind(vector_arrays):
def test_wrong_ind_raises_exception(vector_arrays):
v = vector_arrays[0]
# TODO index input as hypothesis strategy
for ind in invalid_inds(v):
with pytest.raises(Exception):
v[ind].copy()
@given(pyst.vector_arrays(count=1))
def test_remove_wrong_ind(vector_arrays):
v = vector_arrays[0]
for ind in invalid_inds(v):
c = v.copy()
with pytest.raises(Exception):
del c[ind]
@given(pyst.vector_arrays(count=1))
def test_scal_wrong_ind(vector_arrays):
v = vector_arrays[0]
for ind in invalid_inds(v):
c = v.copy()
with pytest.raises(Exception):
c[ind].scal(0.)
c = v.copy()
with pytest.raises(Exception):
c[ind].scal(1.)
c = v.copy()
with pytest.raises(Exception):
c[ind].scal(-1.)
c = v.copy()
with pytest.raises(Exception):
c[ind].scal(1.2)
v[ind]
@given(pyst.vector_array_with_ind())
......@@ -1068,30 +1042,10 @@ def test_scal_wrong_coefficients(v_ind):
v[ind].scal(alpha)
@settings(deadline=None)
@given(pyst.vector_arrays(count=2))
def test_axpy_wrong_ind(compatible_vector_array_pair):
v1, v2 = compatible_vector_array_pair
for ind1, ind2 in invalid_ind_pairs(v1, v2):
if v2.len_ind(ind2) == 1:
continue
c1, c2 = v1.copy(), v2.copy()
with pytest.raises(Exception):
c1[ind1].axpy(0., c2[ind2])
c1, c2 = v1.copy(), v2.copy()
with pytest.raises(Exception):
c1[ind1].axpy(1., c2[ind2])
c1, c2 = v1.copy(), v2.copy()
with pytest.raises(Exception):
c1[ind1].axpy(-1., c2[ind2])
c1, c2 = v1.copy(), v2.copy()
with pytest.raises(Exception):
c1[ind1].axpy(1.456, c2[ind2])
@given(pyst.vector_arrays(count=2))
def test_axpy_wrong_coefficients(compatible_vector_array_pair):
v1, v2 = compatible_vector_array_pair
# TODO data input from hypothesis strategy
for ind1, ind2 in pyst.valid_inds_of_same_length(v1, v2):
np.random.seed(len(v1) + 99)
for alpha in ([np.array([]), np.eye(v1.len_ind(ind1)), np.random.random(v1.len_ind(ind1) + 1)]
......@@ -1101,15 +1055,6 @@ def test_axpy_wrong_coefficients(compatible_vector_array_pair):
v1[ind1].axpy(alpha, v2[ind2])
@given(pyst.vector_arrays(count=2))
def test_pairwise_dot_wrong_ind(compatible_vector_array_pair):
v1, v2 = compatible_vector_array_pair
for ind1, ind2 in invalid_ind_pairs(v1, v2):
c1, c2 = v1.copy(), v2.copy()
with pytest.raises(Exception):
c1[ind1].pairwise_dot(c2[ind2])
@given(pyst.picklable_vector_arrays())
def test_pickle(picklable_vector_array):
assert_picklable_without_dumps_function(picklable_vector_array)
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