Skip to content

Commit e738314

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 7f2c29a commit e738314

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
@@ -18,6 +18,7 @@
1818

1919
import scipy._lib.array_api_extra as xpx
2020
from scipy._lib._array_api import array_namespace, xp_promote, xp_size
21+
from scipy._lib.array_api_compat import numpy as np_compat
2122

2223

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

17171718
# pre-allocate
1718-
aligned_nums = xp.zeros((nums.shape[0], max_width))
1719+
aligned_nums = xp.zeros((len(nums), max_width))
17191720

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

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

0 commit comments

Comments
 (0)