Skip to content

Commit 53188c3

Browse files
committed
python - add test t109
1 parent c86ac48 commit 53188c3

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

python/tests/test-1-vector.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,33 @@ def test_108(ceed_resource, capsys):
208208

209209
assert abs(norm - 9.) < TOL
210210

211+
# -------------------------------------------------------------------------------
212+
# Test set_array and take_array
213+
# -------------------------------------------------------------------------------
214+
215+
216+
def test_109(ceed_resource, capsys):
217+
ceed = libceed.Ceed(ceed_resource)
218+
219+
n = 10
220+
x = ceed.Vector(n)
221+
222+
a = np.arange(0, n, dtype=ceed.scalar_type())
223+
for i in range(n):
224+
a[i] = -3.14 if i == 3 else 0
225+
x.set_array(a, cmode=libceed.USE_POINTER)
226+
227+
# Verify correct array
228+
a = x.take_array()
229+
for i in range(n):
230+
assert abs(a[i] + (3.14 if i == 3 else 0)) < TOL
231+
232+
# And ensure access removed in Vector
233+
x.set_value(0)
234+
with x.array() as b:
235+
b[5] = 3.14
236+
assert abs(a[5]) < TOL
237+
211238
# -------------------------------------------------------------------------------
212239
# Test taking the reciprocal of a vector
213240
# -------------------------------------------------------------------------------

tests/t109-vector.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// @file
2-
/// Test CeedVectorSetArray to remove array access
3-
/// \test Test CeedVectorSetArray to remove array access
2+
/// Test CeedVectorTakeArray to remove array access
3+
/// \test Test CeedVectorTakeArray to remove array access
44
#include <ceed.h>
55
#include <math.h>
66
#include <stdio.h>

0 commit comments

Comments
 (0)