Skip to content

Commit cb37158

Browse files
committed
Add a test
1 parent c01bbd9 commit cb37158

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

symengine/tests/test_lambdify.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,3 +806,16 @@ def test_scipy():
806806
lmb = se.Lambdify(args, [se.exp(-x*t)/t**5], as_scipy=True)
807807
res = integrate.nquad(lmb, [[1, np.inf], [0, np.inf]])
808808
assert abs(res[0] - 0.2) < 1e-7
809+
810+
811+
@unittest.skipUnless(have_numpy, "Numpy not installed")
812+
def test_as_ctypes():
813+
import numpy as np
814+
import ctypes
815+
x, y, z = se.symbols('x, y, z')
816+
l = se.Lambdify([x, y, z], [x+y+z, x*y*z+1])
817+
addr1, addr2 = l.as_ctypes()
818+
inp = np.array([1,2,3], dtype=np.double)
819+
out = np.array([0, 0], dtype=np.double)
820+
addr1(out.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), inp.ctypes.data_as(ctypes.POINTER(ctypes.c_double)), addr2)
821+
assert np.all(out == [6, 7])

0 commit comments

Comments
 (0)