Skip to content

Commit c8177d7

Browse files
committed
TST: signal: temp workarounds for tf2sos being numpy-only
1 parent c4cee61 commit c8177d7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

scipy/signal/_filter_design.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,7 +2030,6 @@ def lp2hp(b, a, wo=1.0):
20302030
pwo = xp.ones(max((d, n)), dtype=b.dtype)
20312031
if d >= n:
20322032
outa = xp.flip(a) * pwo
2033-
outb = xp.concat((xp.zeros(n, dtype=b.dtype), ))
20342033
outb = _resize(b, (d,), xp=xp)
20352034
outb[n:] = 0.0
20362035
outb[:n] = xp.flip(b) * pwo[:n]

scipy/signal/tests/test_signaltools.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,7 +4154,8 @@ def test_rank1(self, dt, xp):
41544154

41554155
# Test simple IIR
41564156
y_r = xp.asarray([0, 2, 4, 6, 8, 10.], dtype=dt)
4157-
sos = tf2sos(b, a)
4157+
bb, aa = map(np.asarray, (b, a))
4158+
sos = tf2sos(bb, aa)
41584159
sos = xp.asarray(sos) # XXX while tf2sos is numpy only
41594160
assert_array_almost_equal(sosfilt(sos, x), y_r)
41604161

@@ -4163,7 +4164,8 @@ def test_rank1(self, dt, xp):
41634164
# NOTE: This was changed (rel. to TestLinear...) to add a pole @zero:
41644165
a = xp.asarray([1, 0], dtype=dt)
41654166
y_r = xp.asarray([0, 1, 3, 5, 7, 9.], dtype=dt)
4166-
sos = tf2sos(b, a)
4167+
bb, aa = map(np.asarray, (b, a))
4168+
sos = tf2sos(bb, aa)
41674169
sos = xp.asarray(sos) # XXX while tf2sos is numpy only
41684170
assert_array_almost_equal(sosfilt(sos, x), y_r)
41694171

@@ -4193,12 +4195,13 @@ def test_rank2(self, dt, xp):
41934195
y_r2_a1 = xp.asarray([[0, 2, 0], [6, -4, 6], [12, -10, 12],
41944196
[18, -16, 18]], dtype=dt)
41954197

4196-
sos = tf2sos(b, a)
4198+
bb, aa = map(np.asarray, (b, a))
4199+
sos = tf2sos(bb, aa)
41974200
sos = xp.asarray(sos) # XXX
41984201
y = sosfilt(sos, x, axis=0)
41994202
assert_array_almost_equal(y_r2_a0, y)
42004203

4201-
sos = tf2sos(b, a)
4204+
sos = tf2sos(bb, aa)
42024205
sos = xp.asarray(sos) # XXX
42034206
y = sosfilt(sos, x, axis=1)
42044207
assert_array_almost_equal(y_r2_a1, y)
@@ -4215,7 +4218,8 @@ def test_rank3(self, dt, xp):
42154218
a = xp.asarray([0.5, 0.5], dtype=dt)
42164219

42174220
# Test last axis
4218-
sos = tf2sos(b, a)
4221+
bb, aa = map(np.asarray, (b, a)) # XXX until tf2sos is array api compatible
4222+
sos = tf2sos(bb, aa)
42194223
sos = xp.asarray(sos) # XXX
42204224
y = sosfilt(sos, x)
42214225
for i in range(x.shape[0]):

0 commit comments

Comments
 (0)