Skip to content

Commit

Permalink
Some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
giadarol committed Mar 30, 2022
1 parent 680c4ad commit 59e8816
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/test_linked_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,30 @@ def asq(self):

b = m.a.copy()
assert np.all(ctx2np(m.a) == ctx2np(b))

m.a = np2ctx(np.array([4,-5,6]))
b = m.a.copy() + 3
assert np.all(ctx2np(m.a - b) == -3)
assert np.all(ctx2np(b - m.a) == 3)
assert np.all(ctx2np(m.a/(m.a*2)) == 0.5)
assert np.all(ctx2np(-m.a) == ctx2np(-10*m.a/10))

m.a = m.a*2
assert np.all(ctx2np(m.a) == np.array([8, -10, 12]))
assert np.all(ctx2np(m.asq) == np.array([64, 100, 144]))

m.a = np2ctx(np.array([4,-5,6]))
m.a *= 2
assert np.all(ctx2np(m.a) == np.array([8, -10, 12]))
assert np.all(ctx2np(m.asq) == np.array([64, 100, 144]))

m.a = np2ctx(np.array([1, 2, 3]))
m.a = m.a**2 +1
assert np.all(ctx2np(m.a) == np.array([2, 5, 10]))
assert np.all(ctx2np(m.asq) == np.array([4, 25, 100]))

if not(isinstance(context, xo.ContextPyopencl)): # masking not working
m.a = np2ctx(np.array([4,-5,6]))
m.a[m.a<0] += m.a[:1]
assert np.all(ctx2np(m.a) == np.array([4, -1, 6]))
assert np.all(ctx2np(m.asq) == np.array([16, 1, 36]))

0 comments on commit 59e8816

Please sign in to comment.