Skip to content

Commit ba1f9b9

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

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
@@ -2029,7 +2029,6 @@ def lp2hp(b, a, wo=1.0):
20292029
pwo = xp.ones(max((d, n)), dtype=b.dtype)
20302030
if d >= n:
20312031
outa = xp.flip(a) * pwo
2032-
outb = xp.concat((xp.zeros(n, dtype=b.dtype), ))
20332032
outb = _resize(b, (d,), xp=xp)
20342033
outb[n:] = 0.0
20352034
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
@@ -4069,7 +4069,8 @@ def test_rank1(self, dt, xp):
40694069

40704070
# Test simple IIR
40714071
y_r = xp.asarray([0, 2, 4, 6, 8, 10.], dtype=dt)
4072-
sos = tf2sos(b, a)
4072+
bb, aa = map(np.asarray, (b, a))
4073+
sos = tf2sos(bb, aa)
40734074
sos = xp.asarray(sos) # XXX while tf2sos is numpy only
40744075
assert_array_almost_equal(sosfilt(sos, x), y_r)
40754076

@@ -4078,7 +4079,8 @@ def test_rank1(self, dt, xp):
40784079
# NOTE: This was changed (rel. to TestLinear...) to add a pole @zero:
40794080
a = xp.asarray([1, 0], dtype=dt)
40804081
y_r = xp.asarray([0, 1, 3, 5, 7, 9.], dtype=dt)
4081-
sos = tf2sos(b, a)
4082+
bb, aa = map(np.asarray, (b, a))
4083+
sos = tf2sos(bb, aa)
40824084
sos = xp.asarray(sos) # XXX while tf2sos is numpy only
40834085
assert_array_almost_equal(sosfilt(sos, x), y_r)
40844086

@@ -4108,12 +4110,13 @@ def test_rank2(self, dt, xp):
41084110
y_r2_a1 = xp.asarray([[0, 2, 0], [6, -4, 6], [12, -10, 12],
41094111
[18, -16, 18]], dtype=dt)
41104112

4111-
sos = tf2sos(b, a)
4113+
bb, aa = map(np.asarray, (b, a))
4114+
sos = tf2sos(bb, aa)
41124115
sos = xp.asarray(sos) # XXX
41134116
y = sosfilt(sos, x, axis=0)
41144117
assert_array_almost_equal(y_r2_a0, y)
41154118

4116-
sos = tf2sos(b, a)
4119+
sos = tf2sos(bb, aa)
41174120
sos = xp.asarray(sos) # XXX
41184121
y = sosfilt(sos, x, axis=1)
41194122
assert_array_almost_equal(y_r2_a1, y)
@@ -4130,7 +4133,8 @@ def test_rank3(self, dt, xp):
41304133
a = xp.asarray([0.5, 0.5], dtype=dt)
41314134

41324135
# Test last axis
4133-
sos = tf2sos(b, a)
4136+
bb, aa = map(np.asarray, (b, a)) # XXX until tf2sos is array api compatible
4137+
sos = tf2sos(bb, aa)
41344138
sos = xp.asarray(sos) # XXX
41354139
y = sosfilt(sos, x)
41364140
for i in range(x.shape[0]):

0 commit comments

Comments
 (0)