Unverified Commit 155fabb7 authored by René Fritze's avatar René Fritze Committed by GitHub
Browse files

Add vectorarray cow test (#1419)

This adds a test for copy on write of VectorArrays and increases the `max_examples` count to 20 in `dev` and `debug` sessions.

I stumbled upon broken COW functionality when binding a vector from an external PDE solver, and this was not catched by our tests.
parents b0aeb872 ffd8ace1
Pipeline #105981 failed with stages
in 22 seconds
......@@ -266,6 +266,29 @@ def test_copy(vectors_and_indices):
def test_COW(vectors_and_indices):
v, ind = vectors_and_indices
for deep in (True, False):
if ind is None:
c = v.copy(deep)
assert len(c) == len(v)
c = v[ind].copy(deep)
assert len(c) == v.len_ind(ind)
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]))
assert np.allclose(c.to_numpy(), 2*indexed(v.to_numpy(), ind))
except NotImplementedError:
def test_copy_repeated_index(vector_array):
v = vector_array
Supports Markdown
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