Skip to content

Commit c4cee61

Browse files
committed
BUG: signal: make normalize accept object arrays, fix _align_num
Object arrays are explicitly used in test_ltisys.py::TestSS2TF::test_simo_round_trip
1 parent 1de1169 commit c4cee61

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

scipy/signal/_filter_design.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import scipy._lib.array_api_extra as xpx
2121
from scipy._lib._array_api import array_namespace, xp_promote, xp_size
22+
from scipy._lib.array_api_compat import numpy as np_compat
2223

2324

2425
__all__ = ['findfreqs', 'freqs', 'freqz', 'tf2zpk', 'zpk2tf', 'normalize',
@@ -1716,7 +1717,7 @@ def _align_nums(nums, xp):
17161717
max_width = max(xp_size(num) for num in nums)
17171718

17181719
# pre-allocate
1719-
aligned_nums = xp.zeros((nums.shape[0], max_width))
1720+
aligned_nums = xp.zeros((len(nums), max_width))
17201721

17211722
# Create numerators with padded zeros
17221723
for index, num in enumerate(nums):
@@ -1801,7 +1802,11 @@ def normalize(b, a):
18011802
Badly conditioned filter coefficients (numerator): the results may be meaningless
18021803
18031804
"""
1804-
xp = array_namespace(b, a)
1805+
try:
1806+
xp = array_namespace(b, a)
1807+
except TypeError:
1808+
# object arrays, test_ltisys.py::TestSS2TF::test_simo_round_trip
1809+
xp = np_compat
18051810

18061811
den = xp.asarray(a)
18071812
den = xpx.atleast_nd(den, ndim=1, xp=xp)

0 commit comments

Comments
 (0)