Repository: scipy/scipy (Python)

Issue:
BUG: signal.resample_poly returns an array consisting only of zeroes, if the input data type is int32 or int16
### Describe your issue.

This appears to be a regression, I think there was no such problem in previous versions.
`signal.resample_poly` would return an obviously wrong result (array with only zeroes) if the input is of data type "int16" or "int32".

A workaround would be to manually convert the input to floats before calling resample_poly.

### Reproducing Code Example

```python
import numpy
from scipy import signal


def example(dtype: str):
    example_input = numpy.fromiter([0, 1, 2, 3, 2, 1, 0], dtype=dtype)
    result = signal.resample_poly(example_input, up=2, down=1, padtype='smooth')
    print(f'dtype = {dtype}, result = {result}')


for dtype in ['int16', 'int32', 'float32', 'float64']:
    example(dtype) # for int types, results will be only zeroes
```


### Error message

```shell
(not an error message, but the output of the Reproducing Code Example)

dtype = int16, result = [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
dtype = int32, result = [0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]
dtype = float32, result = [ 2.9888927e-17  4.6809512e-01  1.0005175e+00  1.4470936e+00
  2.0010350e+00  2.6719987e+00  3.0015526e+00  2.6719987e+00
  2.0010350e+00  1.4470937e+00  1.0005175e+00  4.6809512e-01
  2.9888924e-17 -1.2663580e-01]
dtype = float64, result = [ 2.98889238e-17  4.68095127e-01  1.00051747e+00  1.44709367e+00
  2.00103494e+00  2.67199884e+00  3.00155241e+00  2.67199884e+00
  2.00103494e+00  1.44709367e+00  1.00051747e+00  4.68095127e-01
  2.98889238e-17 -1.26635803e-01]
```


### SciPy/NumPy/Python version information

1.8.0 1.22.2 sys.version_info(major=3, minor=10, micro=2, releaselevel='final', serial=0)


Discussion:
Thats a real issue in 1.11.1 that wasn't present in older version. This require existing code to be modified in order to run correctly.
I've just been running in to this as well in scipy 1.13.1. Very weird behavior. Sad it isn't yet fixed.



Patch:
diff --git a/scipy/signal/_signaltools.py b/scipy/signal/_signaltools.py
index 0332a77cb0f9..d7d92b81d39e 100644
--- a/scipy/signal/_signaltools.py
+++ b/scipy/signal/_signaltools.py
@@ -3416,8 +3416,12 @@ def resample_poly(x, up, down, axis=0, window=('kaiser', 5.0),
         max_rate = max(up, down)
         f_c = 1. / max_rate  # cutoff of FIR filter (rel. to Nyquist)
         half_len = 10 * max_rate  # reasonable cutoff for sinc-like function
-        h = firwin(2 * half_len + 1, f_c,
-                   window=window).astype(x.dtype)  # match dtype of x
+        if np.issubdtype(x.dtype, np.floating):
+            h = firwin(2 * half_len + 1, f_c,
+                       window=window).astype(x.dtype)  # match dtype of x
+        else:
+            h = firwin(2 * half_len + 1, f_c,
+                       window=window)
     h *= up
 
     # Zero-pad our filter to put the output samples at the center


Test patch:
diff --git a/scipy/signal/tests/test_signaltools.py b/scipy/signal/tests/test_signaltools.py
index c58cf6891d4e..a8fae577ca71 100644
--- a/scipy/signal/tests/test_signaltools.py
+++ b/scipy/signal/tests/test_signaltools.py
@@ -1414,6 +1414,15 @@ def test_correlate1d(self):
                         x, up=1, down=down, window=weights)
                     assert_allclose(y_g[::down], y_s)
 
+    @pytest.mark.parametrize('dtype', [np.int32, np.float32])
+    def test_gh_15620(self, dtype):
+        data = np.array([0, 1, 2, 3, 2, 1, 0], dtype=dtype)
+        actual = signal.resample_poly(data,
+                                      up=2,
+                                      down=1,
+                                      padtype='smooth')
+        assert np.count_nonzero(actual) > 0
+
 
 class TestCSpline1DEval: