Strange code in scipy.signal.decimate
Hello, I was having a look at the scipy.signal.decimate() function and I noticed some strange looking code: elif ftype == 'iir': if n is None: n = 8 system = dlti(*cheby1(n, 0.05, 0.8 / q)) b, a = system.num, system.den This is used to setup the anti aliasing low pass filter. What I don't understand is the dance to obtain the IIR numerator and denominator coefficients. Couldn't the above be simply as the code below? elif ftype == 'iir': if n is None: n = 8 b, a = cheby1(n, 0.05, 0.8 / q) Am I missing something? Thanks! Cheers, Dan
Dan, I might be missing something, but dlti returns a subclass of LinearTimeInvariant. Point is, it's not a tuple, but a class with multiple attributes and method. Simple tuple unpacking won't likely work unless the authors of LinearTimeInvariant really went out of their way to make it so. -Paul On Thu, Oct 18, 2018 at 1:58 PM Daniele Nicolodi <daniele@grinta.net> wrote:
Hello,
I was having a look at the scipy.signal.decimate() function and I noticed some strange looking code:
elif ftype == 'iir': if n is None: n = 8 system = dlti(*cheby1(n, 0.05, 0.8 / q)) b, a = system.num, system.den
This is used to setup the anti aliasing low pass filter. What I don't understand is the dance to obtain the IIR numerator and denominator coefficients. Couldn't the above be simply as the code below?
elif ftype == 'iir': if n is None: n = 8 b, a = cheby1(n, 0.05, 0.8 / q)
Am I missing something?
Thanks!
Cheers, Dan _______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org https://mail.python.org/mailman/listinfo/scipy-dev
On 18-10-2018 15:28, Paul Hobson wrote:
Dan,
I might be missing something, but dlti returns a subclass of LinearTimeInvariant. Point is, it's not a tuple, but a class with multiple attributes and method. Simple tuple unpacking won't likely work unless the authors of LinearTimeInvariant really went out of their way to make it so.
The point is not to go through the `dlti` class at all. Please look at the replacement code I posted: it works. Cheers, Dan
-Paul
On Thu, Oct 18, 2018 at 1:58 PM Daniele Nicolodi <daniele@grinta.net <mailto:daniele@grinta.net>> wrote:
Hello,
I was having a look at the scipy.signal.decimate() function and I noticed some strange looking code:
elif ftype == 'iir': if n is None: n = 8 system = dlti(*cheby1(n, 0.05, 0.8 / q)) b, a = system.num, system.den
This is used to setup the anti aliasing low pass filter. What I don't understand is the dance to obtain the IIR numerator and denominator coefficients. Couldn't the above be simply as the code below?
elif ftype == 'iir': if n is None: n = 8 b, a = cheby1(n, 0.05, 0.8 / q)
Am I missing something?
Thanks!
Cheers, Dan _______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org <mailto:SciPy-Dev@python.org> https://mail.python.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org https://mail.python.org/mailman/listinfo/scipy-dev
If you make the changes and run the test suite, do the pertinent tests pass? -Paul On Thu, Oct 18, 2018 at 2:49 PM Daniele Nicolodi <daniele@grinta.net> wrote:
On 18-10-2018 15:28, Paul Hobson wrote:
Dan,
I might be missing something, but dlti returns a subclass of LinearTimeInvariant. Point is, it's not a tuple, but a class with multiple attributes and method. Simple tuple unpacking won't likely work unless the authors of LinearTimeInvariant really went out of their way to make it so.
The point is not to go through the `dlti` class at all.
Please look at the replacement code I posted: it works.
Cheers, Dan
-Paul
On Thu, Oct 18, 2018 at 1:58 PM Daniele Nicolodi <daniele@grinta.net <mailto:daniele@grinta.net>> wrote:
Hello,
I was having a look at the scipy.signal.decimate() function and I noticed some strange looking code:
elif ftype == 'iir': if n is None: n = 8 system = dlti(*cheby1(n, 0.05, 0.8 / q)) b, a = system.num, system.den
This is used to setup the anti aliasing low pass filter. What I don't understand is the dance to obtain the IIR numerator and denominator coefficients. Couldn't the above be simply as the code below?
elif ftype == 'iir': if n is None: n = 8 b, a = cheby1(n, 0.05, 0.8 / q)
Am I missing something?
Thanks!
Cheers, Dan _______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org <mailto:SciPy-Dev@python.org> https://mail.python.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org https://mail.python.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org https://mail.python.org/mailman/listinfo/scipy-dev
On 10/18/18, Daniele Nicolodi <daniele@grinta.net> wrote:
On 18-10-2018 15:28, Paul Hobson wrote:
Dan,
I might be missing something, but dlti returns a subclass of LinearTimeInvariant. Point is, it's not a tuple, but a class with multiple attributes and method. Simple tuple unpacking won't likely work unless the authors of LinearTimeInvariant really went out of their way to make it so.
The point is not to go through the `dlti` class at all.
Please look at the replacement code I posted: it works.
There have been several incremental changes to that function over the years. I suspect the last person to change it simply did not notice that the code could be simplified. Your proposed change looks good. Warren
Cheers, Dan
-Paul
On Thu, Oct 18, 2018 at 1:58 PM Daniele Nicolodi <daniele@grinta.net <mailto:daniele@grinta.net>> wrote:
Hello,
I was having a look at the scipy.signal.decimate() function and I noticed some strange looking code:
elif ftype == 'iir': if n is None: n = 8 system = dlti(*cheby1(n, 0.05, 0.8 / q)) b, a = system.num, system.den
This is used to setup the anti aliasing low pass filter. What I don't understand is the dance to obtain the IIR numerator and denominator coefficients. Couldn't the above be simply as the code below?
elif ftype == 'iir': if n is None: n = 8 b, a = cheby1(n, 0.05, 0.8 / q)
Am I missing something?
Thanks!
Cheers, Dan _______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org <mailto:SciPy-Dev@python.org> https://mail.python.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org https://mail.python.org/mailman/listinfo/scipy-dev
_______________________________________________ SciPy-Dev mailing list SciPy-Dev@python.org https://mail.python.org/mailman/listinfo/scipy-dev
participants (3)
-
Daniele Nicolodi -
Paul Hobson -
Warren Weckesser