Unverified Commit e286d493 authored by René Fritze's avatar René Fritze
Browse files

[tests] tighten vecarray COW + add regression test case

closes #1472
parent 08ca794d
Pipeline #106628 passed with stages
in 42 minutes and 12 seconds
......@@ -6,11 +6,12 @@ from numbers import Number
import pytest
import numpy as np
from hypothesis import assume, settings
from hypothesis import assume, settings, example
from hypothesis import strategies as hyst
from pymor.algorithms.basic import almost_equal
from pymor.vectorarrays.interface import VectorSpace
from pymor.vectorarrays.numpy import NumpyVectorArray, NumpyVectorSpace
from pymor.tools import floatcmp
from pymor.tools.floatcmp import float_cmp
from pymortests.pickling import assert_picklable_without_dumps_function
......@@ -267,6 +268,7 @@ def test_copy(vectors_and_indices):
@example(vectors_and_indices=(NumpyVectorArray(np.array([[2.22044605e-16]]), NumpyVectorSpace(1)), [0]))
def test_COW(vectors_and_indices):
v, ind = vectors_and_indices
for deep in (True, False):
......@@ -279,10 +281,8 @@ def test_COW(vectors_and_indices):
assert c.space == v.space
if len(c) > 0 and not np.all(c.norm() == 0):
c *= 2
if ind is None:
assert not np.all(almost_equal(c, v))
assert not np.all(almost_equal(c, v[ind]))
vi = v[ind] if ind else v
assert not np.all(almost_equal(c, vi, atol=0, rtol=0))
assert np.allclose(c.to_numpy(), 2*indexed(v.to_numpy(), ind))
except NotImplementedError:
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