-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
DEP: signal: remove support for object arrays and longdoubles in {correlate,convolve,lfilter,sosfilter}
#23212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…al.{correlate,convolve,lfilter,sosfilter}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Can also remove some C code, too: https://github.com/scipy/scipy/blob/main/scipy/signal/_lfilter.cc#L24, https://github.com/scipy/scipy/blob/main/scipy/signal/_correlate_nd.cc#L181 and maybe some more from the _sigtools
extension.
Can be done either here or in a follow-up though.
{correlate,convolve,lfilter,sosfilter}
Done thanks, that made me spot a few areas I'd missed |
In fact, also |
139831b
to
b17bf7d
Compare
Co-authored-by: Evgeni Burovski <evgeny.burovskiy@gmail.com>
I think the CI failure is due to this line: https://github.com/scipy/scipy/blob/main/scipy/signal/tests/test_signaltools.py#L2951: |
8836a50
to
5ed36db
Compare
This patch seems to fix the dask failure: $ git diff
diff --git a/scipy/signal/_signaltools.py b/scipy/signal/_signaltools.py
index 2cdb6c45c4..b085f758f4 100644
--- a/scipy/signal/_signaltools.py
+++ b/scipy/signal/_signaltools.py
@@ -4755,6 +4755,7 @@ def filtfilt(b, a, x, axis=-1, padtype='odd', padlen=None, method='pad',
# method == "pad"
edge, ext = _validate_pad(padtype, padlen, x, axis,
ntaps=max(len(a), len(b)))
+ ext = xp.asarray(ext)
# Get the steady state of the filter's step response.
zi = lfilter_zi(b, a) EDIT: Sorry, no. The patch above is wrong, and causes other issues elsewhere. A correct patch: $ git diff
diff --git a/scipy/signal/_signaltools.py b/scipy/signal/_signaltools.py
index 2cdb6c45c4..61460f999b 100644
--- a/scipy/signal/_signaltools.py
+++ b/scipy/signal/_signaltools.py
@@ -4741,8 +4741,8 @@ def filtfilt(b, a, x, axis=-1, padtype='odd', padlen=None, method='pad',
"""
xp = array_namespace(b, a, x)
- b = np.atleast_1d(b)
- a = np.atleast_1d(a)
+ b = np.atleast_1d(np.asarray(b))
+ a = np.atleast_1d(np.asarray(a))
x = np.asarray(x)
if method not in ["pad", "gust"]:
diff --git a/scipy/signal/tests/test_signaltools.py b/scipy/signal/tests/test_signaltools.py
index 8d6f82bedd..f922e5c606 100644
--- a/scipy/signal/tests/test_signaltools.py
+++ b/scipy/signal/tests/test_signaltools.py
@@ -1649,8 +1649,7 @@ class TestResample:
x[0] = 0
x[-1] = 0
- h = signal.firwin(31, 1. / down_factor, window='hamming')
- h = xp.asarray(h) # XXX: convert firwin
+ h = signal.firwin(31, xp.asarray(1. / down_factor), window='hamming')
yf = filtfilt(h, 1.0, x, padtype='constant')[::down_factor]
# Need to pass convolved version of filter to resample_poly, The underlying reason is that |
Array-api-strict test failure is fixed by this: @@ -2803,7 +2802,7 @@ class TestFiltFilt:
if is_jax(xp) and self.filtfilt_kind == 'sos':
pytest.skip(reason='sosfilt works in-place')
- zpk = tf2zpk(xp.asarray([1, 2, 3]), xp.asarray([1, 2, 3]))
+ zpk = tf2zpk(xp.asarray([1.0, 2, 3]), xp.asarray([1.0, 2, 3]))
out = self.filtfilt(zpk, xp.arange(12), xp=xp)
atol= 3e-9 if is_cupy(xp) else 5.28e-11
xp_assert_close(out, xp.arange(12, dtype=xp.float64), atol=atol) The what remains is a small tolerance bump on CuPy. Phew. |
CI finally green, hopefully this is ready to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks Jake, great cleanup!
Minus 500 LOC of obscure C code, yay! |
Is there anywhere else we're hiding compiled code just for handling object arrays? |
Let's see:
Don't know about Let's see about object arrays in pure python:
ISTM we can discount |
As part of array api conversion support for object arrays is scheduled for removal in this release.