[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/02: filter: allow small rounding error i
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/02: filter: allow small rounding error in oversample rate setting for pfb_channelizer. |
Date: |
Mon, 5 May 2014 13:15:46 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch maint
in repository gnuradio.
commit 336e49ea77ccb57b3eaa3cb8c2b822e9d4f48880
Author: Jiri Pinkava <address@hidden>
Date: Mon May 5 07:17:10 2014 -0400
filter: allow small rounding error in oversample rate setting for
pfb_channelizer.
---
gr-filter/lib/pfb_channelizer_ccf_impl.cc | 8 ++++----
gr-filter/python/filter/qa_pfb_channelizer.py | 13 +++++++++++++
2 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/gr-filter/lib/pfb_channelizer_ccf_impl.cc
b/gr-filter/lib/pfb_channelizer_ccf_impl.cc
index 62223e4..d4f099f 100644
--- a/gr-filter/lib/pfb_channelizer_ccf_impl.cc
+++ b/gr-filter/lib/pfb_channelizer_ccf_impl.cc
@@ -55,12 +55,12 @@ namespace gr {
// of [fs/N, fs] where fs is the input sample rate.
// This tests the specified input sample rate to see if it conforms to
this
// requirement within a few significant figures.
- double intp = 0;
- double fltp = modf(nfilts / oversample_rate, &intp);
- if(fltp != 0.0)
+ const double srate = nfilts / oversample_rate;
+ const double rsrate = round(srate);
+ if(fabsf(srate - rsrate) > 0.00001)
throw std::invalid_argument("pfb_channelizer: oversample rate must be
N/i for i in [1, N]");
- set_relative_rate(1.0/intp);
+ set_relative_rate(1.0/srate);
// Default channel map. The channel map specifies which input
// goes to which output channel; so out[0] comes from
diff --git a/gr-filter/python/filter/qa_pfb_channelizer.py
b/gr-filter/python/filter/qa_pfb_channelizer.py
index 46c6e7b..3a1eb06 100755
--- a/gr-filter/python/filter/qa_pfb_channelizer.py
+++ b/gr-filter/python/filter/qa_pfb_channelizer.py
@@ -112,5 +112,18 @@ class test_pfb_channelizer(gr_unittest.TestCase):
self.assertComplexTuplesAlmostEqual(expected3_data[-Ntest:],
dst3_data[-Ntest:], 3)
self.assertComplexTuplesAlmostEqual(expected4_data[-Ntest:],
dst4_data[-Ntest:], 3)
+ def test_0002(self):
+ """Test roundig error handling for oversample rate (ok)."""
+ channels, oversample = 36, 25.
+ filter.pfb.channelizer_ccf(channels, taps=self.taps,
+ oversample_rate=channels/oversample)
+
+ def test_0003(self):
+ """Test roundig error handling for oversample rate, (bad)."""
+ self.assertRaises(RuntimeError,
+ filter.pfb.channelizer_ccf,
+ 36, taps=self.taps, oversample_rate=10.1334)
+
+
if __name__ == '__main__':
gr_unittest.run(test_pfb_channelizer, "test_pfb_channelizer.xml")