LAL  7.1.7.1-2d066e5
SWIGTestLALPython.py
Go to the documentation of this file.
1 # Check SWIG Python bindings for LAL
2 # Author: Karl Wette, 2011--2014
3 
4 import warnings
5 import datetime
6 import pickle
7 import numpy
8 expected_exception = False
9 
10 # return if 'x' has both value 'v' and type 't'
11 def is_value_and_type(x, v, t):
12  return x == v and type(x) is t
13 
14 # turn NumPy's ComplexWarning into an error, if available
15 if hasattr(numpy, "ComplexWarning"):
16  warnings.simplefilter("error", numpy.ComplexWarning)
17 
18 # check module load
19 print("checking module load ...")
20 import lal
21 from lal import globalvar as lalglobalvar
22 lal_c_si = lal.C_SI
23 lal_180_pi = lal.LAL_180_PI
24 print("PASSED module load")
25 
26 # check memory allocation
27 print("checking memory allocation ...")
28 if not lal.NoDebug:
29  lal.CheckMemoryLeaks()
30  mem1 = lal.Detector()
31  mem2 = lal.CreateCOMPLEX8Vector(5)
32  mem3 = lal.CreateREAL8Vector(3)
33  mem4 = lal.CreateREAL4TimeSeries("test", lal.LIGOTimeGPS(0), 100, 0.1, lal.DimensionlessUnit, 10)
34  print("*** below should be an error message from CheckMemoryLeaks() ***")
35  try:
36  lal.CheckMemoryLeaks()
37  expected_exception = True
38  except:
39  pass
40  assert not expected_exception
41  print("*** above should be an error message from CheckMemoryLeaks() ***")
42  del mem1
43  del mem2
44  del mem3
45  del mem4
46  lal.CheckMemoryLeaks()
47  print("PASSED memory allocation")
48 else:
49  print("skipped memory allocation")
50 
51 # check object parent tracking
52 print("checking object parent tracking ...")
53 a = lal.gsl_vector(3)
54 a.data = [1.1, 2.2, 3.3]
55 b = a.data
56 assert not b.flags['OWNDATA']
57 assert (b == [1.1, 2.2, 3.3]).all()
58 del a
59 assert (b == [1.1, 2.2, 3.3]).all()
60 ts = lal.CreateREAL8TimeSeries("test", lal.LIGOTimeGPS(0), 0, 0.1, lal.DimensionlessUnit, 10)
61 ts.data.data = list(range(0, 10))
62 for i in range(0, 7):
63  v = ts.data
64 assert (v.data == list(range(0, 10))).all()
65 del ts
66 assert (v.data == list(range(0, 10))).all()
67 del v
68 lal.CheckMemoryLeaks()
69 print("PASSED object parent tracking")
70 
71 # check equal return/first argument type handling
72 print("checking equal return/first argument type handling")
73 sv = lal.CreateStringVector("1")
74 assert sv.length == 1
75 lal.AppendString2Vector(sv, "2")
76 assert sv.length == 2
77 sv = lal.AppendString2Vector(sv, "3")
78 assert sv.length == 3
79 sv2 = lal.AppendString2Vector(sv, "4")
80 assert sv.length == 4
81 assert sv2.length == 4
82 assert sv == sv2
83 del sv
84 del sv2
85 lal.CheckMemoryLeaks()
86 ts = lal.CreateREAL8TimeSeries("ts", 800000000, 100, 0.1, lal.HertzUnit, 10)
87 assert ts.data.length == 10
88 lal.ResizeREAL8TimeSeries(ts, 0, 20)
89 assert ts.data.length == 20
90 ts = lal.ResizeREAL8TimeSeries(ts, 0, 30)
91 assert ts.data.length == 30
92 ts2 = lal.ResizeREAL8TimeSeries(ts, 0, 40)
93 assert ts.data.length == 40
94 assert ts2.data.length == 40
95 assert ts == ts2
96 del ts
97 del ts2
98 lal.CheckMemoryLeaks()
99 print("PASSED equal return/first argument type handling")
100 
101 # check string conversions
102 print("checking string conversions ...")
103 strs = ["a", "bc", "def"]
104 sv = lal.CreateStringVector(*strs)
105 assert sv.length == 3
106 assert (sv.data.astype(numpy.object) == strs).all()
107 strs[0] = "ghijk"
108 sv.data[0] = strs[0]
109 strs.append("lmnopq")
110 sv = lal.AppendString2Vector(sv, strs[3])
111 assert sv.length == 4
112 for i in range(0, 4):
113  assert sv.data[i] == strs[i]
114 del sv
115 lal.CheckMemoryLeaks()
116 print("PASSED string conversions")
117 
118 # check static vector/matrix conversions
119 print("checking static vector/matrix conversions ...")
120 lalglobalvar.swig_lal_test_struct_vector[0] = lalglobalvar.swig_lal_test_struct_const
121 assert lalglobalvar.swig_lal_test_struct_vector[0].n == lalglobalvar.swig_lal_test_struct_const.n
122 assert lalglobalvar.swig_lal_test_struct_vector[0].i == lalglobalvar.swig_lal_test_struct_const.i
123 assert lalglobalvar.swig_lal_test_struct_vector[0].f == lalglobalvar.swig_lal_test_struct_const.f
124 assert lalglobalvar.swig_lal_test_struct_vector[0].str == lalglobalvar.swig_lal_test_struct_const.str
125 assert (lalglobalvar.swig_lal_test_struct_vector[0].vec == lalglobalvar.swig_lal_test_struct_const.vec).all()
126 lalglobalvar.swig_lal_test_struct_matrix[0, 0] = lalglobalvar.swig_lal_test_struct_const
127 assert lalglobalvar.swig_lal_test_struct_matrix[0, 0].n == lalglobalvar.swig_lal_test_struct_const.n
128 assert lalglobalvar.swig_lal_test_struct_matrix[0, 0].i == lalglobalvar.swig_lal_test_struct_const.i
129 assert lalglobalvar.swig_lal_test_struct_matrix[0, 0].f == lalglobalvar.swig_lal_test_struct_const.f
130 assert lalglobalvar.swig_lal_test_struct_matrix[0, 0].str == lalglobalvar.swig_lal_test_struct_const.str
131 assert (lalglobalvar.swig_lal_test_struct_matrix[0, 0].vec == lalglobalvar.swig_lal_test_struct_const.vec).all()
132 sts = lal.swig_lal_test_struct()
133 assert len(sts.vec) == 3
134 assert len(sts.evec) == 3
135 assert sts.mat.shape == (2, 3)
136 sts.vec = [3, 2, 1]
137 assert (sts.vec == [3, 2, 1]).all()
138 sts.mat = [[4, 5, 6], (9, 8, 7)]
139 try:
140  sts.mat = [[1.1, 2.3, 4.5], [6.5, 4.3, 2.1]]
141  expected_exception = True
142 except:
143  pass
144 assert not expected_exception
145 assert (sts.mat == [[4, 5, 6], [9, 8, 7]]).all()
146 for i in range(0, 3):
147  sts.evec[i] = 2*i + 3
148  assert sts.evec[i] == (2*i + 3)
149 del sts
150 assert not lalglobalvar.swig_lal_test_enum_vector.any()
151 assert not lalglobalvar.swig_lal_test_enum_matrix.any()
152 assert len(lalglobalvar.swig_lal_test_empty_INT4_vector) == 0
153 assert not lalglobalvar.swig_lal_test_INT4_vector.any()
154 assert not lalglobalvar.swig_lal_test_INT4_matrix.any()
155 assert not lalglobalvar.swig_lal_test_REAL8_vector.any()
156 assert not lalglobalvar.swig_lal_test_REAL8_matrix.any()
157 assert not lalglobalvar.swig_lal_test_COMPLEX8_vector.any()
158 assert not lalglobalvar.swig_lal_test_COMPLEX8_matrix.any()
159 lalglobalvar.swig_lal_test_INT4_vector[0] = 10
160 assert lalglobalvar.swig_lal_test_INT4_vector[0] == 10
161 lalglobalvar.swig_lal_test_INT4_matrix[0, 0] = 11
162 assert lalglobalvar.swig_lal_test_INT4_matrix[0, 0] == 11
163 lalglobalvar.swig_lal_test_INT4_vector = lalglobalvar.swig_lal_test_INT4_const_vector
164 assert (lalglobalvar.swig_lal_test_INT4_vector == [1, 2, 4]).all()
165 assert lalglobalvar.swig_lal_test_INT4_const_vector[2] == 4
166 lalglobalvar.swig_lal_test_INT4_matrix = lalglobalvar.swig_lal_test_INT4_const_matrix
167 assert (lalglobalvar.swig_lal_test_INT4_matrix == [[1, 2, 4], [2, 4, 8]]).all()
168 assert lalglobalvar.swig_lal_test_INT4_const_matrix[1, 2] == 8
169 try:
170  lalglobalvar.swig_lal_test_INT4_const_vector(20)
171  expected_exception = True
172 except:
173  pass
174 assert not expected_exception
175 lalglobalvar.swig_lal_test_REAL8_vector[0] = 3.4
176 assert lalglobalvar.swig_lal_test_REAL8_vector[0] == 3.4
177 lalglobalvar.swig_lal_test_REAL8_matrix[0, 0] = 5.6
178 assert lalglobalvar.swig_lal_test_REAL8_matrix[0, 0] == 5.6
179 lalglobalvar.swig_lal_test_COMPLEX8_vector[0] = complex(3.5, 4.75)
180 assert lalglobalvar.swig_lal_test_COMPLEX8_vector[0] == complex(3.5, 4.75)
181 lalglobalvar.swig_lal_test_COMPLEX8_matrix[0, 0] = complex(5.5, 6.25)
182 assert lalglobalvar.swig_lal_test_COMPLEX8_matrix[0, 0] == complex(5.5, 6.25)
183 print("PASSED static vector/matrix conversions")
184 
185 # check dynamic vector/matrix conversions
186 print("checking dynamic vector/matrix conversions ...")
187 def check_dynamic_vector_matrix(iv, ivl, rv, rvl, cm, cms1, cms2):
188  expected_exception = False
189  iv.data = numpy.zeros(ivl, dtype=iv.data.dtype)
190  rv.data = numpy.zeros(rvl, dtype=rv.data.dtype)
191  cm.data = numpy.zeros((cms1, cms2), dtype=cm.data.dtype)
192  assert ivl == 5
193  iv.data = [1, 3, 2, 4, 3]
194  assert (iv.data == [1, 3, 2, 4, 3]).all()
195  iv.data[3] = 7
196  assert iv.data[3] == 7
197  assert rvl == 5
198  rv.data = [1.2, 3.4, 2.6, 4.8, 3.5]
199  assert (rv.data == [1.2, 3.4, 2.6, 4.8, 3.5]).all()
200  rv.data[rvl - 1] = 7.5
201  assert rv.data[rvl - 1] == 7.5
202  try:
203  rv.data[rvl] = 99.9
204  expected_exception = True
205  except:
206  pass
207  assert not expected_exception
208  try:
209  iv.data = rv.data
210  expected_exception = True
211  except:
212  pass
213  assert not expected_exception
214  rv.data = iv.data
215  assert (rv.data == iv.data).all()
216  assert cms1 == 4
217  assert cms2 == 6
218  for i in range(0, cms1):
219  for j in range(0, cms2):
220  cm.data[i, j] = complex(i / 4.0, j / 2.0)
221  assert cm.data[2, 3] == complex(0.5, 1.5)
222  assert cm.data[3, 2] == complex(0.75, 1.0)
223  try:
224  iv.data[0] = cm.data[2, 3]
225  if not hasattr(numpy, "ComplexWarning"):
226  raise Exception("NumPy %s does not have ComplexWarning" % numpy.__version__)
227  expected_exception = True
228  except:
229  pass
230  assert not expected_exception
231  try:
232  rv.data[0] = cm.data[3, 2]
233  if not hasattr(numpy, "ComplexWarning"):
234  raise Exception("NumPy %s does not have ComplexWarning" % numpy.__version__)
235  expected_exception = True
236  except:
237  pass
238  assert not expected_exception
239 # check LAL vector and matrix datatypes
240 iv = lal.CreateINT4Vector(5)
241 rv = lal.CreateREAL8Vector(5)
242 cm = lal.CreateCOMPLEX8VectorSequence(4, 6)
243 check_dynamic_vector_matrix(iv, iv.length, rv, rv.length,
244  cm, cm.length, cm.vectorLength)
245 del iv
246 del rv
247 del cm
248 rv0 = lal.CreateREAL8Vector(0)
249 assert rv0.length == 0
250 assert rv0.data is None
251 del rv0
252 rv1 = lal.CreateREAL8Vector(1)
253 rv1.data[0] = 1
254 del rv1
255 lal.CheckMemoryLeaks()
256 print("PASSED dynamic vector/matrix conversions (LAL)")
257 # check GSL vectors and matrices
258 iv = lal.gsl_vector_int(5)
259 rv = lal.gsl_vector(5)
260 cm = lal.gsl_matrix_complex_float(4, 6)
261 check_dynamic_vector_matrix(iv, iv.size, rv, rv.size,
262  cm, cm.size1, cm.size2)
263 del iv
264 del rv
265 del cm
266 rv1 = lal.gsl_vector(1)
267 rv1.data[0] = 1
268 del rv1
269 print("PASSED dynamic vector/matrix conversions (GSL)")
270 
271 # check fixed and dynamic arrays typemaps
272 print("checking fixed and dynamic arrays typemaps ...")
273 a1in = numpy.array([1.2, 3.5, 7.9], dtype=numpy.double)
274 a1out = a1in * 2.5
275 assert (lal.swig_lal_test_copyin_array1(a1in, 2.5) == a1out).all()
276 a2in = numpy.array([[3,2], [7,6], [12,10]], dtype=numpy.int32)
277 a2out = a2in * 15
278 assert (lal.swig_lal_test_copyin_array2(a2in, 15) == a2out).all()
279 a3in = numpy.array([lal.LIGOTimeGPS(1234.5), lal.LIGOTimeGPS(678.9)])
280 a3out = a3in * 3
281 assert (lal.swig_lal_test_copyin_array3(a3in, 3) == a3out).all()
282 try:
283  lal.swig_lal_test_copyin_array1(numpy.array([0,0,0,0], dtype=numpy.double), 0)
284  expected_exception = True
285 except:
286  pass
287 assert not expected_exception
288 try:
289  lal.swig_lal_test_copyin_array2(numpy.array([[1.2,3.4],[0,0],[0,0]], dtype=numpy.double), 0)
290  expected_exception = True
291 except:
292  pass
293 assert not expected_exception
294 del a3in
295 del a3out
296 lal.CheckMemoryLeaks()
297 print("PASSED fixed and dynamic arrays typemaps")
298 
299 ## check input views of string array structs
300 print("checking input views of string array structs ...")
301 svdat = ["a", "bc", "def"]
302 sv = lal.CreateEmptyStringVector(len(svdat))
303 sv.data = svdat;
304 svout = lal.CreateEmptyStringVector(len(svdat));
305 svout.data = [""] * len(svdat)
306 assert lal.swig_lal_test_viewin_LALStringVector(svout, sv)
307 assert all(map(lambda x, y: x == y, svout.data, sv.data))
308 svout.data = [""] * len(svdat)
309 assert lal.swig_lal_test_viewin_LALStringVector(svout, svdat)
310 assert all(map(lambda x, y: x == y, svout.data, svdat))
311 sv.data = svdat
312 assert lal.swig_lal_test_copyinout_LALStringVector(sv)
313 assert all(map(lambda x, y: x == y.upper(), sv.data, svdat))
314 sv.data = svdat
315 retn, sv = lal.swig_lal_test_copyinout_LALStringVector(sv)
316 assert retn
317 assert all(map(lambda x, y: x == y.upper(), sv.data, svdat))
318 sv = svdat
319 retn, sv = lal.swig_lal_test_copyinout_LALStringVector(sv)
320 assert retn
321 assert all(map(lambda x, y: x == y.upper(), sv, svdat))
322 del sv
323 del svout
324 del svdat
325 lal.CheckMemoryLeaks()
326 print("PASSED input views of string array structs")
327 
328 ## check input views of numeric array structs
329 print("checking input views of numeric array structs ...")
330 r4dat = numpy.array([1.2, 2.3, 3.4, 4.5, 5.6], dtype=numpy.float32)
331 r8dat = numpy.array([3.4, 4.5, 5.6, 6.7, 7.8, 8.9], dtype=numpy.float64)
332 c8dat = numpy.array(numpy.vectorize(complex)(r4dat, 8 + r4dat), dtype=numpy.complex64)
333 c16dat = numpy.array(numpy.vectorize(complex)(r8dat, 16 + r8dat), dtype=numpy.complex128)
334 r4 = lal.CreateREAL4Vector(len(r4dat))
335 r4.data = r4dat
336 r4out = lal.CreateREAL4Vector(len(r4dat))
337 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
338 assert lal.swig_lal_test_viewin_REAL4Vector(r4out, r4)
339 assert (r4out.data == r4.data).all()
340 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
341 assert lal.swig_lal_test_viewin_REAL4Vector(r4out, r4dat)
342 assert (r4out.data == r4dat).all()
343 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
344 assert lal.swig_lal_test_viewinout_REAL4Vector(r4out, r4)
345 assert (2 * r4out.data == r4.data).all()
346 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
347 assert lal.swig_lal_test_viewinout_REAL4Vector(r4out, r4dat)
348 assert (2 * r4out.data == r4dat).all()
349 r4.data = r4dat
350 assert lal.swig_lal_test_copyinout_REAL4Vector(r4)
351 assert (r4.data == 3 * r4dat).all()
352 r4.data = r4dat
353 retn, r4 = lal.swig_lal_test_copyinout_REAL4Vector(r4)
354 assert retn
355 assert (r4.data == 3 * r4dat).all()
356 r4 = r4dat
357 retn, r4 = lal.swig_lal_test_copyinout_REAL4Vector(r4)
358 assert retn
359 assert (r4 == 3 * r4dat).all()
360 del r4
361 del r4out
362 del r4dat
363 lal.CheckMemoryLeaks()
364 r8 = lal.CreateREAL8Vector(len(r8dat))
365 r8.data = r8dat
366 r8out = lal.CreateREAL8Vector(len(r8dat))
367 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
368 assert lal.swig_lal_test_viewin_REAL8Vector(r8out, r8)
369 assert (r8out.data == r8.data).all()
370 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
371 assert lal.swig_lal_test_viewin_REAL8Vector(r8out, r8dat)
372 assert (r8out.data == r8dat).all()
373 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
374 assert lal.swig_lal_test_viewinout_REAL8Vector(r8out, r8)
375 assert (2 * r8out.data == r8.data).all()
376 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
377 assert lal.swig_lal_test_viewinout_REAL8Vector(r8out, r8dat)
378 assert (2 * r8out.data == r8dat).all()
379 r8.data = r8dat
380 assert lal.swig_lal_test_copyinout_REAL8Vector(r8)
381 assert (r8.data == 3 * r8dat).all()
382 r8.data = r8dat
383 retn, r8 = lal.swig_lal_test_copyinout_REAL8Vector(r8)
384 assert retn
385 assert (r8.data == 3 * r8dat).all()
386 r8 = r8dat
387 retn, r8 = lal.swig_lal_test_copyinout_REAL8Vector(r8)
388 assert retn
389 assert (r8 == 3 * r8dat).all()
390 del r8
391 del r8out
392 del r8dat
393 lal.CheckMemoryLeaks()
394 c8 = lal.CreateCOMPLEX8Vector(len(c8dat))
395 c8.data = c8dat
396 c8out = lal.CreateCOMPLEX8Vector(len(c8dat))
397 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
398 assert lal.swig_lal_test_viewin_COMPLEX8Vector(c8out, c8)
399 assert (c8out.data == c8.data).all()
400 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
401 assert lal.swig_lal_test_viewin_COMPLEX8Vector(c8out, c8dat)
402 assert (c8out.data == c8dat).all()
403 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
404 assert lal.swig_lal_test_viewinout_COMPLEX8Vector(c8out, c8)
405 assert (2 * c8out.data == c8.data).all()
406 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
407 assert lal.swig_lal_test_viewinout_COMPLEX8Vector(c8out, c8dat)
408 assert (2 * c8out.data == c8dat).all()
409 c8.data = c8dat
410 assert lal.swig_lal_test_copyinout_COMPLEX8Vector(c8)
411 assert (c8.data == 3 * c8dat).all()
412 c8.data = c8dat
413 retn, c8 = lal.swig_lal_test_copyinout_COMPLEX8Vector(c8)
414 assert retn
415 assert (c8.data == 3 * c8dat).all()
416 c8 = c8dat
417 retn, c8 = lal.swig_lal_test_copyinout_COMPLEX8Vector(c8)
418 assert retn
419 assert (c8 == 3 * c8dat).all()
420 del c8
421 del c8out
422 del c8dat
423 lal.CheckMemoryLeaks()
424 c16 = lal.CreateCOMPLEX16Vector(len(c16dat))
425 c16.data = c16dat
426 c16out = lal.CreateCOMPLEX16Vector(len(c16dat))
427 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
428 assert lal.swig_lal_test_viewin_COMPLEX16Vector(c16out, c16)
429 assert (c16out.data == c16.data).all()
430 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
431 assert lal.swig_lal_test_viewin_COMPLEX16Vector(c16out, c16dat)
432 assert (c16out.data == c16dat).all()
433 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
434 assert lal.swig_lal_test_viewinout_COMPLEX16Vector(c16out, c16)
435 assert (2 * c16out.data == c16.data).all()
436 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
437 assert lal.swig_lal_test_viewinout_COMPLEX16Vector(c16out, c16dat)
438 assert (2 * c16out.data == c16dat).all()
439 c16.data = c16dat
440 assert lal.swig_lal_test_copyinout_COMPLEX16Vector(c16)
441 assert (c16.data == 3 * c16dat).all()
442 c16.data = c16dat
443 retn, c16 = lal.swig_lal_test_copyinout_COMPLEX16Vector(c16)
444 assert retn
445 assert (c16.data == 3 * c16dat).all()
446 c16 = c16dat
447 retn, c16 = lal.swig_lal_test_copyinout_COMPLEX16Vector(c16)
448 assert retn
449 assert (c16 == 3 * c16dat).all()
450 del c16
451 del c16out
452 del c16dat
453 lal.CheckMemoryLeaks()
454 r4dat = numpy.array([[1.2, 2.3, 3.4], [4.5, 5.6, 6.7]], dtype=numpy.float32)
455 r8dat = numpy.array([[3.4, 4.5], [5.6, 6.7], [7.8, 8.9]], dtype=numpy.float64)
456 c8dat = numpy.array(numpy.vectorize(complex)(r4dat, 8 + r4dat), dtype=numpy.complex64)
457 c16dat = numpy.array(numpy.vectorize(complex)(r8dat, 16 + r8dat), dtype=numpy.complex128)
458 r4 = lal.CreateREAL4VectorSequence(r4dat.shape[0], r4dat.shape[1])
459 r4.data = r4dat
460 r4out = lal.CreateREAL4VectorSequence(r4dat.shape[0], r4dat.shape[1])
461 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
462 assert lal.swig_lal_test_viewin_REAL4VectorSequence(r4out, r4)
463 assert (r4out.data == r4.data).all()
464 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
465 assert lal.swig_lal_test_viewin_REAL4VectorSequence(r4out, r4dat)
466 assert (r4out.data == r4dat).all()
467 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
468 assert lal.swig_lal_test_viewinout_REAL4VectorSequence(r4out, r4)
469 assert (2 * r4out.data == r4.data).all()
470 r4out.data = numpy.zeros(numpy.shape(r4dat), dtype=r4dat.dtype)
471 assert lal.swig_lal_test_viewinout_REAL4VectorSequence(r4out, r4dat)
472 assert (2 * r4out.data == r4dat).all()
473 r4.data = r4dat
474 assert lal.swig_lal_test_copyinout_REAL4VectorSequence(r4)
475 assert (r4.data == 3 * r4dat).all()
476 r4.data = r4dat
477 retn, r4 = lal.swig_lal_test_copyinout_REAL4VectorSequence(r4)
478 assert retn
479 assert (r4.data == 3 * r4dat).all()
480 r4 = r4dat
481 retn, r4 = lal.swig_lal_test_copyinout_REAL4VectorSequence(r4)
482 assert retn
483 assert (r4 == 3 * r4dat).all()
484 del r4
485 del r4out
486 del r4dat
487 lal.CheckMemoryLeaks()
488 r8 = lal.CreateREAL8VectorSequence(r8dat.shape[0], r8dat.shape[1])
489 r8.data = r8dat
490 r8out = lal.CreateREAL8VectorSequence(r8dat.shape[0], r8dat.shape[1])
491 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
492 assert lal.swig_lal_test_viewin_REAL8VectorSequence(r8out, r8)
493 assert (r8out.data == r8.data).all()
494 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
495 assert lal.swig_lal_test_viewin_REAL8VectorSequence(r8out, r8dat)
496 assert (r8out.data == r8dat).all()
497 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
498 assert lal.swig_lal_test_viewinout_REAL8VectorSequence(r8out, r8)
499 assert (2 * r8out.data == r8.data).all()
500 r8out.data = numpy.zeros(numpy.shape(r8dat), dtype=r8dat.dtype)
501 assert lal.swig_lal_test_viewinout_REAL8VectorSequence(r8out, r8dat)
502 assert (2 * r8out.data == r8dat).all()
503 r8.data = r8dat
504 assert lal.swig_lal_test_copyinout_REAL8VectorSequence(r8)
505 assert (r8.data == 3 * r8dat).all()
506 r8.data = r8dat
507 retn, r8 = lal.swig_lal_test_copyinout_REAL8VectorSequence(r8)
508 assert retn
509 assert (r8.data == 3 * r8dat).all()
510 r8 = r8dat
511 retn, r8 = lal.swig_lal_test_copyinout_REAL8VectorSequence(r8)
512 assert retn
513 assert (r8 == 3 * r8dat).all()
514 del r8
515 del r8out
516 del r8dat
517 lal.CheckMemoryLeaks()
518 c8 = lal.CreateCOMPLEX8VectorSequence(c8dat.shape[0], c8dat.shape[1])
519 c8.data = c8dat
520 c8out = lal.CreateCOMPLEX8VectorSequence(c8dat.shape[0], c8dat.shape[1])
521 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
522 assert lal.swig_lal_test_viewin_COMPLEX8VectorSequence(c8out, c8)
523 assert (c8out.data == c8.data).all()
524 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
525 assert lal.swig_lal_test_viewin_COMPLEX8VectorSequence(c8out, c8dat)
526 assert (c8out.data == c8dat).all()
527 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
528 assert lal.swig_lal_test_viewinout_COMPLEX8VectorSequence(c8out, c8)
529 assert (2 * c8out.data == c8.data).all()
530 c8out.data = numpy.zeros(numpy.shape(c8dat), dtype=c8dat.dtype)
531 assert lal.swig_lal_test_viewinout_COMPLEX8VectorSequence(c8out, c8dat)
532 assert (2 * c8out.data == c8dat).all()
533 c8.data = c8dat
534 assert lal.swig_lal_test_copyinout_COMPLEX8VectorSequence(c8)
535 assert (c8.data == 3 * c8dat).all()
536 c8.data = c8dat
537 retn, c8 = lal.swig_lal_test_copyinout_COMPLEX8VectorSequence(c8)
538 assert retn
539 assert (c8.data == 3 * c8dat).all()
540 c8 = c8dat
541 retn, c8 = lal.swig_lal_test_copyinout_COMPLEX8VectorSequence(c8)
542 assert retn
543 assert (c8 == 3 * c8dat).all()
544 del c8
545 del c8out
546 del c8dat
547 lal.CheckMemoryLeaks()
548 c16 = lal.CreateCOMPLEX16VectorSequence(c16dat.shape[0], c16dat.shape[1])
549 c16.data = c16dat
550 c16out = lal.CreateCOMPLEX16VectorSequence(c16dat.shape[0], c16dat.shape[1])
551 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
552 assert lal.swig_lal_test_viewin_COMPLEX16VectorSequence(c16out, c16)
553 assert (c16out.data == c16.data).all()
554 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
555 assert lal.swig_lal_test_viewin_COMPLEX16VectorSequence(c16out, c16dat)
556 assert (c16out.data == c16dat).all()
557 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
558 assert lal.swig_lal_test_viewinout_COMPLEX16VectorSequence(c16out, c16)
559 assert (2 * c16out.data == c16.data).all()
560 c16out.data = numpy.zeros(numpy.shape(c16dat), dtype=c16dat.dtype)
561 assert lal.swig_lal_test_viewinout_COMPLEX16VectorSequence(c16out, c16dat)
562 assert (2 * c16out.data == c16dat).all()
563 c16.data = c16dat
564 assert lal.swig_lal_test_copyinout_COMPLEX16VectorSequence(c16)
565 assert (c16.data == 3 * c16dat).all()
566 c16.data = c16dat
567 retn, c16 = lal.swig_lal_test_copyinout_COMPLEX16VectorSequence(c16)
568 assert retn
569 assert (c16.data == 3 * c16dat).all()
570 c16 = c16dat
571 retn, c16 = lal.swig_lal_test_copyinout_COMPLEX16VectorSequence(c16)
572 assert retn
573 assert (c16 == 3 * c16dat).all()
574 del c16
575 del c16out
576 del c16dat
577 lal.CheckMemoryLeaks()
578 print("PASSED input views of numeric array structs (LAL)")
579 vfdat = numpy.array([1.2, 2.3, 3.4, 4.5, 5.6], dtype=numpy.float32)
580 vddat = numpy.array([3.4, 4.5, 5.6, 6.7, 7.8, 8.9], dtype=numpy.float64)
581 vcfdat = numpy.array(numpy.vectorize(complex)(vfdat, 8 + vfdat), dtype=numpy.complex64)
582 vcddat = numpy.array(numpy.vectorize(complex)(vddat, 16 + vddat), dtype=numpy.complex128)
583 vf = lal.gsl_vector_float(len(vfdat))
584 vf.data = vfdat
585 vfout = lal.gsl_vector_float(len(vfdat))
586 vfout.data = numpy.zeros(numpy.shape(vfdat), dtype=vfdat.dtype)
587 assert lal.swig_lal_test_viewin_gsl_vector_float(vfout, vf)
588 assert (vfout.data == vf.data).all()
589 vfout.data = numpy.zeros(numpy.shape(vfdat), dtype=vfdat.dtype)
590 assert lal.swig_lal_test_viewin_gsl_vector_float(vfout, vfdat)
591 assert (vfout.data == vfdat).all()
592 vfout.data = numpy.zeros(numpy.shape(vfdat), dtype=vfdat.dtype)
593 assert lal.swig_lal_test_viewinout_gsl_vector_float(vfout, vf)
594 assert (2 * vfout.data == vf.data).all()
595 vfout.data = numpy.zeros(numpy.shape(vfdat), dtype=vfdat.dtype)
596 assert lal.swig_lal_test_viewinout_gsl_vector_float(vfout, vfdat)
597 assert (2 * vfout.data == vfdat).all()
598 vf.data = vfdat
599 assert lal.swig_lal_test_copyinout_gsl_vector_float(vf)
600 assert (vf.data == 3 * vfdat).all()
601 vf.data = vfdat
602 retn, vf = lal.swig_lal_test_copyinout_gsl_vector_float(vf)
603 assert retn
604 assert (vf.data == 3 * vfdat).all()
605 vf = vfdat
606 retn, vf = lal.swig_lal_test_copyinout_gsl_vector_float(vf)
607 assert retn
608 assert (vf == 3 * vfdat).all()
609 del vf
610 del vfout
611 del vfdat
612 lal.CheckMemoryLeaks()
613 vd = lal.gsl_vector(len(vddat))
614 vd.data = vddat
615 vdout = lal.gsl_vector(len(vddat))
616 vdout.data = numpy.zeros(numpy.shape(vddat), dtype=vddat.dtype)
617 assert lal.swig_lal_test_viewin_gsl_vector(vdout, vd)
618 assert (vdout.data == vd.data).all()
619 vdout.data = numpy.zeros(numpy.shape(vddat), dtype=vddat.dtype)
620 assert lal.swig_lal_test_viewin_gsl_vector(vdout, vddat)
621 assert (vdout.data == vddat).all()
622 vdout.data = numpy.zeros(numpy.shape(vddat), dtype=vddat.dtype)
623 assert lal.swig_lal_test_viewinout_gsl_vector(vdout, vd)
624 assert (2 * vdout.data == vd.data).all()
625 vdout.data = numpy.zeros(numpy.shape(vddat), dtype=vddat.dtype)
626 assert lal.swig_lal_test_viewinout_gsl_vector(vdout, vddat)
627 assert (2 * vdout.data == vddat).all()
628 vd.data = vddat
629 assert lal.swig_lal_test_copyinout_gsl_vector(vd)
630 assert (vd.data == 3 * vddat).all()
631 vd.data = vddat
632 retn, vd = lal.swig_lal_test_copyinout_gsl_vector(vd)
633 assert retn
634 assert (vd.data == 3 * vddat).all()
635 vd = vddat
636 retn, vd = lal.swig_lal_test_copyinout_gsl_vector(vd)
637 assert retn
638 assert (vd == 3 * vddat).all()
639 del vd
640 del vdout
641 del vddat
642 lal.CheckMemoryLeaks()
643 vcf = lal.gsl_vector_complex_float(len(vcfdat))
644 vcf.data = vcfdat
645 vcfout = lal.gsl_vector_complex_float(len(vcfdat))
646 vcfout.data = numpy.zeros(numpy.shape(vcfdat), dtype=vcfdat.dtype)
647 assert lal.swig_lal_test_viewin_gsl_vector_complex_float(vcfout, vcf)
648 assert (vcfout.data == vcf.data).all()
649 vcfout.data = numpy.zeros(numpy.shape(vcfdat), dtype=vcfdat.dtype)
650 assert lal.swig_lal_test_viewin_gsl_vector_complex_float(vcfout, vcfdat)
651 assert (vcfout.data == vcfdat).all()
652 vcfout.data = numpy.zeros(numpy.shape(vcfdat), dtype=vcfdat.dtype)
653 assert lal.swig_lal_test_viewinout_gsl_vector_complex_float(vcfout, vcf)
654 assert (2 * vcfout.data == vcf.data).all()
655 vcfout.data = numpy.zeros(numpy.shape(vcfdat), dtype=vcfdat.dtype)
656 assert lal.swig_lal_test_viewinout_gsl_vector_complex_float(vcfout, vcfdat)
657 assert (2 * vcfout.data == vcfdat).all()
658 vcf.data = vcfdat
659 assert lal.swig_lal_test_copyinout_gsl_vector_complex_float(vcf)
660 assert (vcf.data == 3 * vcfdat).all()
661 vcf.data = vcfdat
662 retn, vcf = lal.swig_lal_test_copyinout_gsl_vector_complex_float(vcf)
663 assert retn
664 assert (vcf.data == 3 * vcfdat).all()
665 vcf = vcfdat
666 retn, vcf = lal.swig_lal_test_copyinout_gsl_vector_complex_float(vcf)
667 assert retn
668 assert (vcf == 3 * vcfdat).all()
669 del vcf
670 del vcfout
671 del vcfdat
672 lal.CheckMemoryLeaks()
673 vcd = lal.gsl_vector_complex(len(vcddat))
674 vcd.data = vcddat
675 vcdout = lal.gsl_vector_complex(len(vcddat))
676 vcdout.data = numpy.zeros(numpy.shape(vcddat), dtype=vcddat.dtype)
677 assert lal.swig_lal_test_viewin_gsl_vector_complex(vcdout, vcd)
678 assert (vcdout.data == vcd.data).all()
679 vcdout.data = numpy.zeros(numpy.shape(vcddat), dtype=vcddat.dtype)
680 assert lal.swig_lal_test_viewin_gsl_vector_complex(vcdout, vcddat)
681 assert (vcdout.data == vcddat).all()
682 vcdout.data = numpy.zeros(numpy.shape(vcddat), dtype=vcddat.dtype)
683 assert lal.swig_lal_test_viewinout_gsl_vector_complex(vcdout, vcd)
684 assert (2 * vcdout.data == vcd.data).all()
685 vcdout.data = numpy.zeros(numpy.shape(vcddat), dtype=vcddat.dtype)
686 assert lal.swig_lal_test_viewinout_gsl_vector_complex(vcdout, vcddat)
687 assert (2 * vcdout.data == vcddat).all()
688 vcd.data = vcddat
689 assert lal.swig_lal_test_copyinout_gsl_vector_complex(vcd)
690 assert (vcd.data == 3 * vcddat).all()
691 vcd.data = vcddat
692 retn, vcd = lal.swig_lal_test_copyinout_gsl_vector_complex(vcd)
693 assert retn
694 assert (vcd.data == 3 * vcddat).all()
695 vcd = vcddat
696 retn, vcd = lal.swig_lal_test_copyinout_gsl_vector_complex(vcd)
697 assert retn
698 assert (vcd == 3 * vcddat).all()
699 del vcd
700 del vcdout
701 del vcddat
702 lal.CheckMemoryLeaks()
703 mfdat = numpy.array([[1.2, 2.3, 3.4], [4.5, 5.6, 6.7]], dtype=numpy.float32)
704 mddat = numpy.array([[3.4, 4.5], [5.6, 6.7], [7.8, 8.9]], dtype=numpy.float64)
705 mcfdat = numpy.array(numpy.vectorize(complex)(mfdat, 8 + mfdat), dtype=numpy.complex64)
706 mcddat = numpy.array(numpy.vectorize(complex)(mddat, 16 + mddat), dtype=numpy.complex128)
707 mf = lal.gsl_matrix_float(mfdat.shape[0], mfdat.shape[1])
708 mf.data = mfdat
709 mfout = lal.gsl_matrix_float(mfdat.shape[0], mfdat.shape[1])
710 mfout.data = numpy.zeros(numpy.shape(mfdat), dtype=mfdat.dtype)
711 assert lal.swig_lal_test_viewin_gsl_matrix_float(mfout, mf)
712 assert (mfout.data == mf.data).all()
713 mfout.data = numpy.zeros(numpy.shape(mfdat), dtype=mfdat.dtype)
714 assert lal.swig_lal_test_viewin_gsl_matrix_float(mfout, mfdat)
715 assert (mfout.data == mfdat).all()
716 mfout.data = numpy.zeros(numpy.shape(mfdat), dtype=mfdat.dtype)
717 assert lal.swig_lal_test_viewinout_gsl_matrix_float(mfout, mf)
718 assert (2 * mfout.data == mf.data).all()
719 mfout.data = numpy.zeros(numpy.shape(mfdat), dtype=mfdat.dtype)
720 assert lal.swig_lal_test_viewinout_gsl_matrix_float(mfout, mfdat)
721 assert (2 * mfout.data == mfdat).all()
722 mf.data = mfdat
723 assert lal.swig_lal_test_copyinout_gsl_matrix_float(mf)
724 assert (mf.data == 3 * mfdat).all()
725 mf.data = mfdat
726 retn, mf = lal.swig_lal_test_copyinout_gsl_matrix_float(mf)
727 assert retn
728 assert (mf.data == 3 * mfdat).all()
729 mf = mfdat
730 retn, mf = lal.swig_lal_test_copyinout_gsl_matrix_float(mf)
731 assert retn
732 assert (mf == 3 * mfdat).all()
733 del mf
734 del mfout
735 del mfdat
736 lal.CheckMemoryLeaks()
737 md = lal.gsl_matrix(mddat.shape[0], mddat.shape[1])
738 md.data = mddat
739 mdout = lal.gsl_matrix(mddat.shape[0], mddat.shape[1])
740 mdout.data = numpy.zeros(numpy.shape(mddat), dtype=mddat.dtype)
741 assert lal.swig_lal_test_viewin_gsl_matrix(mdout, md)
742 assert (mdout.data == md.data).all()
743 mdout.data = numpy.zeros(numpy.shape(mddat), dtype=mddat.dtype)
744 assert lal.swig_lal_test_viewin_gsl_matrix(mdout, mddat)
745 assert (mdout.data == mddat).all()
746 mdout.data = numpy.zeros(numpy.shape(mddat), dtype=mddat.dtype)
747 assert lal.swig_lal_test_viewinout_gsl_matrix(mdout, md)
748 assert (2 * mdout.data == md.data).all()
749 mdout.data = numpy.zeros(numpy.shape(mddat), dtype=mddat.dtype)
750 assert lal.swig_lal_test_viewinout_gsl_matrix(mdout, mddat)
751 assert (2 * mdout.data == mddat).all()
752 md.data = mddat
753 assert lal.swig_lal_test_copyinout_gsl_matrix(md)
754 assert (md.data == 3 * mddat).all()
755 md.data = mddat
756 retn, md = lal.swig_lal_test_copyinout_gsl_matrix(md)
757 assert retn
758 assert (md.data == 3 * mddat).all()
759 md = mddat
760 retn, md = lal.swig_lal_test_copyinout_gsl_matrix(md)
761 assert retn
762 assert (md == 3 * mddat).all()
763 del md
764 del mdout
765 del mddat
766 lal.CheckMemoryLeaks()
767 mcf = lal.gsl_matrix_complex_float(mcfdat.shape[0], mcfdat.shape[1])
768 mcf.data = mcfdat
769 mcfout = lal.gsl_matrix_complex_float(mcfdat.shape[0], mcfdat.shape[1])
770 mcfout.data = numpy.zeros(numpy.shape(mcfdat), dtype=mcfdat.dtype)
771 assert lal.swig_lal_test_viewin_gsl_matrix_complex_float(mcfout, mcf)
772 assert (mcfout.data == mcf.data).all()
773 mcfout.data = numpy.zeros(numpy.shape(mcfdat), dtype=mcfdat.dtype)
774 assert lal.swig_lal_test_viewin_gsl_matrix_complex_float(mcfout, mcfdat)
775 assert (mcfout.data == mcfdat).all()
776 mcfout.data = numpy.zeros(numpy.shape(mcfdat), dtype=mcfdat.dtype)
777 assert lal.swig_lal_test_viewinout_gsl_matrix_complex_float(mcfout, mcf)
778 assert (2 * mcfout.data == mcf.data).all()
779 mcfout.data = numpy.zeros(numpy.shape(mcfdat), dtype=mcfdat.dtype)
780 assert lal.swig_lal_test_viewinout_gsl_matrix_complex_float(mcfout, mcfdat)
781 assert (2 * mcfout.data == mcfdat).all()
782 mcf.data = mcfdat
783 assert lal.swig_lal_test_copyinout_gsl_matrix_complex_float(mcf)
784 assert (mcf.data == 3 * mcfdat).all()
785 mcf.data = mcfdat
786 retn, mcf = lal.swig_lal_test_copyinout_gsl_matrix_complex_float(mcf)
787 assert retn
788 assert (mcf.data == 3 * mcfdat).all()
789 mcf = mcfdat
790 retn, mcf = lal.swig_lal_test_copyinout_gsl_matrix_complex_float(mcf)
791 assert retn
792 assert (mcf == 3 * mcfdat).all()
793 del mcf
794 del mcfout
795 del mcfdat
796 lal.CheckMemoryLeaks()
797 mcd = lal.gsl_matrix_complex(mcddat.shape[0], mcddat.shape[1])
798 mcd.data = mcddat
799 mcdout = lal.gsl_matrix_complex(mcddat.shape[0], mcddat.shape[1])
800 mcdout.data = numpy.zeros(numpy.shape(mcddat), dtype=mcddat.dtype)
801 assert lal.swig_lal_test_viewin_gsl_matrix_complex(mcdout, mcd)
802 assert (mcdout.data == mcd.data).all()
803 mcdout.data = numpy.zeros(numpy.shape(mcddat), dtype=mcddat.dtype)
804 assert lal.swig_lal_test_viewin_gsl_matrix_complex(mcdout, mcddat)
805 assert (mcdout.data == mcddat).all()
806 mcdout.data = numpy.zeros(numpy.shape(mcddat), dtype=mcddat.dtype)
807 assert lal.swig_lal_test_viewinout_gsl_matrix_complex(mcdout, mcd)
808 assert (2 * mcdout.data == mcd.data).all()
809 mcdout.data = numpy.zeros(numpy.shape(mcddat), dtype=mcddat.dtype)
810 assert lal.swig_lal_test_viewinout_gsl_matrix_complex(mcdout, mcddat)
811 assert (2 * mcdout.data == mcddat).all()
812 mcd.data = mcddat
813 assert lal.swig_lal_test_copyinout_gsl_matrix_complex(mcd)
814 assert (mcd.data == 3 * mcddat).all()
815 mcd.data = mcddat
816 retn, mcd = lal.swig_lal_test_copyinout_gsl_matrix_complex(mcd)
817 assert retn
818 assert (mcd.data == 3 * mcddat).all()
819 mcd = mcddat
820 retn, mcd = lal.swig_lal_test_copyinout_gsl_matrix_complex(mcd)
821 assert retn
822 assert (mcd == 3 * mcddat).all()
823 del mcd
824 del mcdout
825 del mcddat
826 lal.CheckMemoryLeaks()
827 print("PASSED input views of numeric array structs (GSL)")
828 def check_input_view_type_safety(f, a, b, expect_exception):
829  expected_exception = False
830  if expect_exception:
831  try:
832  f(a, b)
833  expected_exception = True
834  except:
835  pass
836  assert not expected_exception
837  try:
838  f(b, a)
839  expected_exception = True
840  except:
841  pass
842  assert not expected_exception
843  else:
844  f(a, b)
845  f(b, a)
846 r4 = numpy.zeros(10, dtype=numpy.float32)
847 r8 = numpy.zeros(10, dtype=numpy.float64)
848 c8 = numpy.zeros(10, dtype=numpy.complex64)
849 c16 = numpy.zeros(10, dtype=numpy.complex128)
850 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL4Vector, r4, r4, False)
851 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL4Vector, r4, r8, True)
852 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL4Vector, r4, c8, True)
853 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL4Vector, r4, c16, True)
854 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL8Vector, r8, r4, True)
855 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL8Vector, r8, r8, False)
856 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL8Vector, r8, c8, True)
857 check_input_view_type_safety(lal.swig_lal_test_viewinout_REAL8Vector, r8, c16, True)
858 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX8Vector, c8, r4, True)
859 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX8Vector, c8, r8, True)
860 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX8Vector, c8, c8, False)
861 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX8Vector, c8, c16, True)
862 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX16Vector, c16, r4, True)
863 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX16Vector, c16, r8, True)
864 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX16Vector, c16, c8, True)
865 check_input_view_type_safety(lal.swig_lal_test_viewinout_COMPLEX16Vector, c16, c16, False)
866 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_float, r4, r4, False)
867 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_float, r4, r8, True)
868 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_float, r4, c8, True)
869 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_float, r4, c16, True)
870 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector, r8, r4, True)
871 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector, r8, r8, False)
872 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector, r8, c8, True)
873 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector, r8, c16, True)
874 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex_float, c8, r4, True)
875 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex_float, c8, r8, True)
876 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex_float, c8, c8, False)
877 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex_float, c8, c16, True)
878 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex, c16, r4, True)
879 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex, c16, r8, True)
880 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex, c16, c8, True)
881 check_input_view_type_safety(lal.swig_lal_test_viewinout_gsl_vector_complex, c16, c16, False)
882 del r4
883 del r8
884 del c8
885 del c16
886 lal.CheckMemoryLeaks()
887 print("PASSED input views of numeric array structs (type safety)")
888 
889 # check FFT functions with input views
890 print("check FFT functions with input views ...")
891 r4in = numpy.array(list(range(0, 32)), dtype=numpy.float32)
892 r8in = numpy.array(list(range(0, 64)), dtype=numpy.float64)
893 c8in = numpy.array(numpy.vectorize(complex)(8 + r4in, r4in), dtype=numpy.complex64)
894 c16in = numpy.array(numpy.vectorize(complex)(16 + r8in, r8in), dtype=numpy.complex128)
895 c8inv = lal.CreateCOMPLEX8Vector(len(c8in))
896 c8inv.data = c8in
897 c8outv = lal.CreateCOMPLEX8Vector(len(c8in))
898 plan = lal.CreateForwardCOMPLEX8FFTPlan(len(c8in), 0)
899 lal.COMPLEX8VectorFFT(c8outv, c8inv, plan)
900 c8out = numpy.zeros(numpy.shape(c8outv.data), dtype=c8outv.data.dtype)
901 lal.COMPLEX8VectorFFT(c8out, c8in, plan)
902 assert (c8out == c8outv.data).all()
903 del c8inv
904 del c8outv
905 del plan
906 lal.CheckMemoryLeaks()
907 c16inv = lal.CreateCOMPLEX16Vector(len(c16in))
908 c16inv.data = c16in
909 c16outv = lal.CreateCOMPLEX16Vector(len(c16in))
910 plan = lal.CreateForwardCOMPLEX16FFTPlan(len(c16in), 0)
911 lal.COMPLEX16VectorFFT(c16outv, c16inv, plan)
912 c16out = numpy.zeros(numpy.shape(c16outv.data), dtype=c16outv.data.dtype)
913 lal.COMPLEX16VectorFFT(c16out, c16in, plan)
914 assert (c16out == c16outv.data).all()
915 del c16inv
916 del c16outv
917 del plan
918 lal.CheckMemoryLeaks()
919 r4inv = lal.CreateREAL4Vector(len(r4in))
920 r4inv.data = r4in
921 c8outv = lal.CreateCOMPLEX8Vector(len(r4in)//2 + 1)
922 plan = lal.CreateForwardREAL4FFTPlan(len(r4in), 0)
923 lal.REAL4ForwardFFT(c8outv, r4inv, plan)
924 c8out = numpy.zeros(numpy.shape(c8outv.data), dtype=c8outv.data.dtype)
925 lal.REAL4ForwardFFT(c8out, r4in, plan)
926 assert (c8out == c8outv.data).all()
927 del r4inv
928 del c8outv
929 del plan
930 lal.CheckMemoryLeaks()
931 c8inv = lal.CreateCOMPLEX8Vector(len(c8in))
932 c8inv.data = c8in
933 r4outv = lal.CreateREAL4Vector((len(c8in)-1)*2)
934 plan = lal.CreateReverseREAL4FFTPlan((len(c8in)-1)*2, 0)
935 lal.REAL4ReverseFFT(r4outv, c8inv, plan)
936 r4out = numpy.zeros(numpy.shape(r4outv.data), dtype=r4outv.data.dtype)
937 lal.REAL4ReverseFFT(r4out, c8in, plan)
938 assert (r4out == r4outv.data).all()
939 del c8inv
940 del r4outv
941 del plan
942 lal.CheckMemoryLeaks()
943 r8inv = lal.CreateREAL8Vector(len(r8in))
944 r8inv.data = r8in
945 c16outv = lal.CreateCOMPLEX16Vector(len(r8in)//2 + 1)
946 plan = lal.CreateForwardREAL8FFTPlan(len(r8in), 0)
947 lal.REAL8ForwardFFT(c16outv, r8inv, plan)
948 c16out = numpy.zeros(numpy.shape(c16outv.data), dtype=c16outv.data.dtype)
949 lal.REAL8ForwardFFT(c16out, r8in, plan)
950 assert (c16out == c16outv.data).all()
951 del r8inv
952 del c16outv
953 del plan
954 lal.CheckMemoryLeaks()
955 c16inv = lal.CreateCOMPLEX16Vector(len(c16in))
956 c16inv.data = c16in
957 r8outv = lal.CreateREAL8Vector((len(c16in)-1)*2)
958 plan = lal.CreateReverseREAL8FFTPlan((len(c16in)-1)*2, 0)
959 lal.REAL8ReverseFFT(r8outv, c16inv, plan)
960 r8out = numpy.zeros(numpy.shape(r8outv.data), dtype=r8outv.data.dtype)
961 lal.REAL8ReverseFFT(r8out, c16in, plan)
962 assert (r8out == r8outv.data).all()
963 del c16inv
964 del r8outv
965 del plan
966 lal.CheckMemoryLeaks()
967 r4inv = lal.CreateREAL4Vector(len(r4in))
968 r4inv.data = r4in
969 r4outv = lal.CreateREAL4Vector(len(r4in))
970 plan = lal.CreateForwardREAL4FFTPlan(len(r4in), 0)
971 lal.REAL4VectorFFT(r4outv, r4inv, plan)
972 r4out = numpy.zeros(numpy.shape(r4outv.data), dtype=r4outv.data.dtype)
973 lal.REAL4VectorFFT(r4out, r4in, plan)
974 assert (r4out == r4outv.data).all()
975 del r4inv
976 del r4outv
977 del plan
978 lal.CheckMemoryLeaks()
979 r8inv = lal.CreateREAL8Vector(len(r8in))
980 r8inv.data = r8in
981 r8outv = lal.CreateREAL8Vector(len(r8in))
982 plan = lal.CreateForwardREAL8FFTPlan(len(r8in), 0)
983 lal.REAL8VectorFFT(r8outv, r8inv, plan)
984 r8out = numpy.zeros(numpy.shape(r8outv.data), dtype=r8outv.data.dtype)
985 lal.REAL8VectorFFT(r8out, r8in, plan)
986 assert (r8out == r8outv.data).all()
987 del r8inv
988 del r8outv
989 del plan
990 lal.CheckMemoryLeaks()
991 r4inv = lal.CreateREAL4Vector(len(r4in))
992 r4inv.data = r4in
993 r4outv = lal.CreateREAL4Vector(len(r4in)//2 + 1)
994 plan = lal.CreateForwardREAL4FFTPlan(len(r4in), 0)
995 lal.REAL4PowerSpectrum(r4outv, r4inv, plan)
996 r4out = numpy.zeros(numpy.shape(r4outv.data), dtype=r4outv.data.dtype)
997 lal.REAL4PowerSpectrum(r4out, r4in, plan)
998 assert (r4out == r4outv.data).all()
999 del r4inv
1000 del r4outv
1001 del plan
1002 lal.CheckMemoryLeaks()
1003 r8inv = lal.CreateREAL8Vector(len(r8in))
1004 r8inv.data = r8in
1005 r8outv = lal.CreateREAL8Vector(len(r8in)//2 + 1)
1006 plan = lal.CreateForwardREAL8FFTPlan(len(r8in), 0)
1007 lal.REAL8PowerSpectrum(r8outv, r8inv, plan)
1008 r8out = numpy.zeros(numpy.shape(r8outv.data), dtype=r8outv.data.dtype)
1009 lal.REAL8PowerSpectrum(r8out, r8in, plan)
1010 assert (r8out == r8outv.data).all()
1011 del r8inv
1012 del r8outv
1013 del plan
1014 lal.CheckMemoryLeaks()
1015 print("PASSED FFT functions with input views ...")
1016 
1017 # check dynamic array of pointers access
1018 print("checking dynamic array of pointers access ...")
1019 ap = lal.swig_lal_test_Create_arrayofptrs(3)
1020 assert ap.length == 3
1021 for i in range(0, ap.length):
1022  assert ap.data[i].length == 6
1023  for j in range(0, ap.data[i].length):
1024  assert ap.data[i].data[j] == 42*ap.length*i + j
1025 del ap
1026 lal.CheckMemoryLeaks()
1027 print("PASSED dynamic array of pointers access")
1028 
1029 ## check typemaps for strings and double pointers
1030 print("checking typemaps for strings and double pointers ...")
1031 sts = lal.swig_lal_test_struct()
1032 ptr_ptr, ptr_null_ptr, null_ptr_ptr = lal.swig_lal_test_typemaps_string_ptrptr("abcde", "", None, sts, 0, None)
1033 assert ptr_ptr == sts
1034 assert ptr_null_ptr is not None
1035 assert null_ptr_ptr is None
1036 del sts
1037 del ptr_ptr
1038 del ptr_null_ptr
1039 del null_ptr_ptr
1040 lal.CheckMemoryLeaks()
1041 ptr_ptr = 0
1042 for i in range(1, 10):
1043  ptr_ptr = lal.swig_lal_test_typemaps_ptrptr(ptr_ptr)
1044  assert ptr_ptr is not None
1045  assert ptr_ptr.n == i
1046 del ptr_ptr
1047 lal.CheckMemoryLeaks()
1048 ptr_ptr_list = [0]
1049 for i in range(1, 10):
1050  ptr_ptr_list.append(lal.swig_lal_test_typemaps_ptrptr(ptr_ptr_list[-1]))
1051  assert ptr_ptr_list[-1] is not None
1052  assert ptr_ptr_list[-1].n == i
1053 while len(ptr_ptr_list) > 0:
1054  assert ptr_ptr_list[-1] is not None
1055  assert ptr_ptr_list[-1].n == i
1056  del ptr_ptr_list[0]
1057 del ptr_ptr_list
1058 lal.CheckMemoryLeaks()
1059 print("PASSED typemaps for strings and double pointers")
1060 
1061 # check 'tm' struct conversions
1062 print("checking 'tm' struct conversions ...")
1063 gps0 = 989168284
1064 utc0 = [2011, 5, 11, 16, 57, 49, 2, 131, 0]
1065 assert lal.GPSToUTC(gps0) == tuple(utc0)
1066 assert lal.UTCToGPS(utc0) == gps0
1067 for i in range(0, 10):
1068  gps = gps0 + i * 86400
1069  utc = list(utc0)
1070  utc[2] = utc[2] + i
1071  utc[6] = (utc[6] + i) % 7
1072  utc[7] = utc[7] + i
1073  utc[8] = -1 + (i % 3)
1074  assert lal.GPSToUTC(gps)[0:8] == tuple(utc[0:8])
1075  assert lal.UTCToGPS(utc) == gps
1076  utc = lal.GPSToUTC(lal.UTCToGPS(utc))
1077  dt = datetime.datetime(*utc[0:6])
1078  assert utc[6] == dt.weekday()
1079 lal.CheckMemoryLeaks()
1080 print("PASSED 'tm' struct conversions")
1081 
1082 # check LIGOTimeGPS operations
1083 print("checking LIGOTimeGPS operations ...")
1084 from lal import LIGOTimeGPS
1085 t0 = LIGOTimeGPS()
1086 assert type(LIGOTimeGPS(t0)) is LIGOTimeGPS
1087 assert is_value_and_type(t0, 0, LIGOTimeGPS)
1088 assert t0 != None and not t0 is None
1089 t1 = LIGOTimeGPS(10.5)
1090 t2 = LIGOTimeGPS(10, 500000000)
1091 assert not t0 and t1 and t2
1092 assert is_value_and_type(t1, t2, LIGOTimeGPS)
1093 t3 = +t1
1094 t3 = -t2
1095 assert t1 == t2 and t1 >= t2 and t2 >= t1
1096 assert abs(-t1) == t1
1097 assert float(t1) == 10.5
1098 assert is_value_and_type(t1 + 3.5, 14, LIGOTimeGPS)
1099 assert is_value_and_type(3.5 + t1, 14, LIGOTimeGPS)
1100 t2 -= 5.5
1101 assert is_value_and_type(t2, 5, LIGOTimeGPS)
1102 assert t2 + 5.5 >= t1 and t2 + 3 != t2
1103 assert is_value_and_type(t2 - 5, t0, LIGOTimeGPS)
1104 assert is_value_and_type(t1 * 3, 31.5, LIGOTimeGPS)
1105 assert is_value_and_type(3 * t1, 31.5, LIGOTimeGPS)
1106 assert is_value_and_type(t2 / 2.5, 2, LIGOTimeGPS)
1107 assert is_value_and_type(21 / t1, 2, LIGOTimeGPS)
1108 assert is_value_and_type(t1 + t2, 15.5, LIGOTimeGPS)
1109 assert is_value_and_type(t1 - t2, 5.5, LIGOTimeGPS)
1110 assert is_value_and_type(t1 * t2, 52.5, LIGOTimeGPS)
1111 assert is_value_and_type(t2 * t1, 52.5, LIGOTimeGPS)
1112 assert is_value_and_type(t1 / t2, 2.1, LIGOTimeGPS)
1113 assert is_value_and_type(t1 % t2, 0.5, LIGOTimeGPS)
1114 assert t1 > t2 and t2 < t1 and t1 >= t2 and t2 <= t1
1115 assert LIGOTimeGPS(333333333,333333333) == LIGOTimeGPS(1000000000) / 3
1116 assert LIGOTimeGPS(666666666,666666667) == LIGOTimeGPS(2000000000) / 3
1117 assert LIGOTimeGPS("-62997760.825036067") == LIGOTimeGPS("-47044285.062262587") - LIGOTimeGPS("15953475.76277348")
1118 assert LIGOTimeGPS("-6542354.389038577") == LIGOTimeGPS("-914984.929117316") * 7.1502318572066237
1119 assert LIGOTimeGPS("-6542354.389038577") == 7.1502318572066237 * LIGOTimeGPS("-914984.929117316")
1120 assert LIGOTimeGPS("-127965.770535834") == LIGOTimeGPS("-914984.929117316") / 7.1502318572066237
1121 t1 += 812345667.75
1122 assert str(t1) == "812345678.25"
1123 assert type(eval(repr(t1))) is type(t1)
1124 assert eval(repr(t1)) == t1
1125 assert(LIGOTimeGPS(1100000000).asutcstr() == "Fri, 14 Nov 2014 11:33:04 +0000") # lalapps_tconvert -u -R
1126 assert LIGOTimeGPS(1100000000, 100).asutcstr() == "Fri, 14 Nov 2014 11:33:04.0000001 +0000"
1127 assert LIGOTimeGPS(0, 0).asutcstr() == "Sun, 06 Jan 1980 00:00:00 +0000"
1128 assert LIGOTimeGPS(-1, 0).asutcstr() == "Sat, 05 Jan 1980 23:59:59 +0000"
1129 assert LIGOTimeGPS(0, -1).asutcstr() == "Sat, 05 Jan 1980 23:59:59.999999999 +0000"
1130 assert int(t1) == 812345678
1131 assert t1.ns() == 812345678250000000
1132 assert hash(t1) == 1049484238
1133 t4struct = lal.swig_lal_test_gps()
1134 t4struct.t = 1234.5
1135 assert t4struct.t == 1234.5
1136 t5 = LIGOTimeGPS("1000")
1137 assert t5 == 1000
1138 print("*** below should be error messages from LIGOTimeGPS constructor ***")
1139 try:
1140  t5 = LIGOTimeGPS("abc1000")
1141  expected_exception = True
1142 except:
1143  pass
1144 assert not expected_exception
1145 try:
1146  t5 = LIGOTimeGPS("1000abc")
1147  expected_exception = True
1148 except:
1149  pass
1150 assert not expected_exception
1151 print("*** above should be error messages from LIGOTimeGPS constructor ***")
1152 assert lal.swig_lal_test_noptrgps(LIGOTimeGPS(1234.5)) == lal.swig_lal_test_noptrgps(1234.5)
1153 print("*** below should be error messages from LIGOTimeGPS constructor ***")
1154 try:
1155  LIGOTimeGPS(None)
1156  expected_exception = True
1157 except:
1158  pass
1159 assert not expected_exception
1160 print("*** above should be error messages from LIGOTimeGPS constructor ***")
1161 del t0
1162 del t1
1163 del t2
1164 del t3
1165 del t4struct
1166 del t5
1167 lal.CheckMemoryLeaks()
1168 print("PASSED LIGOTimeGPS operations")
1169 print("checking LIGOTimeGPS operations (Python specific) ...")
1171  def __init__(self, s, ns):
1172  self.gpsSeconds = s
1173  self.gpsNanoSeconds = ns
1174 tmy = my_gps_class(987, 654321)
1175 tsw = LIGOTimeGPS(tmy)
1176 assert type(tsw) is LIGOTimeGPS
1177 assert tsw.gpsSeconds == 987
1178 assert tsw.gpsNanoSeconds == 654321
1179 assert is_value_and_type(tsw + tmy, tsw + tsw, LIGOTimeGPS)
1180 assert is_value_and_type(tmy + tsw, tsw + tsw, LIGOTimeGPS)
1181 assert is_value_and_type(tsw - tmy, tsw - tsw, LIGOTimeGPS)
1182 assert is_value_and_type(tmy - tsw, tsw - tsw, LIGOTimeGPS)
1183 assert is_value_and_type(tsw * tmy, tsw * tsw, LIGOTimeGPS)
1184 assert is_value_and_type(tmy * tsw, tsw * tsw, LIGOTimeGPS)
1185 assert is_value_and_type(tsw / tmy, tsw / tsw, LIGOTimeGPS)
1186 assert is_value_and_type(tmy / tsw, tsw / tsw, LIGOTimeGPS)
1187 assert lal.swig_lal_test_noptrgps(tmy) == lal.swig_lal_test_noptrgps(tsw)
1188 del tsw
1189 lal.CheckMemoryLeaks()
1190 print("PASSED LIGOTimeGPS operations (Python specific)")
1191 
1192 # check LALUnit operations
1193 print("checking LALUnit operations ...")
1194 u1 = lal.Unit("kg m s^-2")
1195 assert type(lal.Unit(u1)) is lal.Unit
1196 assert is_value_and_type(u1, lal.NewtonUnit, lal.Unit)
1197 assert str(u1) == "m kg s^-2"
1198 u2 = lal.MeterUnit * lal.KiloGramUnit / lal.SecondUnit ** 2
1199 assert is_value_and_type(u2, u1, lal.Unit)
1200 u2 = lal.MeterUnit**(1,2) * lal.KiloGramUnit**(1,2) * lal.SecondUnit ** -1
1201 assert is_value_and_type(u2, u1**(1,2), lal.Unit)
1202 try:
1203  lal.SecondUnit ** (1,0)
1204  expected_exception = True
1205 except:
1206  pass
1207 assert not expected_exception
1208 u1 *= lal.MeterUnit
1209 assert is_value_and_type(u1, lal.JouleUnit, lal.Unit)
1210 assert repr(u1) == "m^2 kg s^-2"
1211 u1 /= lal.SecondUnit
1212 assert is_value_and_type(u1, lal.WattUnit, lal.Unit)
1213 assert u1 == "m^2 kg s^-3"
1214 u1 *= 1000
1215 assert u1 == lal.KiloUnit * lal.WattUnit
1216 assert u1 == 1000 * lal.WattUnit
1217 assert u1 == lal.WattUnit * 1000
1218 assert u1 == lal.MegaUnit / 1000 * lal.WattUnit
1219 assert int(u1) == 1000
1220 u1 /= 10000
1221 assert u1 == 100 * lal.MilliUnit * lal.WattUnit
1222 try:
1223  u1 *= 1.234
1224  expected_exception = True
1225 except:
1226  pass
1227 assert not expected_exception
1228 assert u1.norm() == u1
1229 del u1
1230 del u2
1231 lal.CheckMemoryLeaks()
1232 print("PASSED LALUnit operations")
1233 
1234 #
1235 # FIXME: pickling requires SWIG >= 3.0.11 because of a bug that was fixed in
1236 # that version. Here's the relevant entry from the SWIG changelog:
1237 #
1238 # 2016-10-13: wsfulton
1239 # [Python] Issue #808 - fix Python pickling and metaclass for builtin wrappers.
1240 # The metaclass (SwigPyObjectType) for SWIG objects was not defined in
1241 # a way that let importlib successfully import the Python wrappers.
1242 # The pickle module previously failed to pickle objects because it couldn't
1243 # determine what module the SWIG wrapped objects were in.
1244 #
1245 if lal.swig_version >= 0x030011:
1246 
1247  # check pickling
1248  print("checking pickling (Python specific) ...")
1249  for datatype in ['INT2', 'INT4', 'INT8', 'UINT2', 'UINT4', 'UINT8',
1250  'REAL4', 'REAL8', 'COMPLEX8', 'COMPLEX16']:
1251 
1252  creator = getattr(lal, 'Create{}FrequencySeries'.format(datatype))
1253  a = creator(
1254  'foobar', lal.LIGOTimeGPS(1e9), 0, 1, lal.StrainUnit, 1024)
1255  a.data.data = numpy.arange(1024)
1256  pickled = pickle.dumps(a, 0)
1257  b = pickle.loads(pickled)
1258  assert type(a) == type(b)
1259  assert a.name == b.name
1260  assert a.epoch == b.epoch
1261  assert a.f0 == b.f0
1262  assert a.deltaF == b.deltaF
1263  assert a.sampleUnits == b.sampleUnits
1264  assert (a.data.data == b.data.data).all()
1265 
1266  creator = getattr(lal, 'Create{}TimeSeries'.format(datatype))
1267  a = creator(
1268  'foobar', lal.LIGOTimeGPS(1e9), 0, 1, lal.StrainUnit, 1024)
1269  a.data.data = numpy.arange(1024)
1270  pickled = pickle.dumps(a, 0)
1271  b = pickle.loads(pickled)
1272  assert type(a) == type(b)
1273  assert a.name == b.name
1274  assert a.epoch == b.epoch
1275  assert a.f0 == b.f0
1276  assert a.deltaT == b.deltaT
1277  assert a.sampleUnits == b.sampleUnits
1278  assert (a.data.data == b.data.data).all()
1279  print("PASSED pickling (Python specific)")
1280 
1281 # test Python dict to LALDict typemap
1282 print("checking Python dict to LALDict typemap (Python specific) ...")
1283 pydict = {
1284  "str": "A string value",
1285  "2-byte-unsigned:UINT2": 32767,
1286  "4-byte-unsigned:UINT4": 123456,
1287  "8-byte-unsigned:UINT8": 9223372036854775807,
1288  "2-byte-signed:INT2": -32768,
1289  "4-byte-signed:INT4": -123456,
1290  "8-byte-signed:INT8": 9223372036854775807,
1291  "single:REAL4": 987e6,
1292  "double:REAL8": -543e-21,
1293  "single complex:COMPLEX8": complex(987e6, -123e4),
1294  "double complex:COMPLEX16": complex(-543e-21, 345e43)
1295 }
1296 laldict = lal.CreateDict()
1297 lal.DictInsertStringValue(laldict, "str", pydict["str"])
1298 lal.DictInsertUINT2Value(laldict, "2-byte-unsigned", pydict["2-byte-unsigned:UINT2"])
1299 lal.DictInsertUINT4Value(laldict, "4-byte-unsigned", pydict["4-byte-unsigned:UINT4"])
1300 lal.DictInsertUINT8Value(laldict, "8-byte-unsigned", pydict["8-byte-unsigned:UINT8"])
1301 lal.DictInsertINT2Value(laldict, "2-byte-signed", pydict["2-byte-signed:INT2"])
1302 lal.DictInsertINT4Value(laldict, "4-byte-signed", pydict["4-byte-signed:INT4"])
1303 lal.DictInsertINT8Value(laldict, "8-byte-signed", pydict["8-byte-signed:INT8"])
1304 lal.DictInsertREAL4Value(laldict, "single", pydict["single:REAL4"])
1305 lal.DictInsertREAL8Value(laldict, "double", pydict["double:REAL8"])
1306 lal.DictInsertCOMPLEX8Value(laldict, "single complex", pydict["single complex:COMPLEX8"])
1307 lal.DictInsertCOMPLEX16Value(laldict, "double complex", pydict["double complex:COMPLEX16"])
1308 lal.swig_lal_test_pydict_to_laldict(laldict)
1309 lal.swig_lal_test_pydict_to_laldict(pydict)
1310 print("PASSED Python dict to LALDict typemap (Python specific)")
1311 
1312 # passed all tests!
1313 print("PASSED all tests")
static double f(double theta, double y, double xi)
Definition: XLALMarcumQ.c:258
static size_t hash(const char *s)
Definition: LALDict.c:51
def check_dynamic_vector_matrix(iv, ivl, rv, rvl, cm, cms1, cms2)
def is_value_and_type(x, v, t)
def check_input_view_type_safety(f, a, b, expect_exception)