forked from gwastro/pycbc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_fft_unthreaded.py
66 lines (55 loc) · 2.34 KB
/
test_fft_unthreaded.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
# Copyright (C) 2012 Josh Willis, Andrew Miller
#
# 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 unit-tests for the pycbc.fft subpackage, testing only unthreaded
backends for the various schemes.
"""
import pycbc.fft
import unittest
from utils import parse_args_all_schemes, simple_exit
from fft_base import _BaseTestFFTClass, _test_lalfft
_scheme, _context = parse_args_all_schemes("FFT")
# Most of the work is now done in fft_base. Below are factories for
# creating a test for each backend of each scheme.
# Get our list of backends:
backends = pycbc.fft.get_backend_names()
FFTTestClasses = []
for backend in backends:
# This creates, for each backend, a new class derived from
# both _BaseTestFFTClass and unittest.TestCase, and with
# the additional property 'self.backend' set to the value
# of backend. One such class for each backend is appended
# to the list
kdict = {'backends' : [backend], 'scheme' : _scheme, 'context' : _context}
if _scheme == 'cpu' and backend == 'lal':
kdict.update({"test_lalfft" : _test_lalfft})
klass = type('{0}_{1}_test'.format(_scheme,backend),
(_BaseTestFFTClass,),kdict)
FFTTestClasses.append(klass)
# Finally, we create suites and run them
if __name__ == '__main__':
suite = unittest.TestSuite()
for klass in FFTTestClasses:
suite.addTest(unittest.TestLoader().loadTestsFromTestCase(klass))
results = unittest.TextTestRunner(verbosity=2).run(suite)
simple_exit(results)