Beispiel #1
0
    lal.swig_lal_test_copyin_array1(numpy.array([0,0,0,0], dtype=numpy.double), 0)
    expected_exception = True
except:
    pass
assert(not expected_exception)
try:
    lal.swig_lal_test_copyin_array2(numpy.array([[1.2,3.4],[0,0],[0,0]], dtype=numpy.double), 0)
    expected_exception = True
except:
    pass
assert(not expected_exception)
print("PASSED fixed and dynamic arrays typemaps")

# check dynamic array of pointers access
print("checking dynamic array of pointers access ...")
ap = lal.swig_lal_test_Create_arrayofptrs(3)
assert(ap.length == 3)
for i in range(0, ap.length):
    assert(ap.data[i].length == 6)
    for j in range(0, ap.data[i].length):
        assert(ap.data[i].data[j] == 42*ap.length*i + j)
del ap
lal.CheckMemoryLeaks()
print("PASSED dynamic array of pointers access")

# check 'tm' struct conversions
print("checking 'tm' struct conversions ...")
gps = 989168284
utc = [2011, 5, 11, 16, 57, 49, 2, 131, 0]
assert(lal.GPSToUTC(gps) == utc)
assert(lal.UTCToGPS(utc) == gps)
r8inv.data = r8in
r8outv = lal.CreateREAL8Vector(len(r8in) // 2 + 1)
plan = lal.CreateForwardREAL8FFTPlan(len(r8in), 0)
lal.REAL8PowerSpectrum(r8outv, r8inv, plan)
r8out = numpy.zeros(numpy.shape(r8outv.data), dtype=r8outv.data.dtype)
lal.REAL8PowerSpectrum(r8out, r8in, plan)
assert ((r8out == r8outv.data).all())
del r8inv
del r8outv
del plan
lal.CheckMemoryLeaks()
print("PASSED FFT functions with input views ...")

# check dynamic array of pointers access
print("checking dynamic array of pointers access ...")
ap = lal.swig_lal_test_Create_arrayofptrs(3)
assert (ap.length == 3)
for i in range(0, ap.length):
    assert (ap.data[i].length == 6)
    for j in range(0, ap.data[i].length):
        assert (ap.data[i].data[j] == 42 * ap.length * i + j)
del ap
lal.CheckMemoryLeaks()
print("PASSED dynamic array of pointers access")

## check typemaps for strings and double pointers
print("checking typemaps for strings and double pointers ...")
sts = lal.swig_lal_test_struct()
ptr_ptr, ptr_null_ptr, null_ptr_ptr = lal.swig_lal_test_typemaps_string_ptrptr(
    "abcde", "", None, sts, 0, None)
assert (ptr_ptr == sts)