diff options
Diffstat (limited to 'gr-analog')
-rw-r--r-- | gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t | 3 | ||||
-rw-r--r-- | gr-analog/lib/fastnoise_source_X_impl.cc.t | 4 | ||||
-rw-r--r-- | gr-analog/lib/fastnoise_source_X_impl.h.t | 1 | ||||
-rw-r--r-- | gr-analog/python/analog/qa_fastnoise.py | 22 |
4 files changed, 29 insertions, 1 deletions
diff --git a/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t b/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t index 850633979c..f588299604 100644 --- a/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t +++ b/gr-analog/include/gnuradio/analog/fastnoise_source_X.h.t @@ -29,6 +29,8 @@ #include <gnuradio/analog/noise_type.h> #include <gnuradio/sync_block.h> +#include <vector> + namespace gr { namespace analog { @@ -62,6 +64,7 @@ namespace gr { long seed = 0, long samples=1024*16); virtual @TYPE@ sample() = 0; virtual @TYPE@ sample_unbiased() = 0; + virtual const std::vector<@TYPE@>& samples() const = 0; /*! * Set the noise type. Nominally from the diff --git a/gr-analog/lib/fastnoise_source_X_impl.cc.t b/gr-analog/lib/fastnoise_source_X_impl.cc.t index 9283f11733..72c6cb0582 100644 --- a/gr-analog/lib/fastnoise_source_X_impl.cc.t +++ b/gr-analog/lib/fastnoise_source_X_impl.cc.t @@ -163,5 +163,9 @@ namespace gr { #endif } + const std::vector<@TYPE@>& @IMPL_NAME@::samples() const + { + return d_samples; + } } /* namespace analog */ } /* namespace gr */ diff --git a/gr-analog/lib/fastnoise_source_X_impl.h.t b/gr-analog/lib/fastnoise_source_X_impl.h.t index 5bea010e62..ef0465729d 100644 --- a/gr-analog/lib/fastnoise_source_X_impl.h.t +++ b/gr-analog/lib/fastnoise_source_X_impl.h.t @@ -50,6 +50,7 @@ namespace gr { void set_type(noise_type_t type); void set_amplitude(float ampl); void generate(); + const std::vector<@TYPE@>& samples() const; noise_type_t type() const { return d_type; } float amplitude() const { return d_ampl; } diff --git a/gr-analog/python/analog/qa_fastnoise.py b/gr-analog/python/analog/qa_fastnoise.py index a7730ffcb1..f712d66ca7 100644 --- a/gr-analog/python/analog/qa_fastnoise.py +++ b/gr-analog/python/analog/qa_fastnoise.py @@ -30,7 +30,7 @@ class test_fastnoise_source(gr_unittest.TestCase): self.num = 2**22 self.num_items = 10**6 - self.default_args = {"samples": self.num, "seed": int(43), "ampl": 1} + self.default_args = {"samples": self.num, "seed": 43, "ampl": 1} def tearDown (self): pass @@ -115,5 +115,25 @@ class test_fastnoise_source(gr_unittest.TestCase): self.assertTrue(numpy.array_equal(data1, data2)) + def test_003_real_uniform_pool(self): + src = analog.fastnoise_source_f(type=analog.GR_UNIFORM, **self.default_args) + src2 = analog.fastnoise_source_f(type=analog.GR_UNIFORM, **self.default_args) + self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples()))) + def test_003_real_gaussian_pool(self): + src = analog.fastnoise_source_f(type=analog.GR_GAUSSIAN, **self.default_args) + src2 = analog.fastnoise_source_f(type=analog.GR_GAUSSIAN, **self.default_args) + self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples()))) + def test_003_cmplx_gaussian_pool(self): + src = analog.fastnoise_source_c(type=analog.GR_GAUSSIAN, **self.default_args) + src2 = analog.fastnoise_source_c(type=analog.GR_GAUSSIAN, **self.default_args) + self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples()))) + def test_003_cmplx_uniform_pool(self): + src = analog.fastnoise_source_c(type=analog.GR_UNIFORM, **self.default_args) + src2 = analog.fastnoise_source_c(type=analog.GR_UNIFORM, **self.default_args) + self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples()))) + def test_003_real_laplacian_pool(self): + src = analog.fastnoise_source_f(type=analog.GR_LAPLACIAN, **self.default_args) + src2 = analog.fastnoise_source_f(type=analog.GR_LAPLACIAN, **self.default_args) + self.assertTrue(numpy.array_equal(numpy.array(src.samples()), numpy.array(src2.samples()))) if __name__ == '__main__': gr_unittest.run(test_fastnoise_source, "test_fastnoise_source.xml") |