forked from gwastro/pycbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_frequencyseries.py
549 lines (479 loc) · 23.9 KB
/
test_frequencyseries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# Copyright (C) 2012 Alex Nitz, Andrew Miller, Tito Dal Canton, Josh Willis
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# =============================================================================
#
# Preamble
#
# =============================================================================
#
'''
These are the unittests for the pycbc frequencyseries type
'''
import pycbc
import unittest
from pycbc.types import *
from pycbc.scheme import *
import numpy
import lal
import sys
import os
import tempfile
from utils import array_base, parse_args_all_schemes, simple_exit
_scheme, _context = parse_args_all_schemes("FrequencySeries")
# By importing the current schemes array type, it will make it
# easier to check the array types later
if _scheme == 'cuda':
import pycuda
import pycuda.gpuarray
from pycuda.gpuarray import GPUArray as SchemeArray
elif _scheme == 'cpu':
from pycbc.types.aligned import ArrayWithAligned as SchemeArray
from pycbc.types.aligned import ArrayWithAligned as CPUArray
class TestFrequencySeriesBase(array_base,unittest.TestCase):
def setUp(self):
self.scheme = _scheme
self.context = _context
# We need to check for correct creation from all dtypes,
# and errors from incorrect operations so the other precision of
# odtype needs to be available as well
self.other_precision = {numpy.complex64 : numpy.complex128,
numpy.complex128 : numpy.complex64,
numpy.float32 : numpy.float64,
numpy.float64 : numpy.float32}
# Number of decimal places to compare for single precision
if self.dtype == numpy.float32 or self.dtype == numpy.complex64:
self.places = 5
self.tol = 1e-5
# Number of decimal places to compare for double precision
else:
self.places = 13
self.tol = 1e-13
# We will also need to check whether dtype and odtype are real or complex,
# so that we can test non-zero imaginary parts.
if self.dtype == numpy.float32 or self.dtype == numpy.float64:
self.kind = 'real'
else:
self.kind = 'complex'
if self.odtype == numpy.float32 or self.odtype == numpy.float64:
self.okind = 'real'
else:
self.okind = 'complex'
# Note that self.epoch is set in the factory class constructor at the end;
# we need only set self.delta_f here.
self.delta_f = 0.1
# We need to tell the arithmetic test functions what our type is:
self.type = FrequencySeries
# and the extra keyword arguments the constructors will need:
self.kwds = {'epoch': self.epoch, 'delta_f': self.delta_f}
# Now that the kinds are set, we need to call our parent method to set up all the
# inputs and answers for our functions
self.setNumbers()
# The above call created instances for all of our inputs and various correct
# outputs. But we make a copy of the scalar to check later.
self.s = self.scalar
# Finally, we want to have an array that we shouldn't be able to operate on,
# because the precision is wrong, and one where the length is wrong.
self.bad = FrequencySeries([1,1,1], 0.1, epoch=self.epoch, dtype = self.other_precision[self.odtype])
self.bad2 = FrequencySeries([1,1,1,1], 0.1, epoch=self.epoch, dtype = self.dtype)
# These are FrequencySeries that have problems specific to FrequencySeries
self.bad3 = FrequencySeries([1,1,1], 0.2, epoch=self.epoch, dtype = self.dtype)
# This next one is actually okay for frequencyseries
if self.epoch is None:
self.bad4 = FrequencySeries([1,1,1], 0.1, epoch = lal.LIGOTimeGPS(1000, 1000), dtype = self.dtype)
else:
self.bad4 = FrequencySeries([1,1,1], 0.1, epoch=None, dtype = self.dtype)
def test_numpy_init(self):
with self.context:
in1 = numpy.array([5,3,1],dtype=self.odtype)
in2 = numpy.array([5,3,1],dtype=self.other_precision[self.odtype])
#We don't want to cast complex as real
if not (self.kind == 'real' and self.okind == 'complex'):
#First we must check that the dtype is correct when specified
out1 = FrequencySeries(in1,0.1, dtype=self.dtype, epoch=self.epoch)
out2 = FrequencySeries(in2,0.1, dtype=self.dtype, epoch=self.epoch)
#to be sure that it is copied
in1 += 1
in2 += 1
self.assertTrue(type(out1._scheme) == type(self.context))
self.assertTrue(type(out1._data) is SchemeArray)
self.assertEqual(out1[0],5)
self.assertEqual(out1[1],3)
self.assertEqual(out1[2],1)
self.assertTrue(out1.dtype==self.dtype)
self.assertEqual(out1.delta_f, 0.1)
self.assertEqual(out1._epoch, self.epoch)
self.assertTrue(type(out2._scheme) == type(self.context))
self.assertTrue(type(out2._data) is SchemeArray)
self.assertEqual(out2[0],5)
self.assertEqual(out2[1],3)
self.assertEqual(out2[2],1)
self.assertTrue(out2.dtype==self.dtype)
self.assertEqual(out2.delta_f,0.1)
self.assertEqual(out2._epoch, self.epoch)
in1-=1
in2-=1
# Also, when it is unspecified
out3 = FrequencySeries(in1,0.1,epoch=self.epoch)
in1 += 1
self.assertTrue(type(out3._scheme) == type(self.context))
self.assertTrue(type(out3._data) is SchemeArray)
self.assertEqual(out3[0],5)
self.assertEqual(out3[1],3)
self.assertEqual(out3[2],1)
self.assertTrue(out3.dtype==self.odtype)
self.assertEqual(out3.delta_f,0.1)
self.assertEqual(out3._epoch, self.epoch)
# Check for copy=false
# On the CPU, this should be possible
in3 = numpy.array([5,3,1],dtype=self.dtype)
if self.scheme == 'cpu':
out4 = FrequencySeries(in3,0.1,copy=False, epoch=self.epoch)
in3 += 1
self.assertTrue(out4.dtype==self.dtype)
self.assertTrue(type(out4._scheme) == type(self.context))
self.assertEqual(out4[0],6)
self.assertEqual(out4[1],4)
self.assertEqual(out4[2],2)
self.assertEqual(out4.delta_f,0.1)
self.assertEqual(out4._epoch, self.epoch)
# If we're in different scheme, this should raise an error
else:
self.assertRaises(TypeError, FrequencySeries, in3, 0.1, copy=False)
# We also need to check initialization using GPU arrays
if self.scheme == 'cuda':
in4 = pycuda.gpuarray.zeros(3,self.dtype)
if self.scheme != 'cpu':
out4 = FrequencySeries(in4,0.1, copy=False, epoch=self.epoch)
in4 += 1
self.assertTrue(type(out4._scheme) == type(self.context))
self.assertTrue(type(out4._data) is SchemeArray)
self.assertEqual(out4[0],1)
self.assertEqual(out4[1],1)
self.assertEqual(out4[2],1)
self.assertTrue(out4.dtype==self.dtype)
self.assertEqual(out4.delta_f,0.1)
self.assertEqual(out4._epoch, self.epoch)
# We should be able to create an array from the wrong dtype, and
# it should be cast as float64
in5 = numpy.array([1,2,3],dtype=numpy.int32)
out5 = FrequencySeries(in5,0.1, epoch=self.epoch)
in5 += 1
self.assertTrue(type(out5._scheme) == type(self.context))
self.assertTrue(type(out5._data) is SchemeArray)
self.assertEqual(out5[0],1)
self.assertEqual(out5[1],2)
self.assertEqual(out5[2],3)
self.assertEqual(out5.delta_f,0.1)
self.assertEqual(out5._epoch, self.epoch)
# Finally, just checking a few things specific to FrequencySeries
inbad = numpy.array([],dtype=float64)
self.assertRaises(ValueError, FrequencySeries, in1, -1)
self.assertRaises(ValueError, FrequencySeries, inbad, .1)
self.assertRaises(TypeError, FrequencySeries, in1, .1, epoch=(5,1))
def test_array_init(self):
# this array is made outside the context so we can check that an error is raised when copy = false in a GPU scheme
cpuarray = Array([1,2,3])
with self.context:
in1 = Array([5,3,1],dtype=self.odtype)
in2 = Array([5,3,1],dtype=self.other_precision[self.odtype])
self.assertTrue(type(in1._scheme) == type(self.context))
self.assertTrue(type(in1._data) is SchemeArray)
self.assertTrue(type(in2._scheme) == type(self.context))
self.assertTrue(type(in2._data) is SchemeArray)
# We don't want to cast complex as real
if not (self.kind=='real' and self.okind == 'complex'):
# First we must check that the dtype is correct when specified
out1 = FrequencySeries(in1, 0.1, dtype=self.dtype, epoch=self.epoch)
out2 = FrequencySeries(in2, 0.1, dtype=self.dtype, epoch=self.epoch)
# to be sure that it is copied
in1 += 1
in2 += 1
self.assertTrue(type(out1._scheme) == type(self.context))
self.assertTrue(type(out1._data) is SchemeArray)
self.assertEqual(out1[0],5)
self.assertEqual(out1[1],3)
self.assertEqual(out1[2],1)
self.assertTrue(out1.dtype==self.dtype)
self.assertEqual(out1.delta_f, 0.1)
self.assertEqual(out1._epoch, self.epoch)
if out1.dtype == numpy.float32:
self.assertTrue(out1.precision == 'single')
#self.assertTrue(out1.kind == 'real')
if out1.dtype == numpy.float64:
self.assertTrue(out1.precision == 'double')
#self.assertTrue(out1.kind == 'real')
if out1.dtype == numpy.complex64:
self.assertTrue(out1.precision == 'single')
#self.assertTrue(out1.kind == 'complex')
if out1.dtype == numpy.complex128:
self.assertTrue(out1.precision == 'double')
#self.assertTrue(out1.kind == 'complex')
self.assertTrue(type(out2._scheme) == type(self.context))
self.assertTrue(type(out2._data) is SchemeArray)
self.assertEqual(out2[0],5)
self.assertEqual(out2[1],3)
self.assertEqual(out2[2],1)
self.assertTrue(out2.dtype==self.dtype)
self.assertEqual(out2.delta_f, 0.1)
self.assertEqual(out2._epoch, self.epoch)
in1-=1
in2-=1
# Giving complex input and specifying a real dtype should raise an error
else:
self.assertRaises(TypeError, FrequencySeries, in1,0.1, dtype = self.dtype)
self.assertRaises(TypeError, FrequencySeries, in2,0.1, dtype = self.dtype)
# Also, when it is unspecified
out3 = FrequencySeries(in1,0.1,epoch=self.epoch)
in1 += 1
self.assertTrue(type(out3._scheme) == type(self.context))
self.assertTrue(type(out3._data) is SchemeArray)
self.assertEqual(out3[0],5)
self.assertEqual(out3[1],3)
self.assertEqual(out3[2],1)
self.assertTrue(out3.dtype==self.odtype)
self.assertEqual(out3.delta_f, 0.1)
self.assertEqual(out3._epoch, self.epoch)
# We should also be able to create from a CPU Array
out4 = FrequencySeries(cpuarray,0.1, dtype=self.dtype, epoch=self.epoch)
self.assertTrue(type(out4._scheme) == type(self.context))
self.assertTrue(type(out4._data) is SchemeArray)
self.assertEqual(out4[0],1)
self.assertEqual(out4[1],2)
self.assertEqual(out4[2],3)
self.assertTrue(out4.dtype==self.dtype)
self.assertEqual(out4.delta_f, 0.1)
self.assertEqual(out4._epoch, self.epoch)
# Check for copy=false
in3 = Array([5,3,1],dtype=self.dtype)
out5 = FrequencySeries(in3,0.1,copy=False, epoch=self.epoch)
in3 += 1
self.assertTrue(type(out5._scheme) == type(self.context))
self.assertTrue(type(out5._data) is SchemeArray)
self.assertEqual(out5[0],6)
self.assertEqual(out5[1],4)
self.assertEqual(out5[2],2)
self.assertTrue(out5.dtype==self.dtype)
self.assertEqual(out5.delta_f, 0.1)
self.assertEqual(out5._epoch, self.epoch)
if self.scheme != 'cpu':
self.assertRaises(TypeError,FrequencySeries,0.1,cpuarray,copy=False)
# Things specific to FrequencySeries
inbad = Array(numpy.array([],dtype=float64))
self.assertRaises(ValueError, FrequencySeries, in1, -1)
self.assertRaises(ValueError, FrequencySeries, inbad, .1)
self.assertRaises(TypeError, FrequencySeries, in1, .1, epoch=(5,2))
# Also checking that a cpu array can't be made out of another scheme without copying
if self.scheme != 'cpu':
self.assertRaises(TypeError, FrequencySeries, out4, 0.1, copy=False)
out6 = FrequencySeries(out4, 0.1, dtype=self.dtype, epoch=self.epoch)
self.assertTrue(type(out6._scheme) == CPUScheme)
self.assertTrue(type(out6._data) is CPUArray)
self.assertEqual(out6[0],1)
self.assertEqual(out6[1],2)
self.assertEqual(out6[2],3)
self.assertTrue(out6.dtype==self.dtype)
self.assertEqual(out6.delta_f, 0.1)
self.assertEqual(out6._epoch, self.epoch)
def test_list_init(self):
with self.context:
# When specified
out1 = FrequencySeries([5,3,1],0.1, dtype=self.dtype, epoch=self.epoch)
self.assertTrue(type(out1._scheme) == type(self.context))
self.assertTrue(type(out1._data) is SchemeArray)
self.assertEqual(out1[0],5)
self.assertEqual(out1[1],3)
self.assertEqual(out1[2],1)
self.assertTrue(out1.dtype==self.dtype)
self.assertEqual(out1.delta_f, 0.1)
self.assertEqual(out1._epoch, self.epoch)
if out1.dtype == numpy.float32:
self.assertTrue(out1.precision == 'single')
#self.assertTrue(out1.kind == 'real')
if out1.dtype == numpy.float64:
self.assertTrue(out1.precision == 'double')
#self.assertTrue(out1.kind == 'real')
if out1.dtype == numpy.complex64:
self.assertTrue(out1.precision == 'single')
#self.assertTrue(out1.kind == 'complex')
if out1.dtype == numpy.complex128:
self.assertTrue(out1.precision == 'double')
#self.assertTrue(out1.kind == 'complex')
if self.kind == 'complex':
out2 = FrequencySeries([5+0j,3+0j,1+0j], 0.1, dtype=self.dtype, epoch=self.epoch)
self.assertTrue(type(out2._scheme) == type(self.context))
self.assertTrue(type(out2._data) is SchemeArray)
self.assertEqual(out2[0],5)
self.assertEqual(out2[1],3)
self.assertEqual(out2[2],1)
self.assertTrue(out2.dtype==self.dtype)
self.assertEqual(out2.delta_f, 0.1)
self.assertEqual(out2._epoch, self.epoch)
else:
self.assertRaises(TypeError, FrequencySeries,[5+0j, 3+0j, 1+0j], 0.1, dtype=self.dtype)
#Also, when it is unspecified
out3 = FrequencySeries([5.0,3,1],0.1,epoch=self.epoch)
self.assertTrue(type(out3._scheme) == type(self.context))
self.assertTrue(type(out3._data) is SchemeArray)
self.assertEqual(out3[0],5)
self.assertEqual(out3[1],3)
self.assertEqual(out3[2],1)
self.assertTrue(out3.dtype==numpy.float64)
self.assertEqual(out3.delta_f, 0.1)
self.assertEqual(out3._epoch, self.epoch)
out4 = FrequencySeries([5.0+0j,3+0j,1+0j],0.1,epoch = self.epoch)
self.assertTrue(type(out4._scheme) == type(self.context))
self.assertTrue(type(out4._data) is SchemeArray)
self.assertEqual(out4[0],5)
self.assertEqual(out4[1],3)
self.assertEqual(out4[2],1)
self.assertTrue(out4.dtype==numpy.complex128)
self.assertEqual(out4.delta_f, 0.1)
self.assertEqual(out4._epoch, self.epoch)
self.assertRaises(TypeError,FrequencySeries,[1,2,3],copy=False)
# Things specific to FrequencySeries
self.assertRaises(ValueError, FrequencySeries, [1,2,3], -1)
self.assertRaises(ValueError, FrequencySeries, [], .1)
self.assertRaises(TypeError, FrequencySeries, [1,2,3], .1, epoch=(5,2))
def test_mul(self):
super(TestFrequencySeriesBase,self).test_mul()
self.assertRaises(ValueError, self.a.__mul__,self.bad3)
c = self.a * self.bad4
self.assertTrue(c._epoch==self.epoch)
def test_rmul(self):
super(TestFrequencySeriesBase,self).test_rmul()
self.assertRaises(ValueError, self.a.__rmul__,self.bad3)
c = self.a.__rmul__(self.bad4)
self.assertTrue(c._epoch==self.epoch)
def test_imul(self):
super(TestFrequencySeriesBase,self).test_imul()
self.assertRaises(ValueError, self.a.__imul__,self.bad3)
self.a *= self.bad4
self.assertTrue(self.a._epoch==self.epoch)
def test_add(self):
super(TestFrequencySeriesBase,self).test_add()
self.assertRaises(ValueError, self.a.__add__,self.bad3)
c = self.a + self.bad4
self.assertTrue(c._epoch==self.epoch)
def test_radd(self):
super(TestFrequencySeriesBase,self).test_radd()
self.assertRaises(ValueError, self.a.__radd__,self.bad3)
c = self.a.__radd__(self.bad4)
self.assertTrue(c._epoch==self.epoch)
def test_iadd(self):
super(TestFrequencySeriesBase,self).test_iadd()
self.assertRaises(ValueError, self.a.__iadd__,self.bad3)
self.a += self.bad4
self.assertTrue(self.a._epoch==self.epoch)
def test_sub(self):
super(TestFrequencySeriesBase,self).test_sub()
self.assertRaises(ValueError, self.a.__sub__,self.bad3)
c = self.a - self.bad4
self.assertTrue(c._epoch==self.epoch)
def test_rsub(self):
super(TestFrequencySeriesBase,self).test_rsub()
self.assertRaises(ValueError, self.a.__rsub__,self.bad3)
c = self.a.__rsub__(self.bad4)
self.assertTrue(c._epoch==self.epoch)
def test_isub(self):
super(TestFrequencySeriesBase,self).test_isub()
self.assertRaises(ValueError, self.a.__isub__,self.bad3)
self.a -= self.bad4
self.assertTrue(self.a._epoch==self.epoch)
def test_div(self):
super(TestFrequencySeriesBase,self).test_div()
self.assertRaises(ValueError, self.a.__div__,self.bad3)
c = self.a / self.bad4
self.assertTrue(c._epoch==self.epoch)
def test_rdiv(self):
super(TestFrequencySeriesBase,self).test_rdiv()
self.assertRaises(ValueError, self.a.__rdiv__,self.bad3)
c = self.a.__rdiv__(self.bad4)
self.assertTrue(c._epoch==self.epoch)
def test_idiv(self):
super(TestFrequencySeriesBase,self).test_idiv()
self.assertRaises(ValueError, self.a.__idiv__,self.bad3)
self.a /= self.bad4
self.assertTrue(self.a._epoch==self.epoch)
def test_dot(self):
super(TestFrequencySeriesBase,self).test_dot()
self.assertRaises(ValueError, self.a.dot,self.bad3)
self.a.dot(self.bad4)
self.assertTrue(self.a._epoch==self.epoch)
def test_sample_frequencies(self):
with self.context:
# Moving these to the current scheme
self.a*=1
self.b*=1
self.bad3*=1
self.assertEqual(len(self.a.sample_frequencies), 3)
self.assertAlmostEqual(self.a.sample_frequencies[-1] - self.a.sample_frequencies[0], 0.2)
self.assertEqual(len(self.b.sample_frequencies), 3)
self.assertAlmostEqual(self.b.sample_frequencies[-1] - self.b.sample_frequencies[0], 0.2)
self.assertEqual(len(self.bad3.sample_frequencies), 3)
self.assertAlmostEqual(self.bad3.sample_frequencies[-1] - self.bad3.sample_frequencies[0], 0.4)
def test_save(self):
with self.context:
# make temporary file paths
temp_file = tempfile.NamedTemporaryFile()
temp_path_npy = temp_file.name + '.npy'
temp_path_txt = temp_file.name + '.txt'
# make a test frequency series
a_numpy = numpy.arange(100, dtype=self.dtype)
a = FrequencySeries(a_numpy, delta_f=0.1)
# test saving to Numpy array
a.save(temp_path_npy)
b = numpy.load(temp_path_npy)
self.assertEqual(b.shape, (a_numpy.shape[0], 2))
self.assertEqual(numpy.abs(b[:,0] - a.sample_frequencies.numpy()).max(), 0)
self.assertEqual(numpy.abs(b[:,1] - a_numpy).max(), 0)
os.remove(temp_path_npy)
# test saving to text file
a.save(temp_path_txt)
b = numpy.loadtxt(temp_path_txt)
if a.kind == 'complex':
self.assertEqual(b.shape, (a_numpy.shape[0], 3))
b = numpy.vstack((b[:,0], b[:,1] + 1j * b[:,2])).T
elif a.kind == 'real':
self.assertEqual(b.shape, (a_numpy.shape[0], 2))
self.assertEqual(numpy.abs(b[:,0] - a.sample_frequencies.numpy()).max(), 0)
self.assertEqual(numpy.abs(b[:,1] - a_numpy).max(), 0)
os.remove(temp_path_txt)
def test_maker(dtype, odtype, epoch):
class TestFrequencySeries(TestFrequencySeriesBase):
def __init__(self, *args):
self.dtype = dtype
self.odtype = odtype
self.epoch = epoch
unittest.TestCase.__init__(self, *args)
TestFrequencySeries.__name__ = _scheme + " " + dtype.__name__ + " with " + odtype.__name__
return TestFrequencySeries
types = [ (float32,[float32,complex64]), (float64,[float64,complex128]),
(complex64,[complex64,float32]), (complex128,[float64,complex128]) ]
suite = unittest.TestSuite()
# Unlike the regular array tests, we will need to test with an epoch, and with none
epochs = [lal.LIGOTimeGPS(1000, 1000),None]
i = 0
for t,otypes in types:
for ot in otypes:
for epoch in epochs:
na = 'test' + str(i)
vars()[na] = test_maker(t, ot, epoch)
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(vars()[na]))
i += 1
if __name__ == '__main__':
results = unittest.TextTestRunner(verbosity=2).run(suite)
simple_exit(results)