From 7ad16f4e4c70d91ca878b33b8d5b262be881f9d5 Mon Sep 17 00:00:00 2001 From: Daniel Williams Date: Wed, 19 Sep 2018 15:22:55 +0100 Subject: [PATCH] Added a WNB test Added a test to ensure that WNB waveforms are the same each time that they're generated (i.e to ensure that they're generated using the same random seed. --- tests/test_sources.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/test_sources.py b/tests/test_sources.py index b57ae0c..7b6db0b 100755 --- a/tests/test_sources.py +++ b/tests/test_sources.py @@ -149,6 +149,33 @@ class TestMinkeAdHocSources(unittest.TestCase): 8.41779831e-31, 1.43679337e-31, 6.07001624e-33]) np.testing.assert_array_almost_equal(data[0].data.data[::5000], scdata) + + +class TestMinkeWNBSources(unittest.TestCase): + """ + Run tests on the creation of white noise bursts to + ensure that these are produced as expected. + """ + + def setUp(self): + """ + Set everything up to make things work. + """ + self.mdcset = mdctools.MDCSet(['L1', 'H1']) + self.times = distribution.even_time(start = 1126620016, stop = 1136995216, rate = 630720, jitter = 20) + + def test_random_seed(self): + """Check that the WNB source produces the same waveform each time it is + called with the same seed.""" + + sc = sources.WhiteNoiseBurst(0.1, 10, 1024, 1126620016) + + hp, hx, _, _ = sc._generate() + hp2, hx2, _, _ = sc._generate() + + np.testing.assert_array_almost_equal(hp.data.data, hp2.data.data) + + class TestMinkeADISources(unittest.TestCase): def setUp(self): -- GitLab