internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: scipy/scipy

Issue:
DOC: Formula of Tustin formula in scipy.signal.bilinear misses "fs*2"
### Formula of Tustin formula in scipy.signal.bilinear misses "fs*2"

The Tustin formula in

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.bilinear.html

is described as (z-1) / (z+1)

but it should be fs*2*(z-1) / (z+1)

The implementation is correct, its only the formula in 

https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.bilinear.html

that is wrong.

Here a simple example of the discretization of the lti $H(s)=\frac{1}{s}$ with the bilinear transform $s(z)=\frac{2}{T}\frac{z-1}{z+1}$ giving $H(z)=\frac{T}{s}\frac{z+1}{z-1}$


### Reproducing Code Example

```python
from scipy.signal import bilinear

num, den = bilinear([0, 1], [1, 0], 1/T)

print(num, den)

num_m = (T/2)*np.array([1, 1]) # manual usage of Tustin reads as ((2/T)*(z-1)/(z+1)))^-1
den_m = np.array([1, -1])

print(num_m, den_m)
```


### Error message

```shell
no error
```


### SciPy/NumPy/Python version information

1.5.0 1.18.5 sys.version_info(major=3, minor=8, micro=3, releaselevel='final', serial=0)


Discussion:
@zolabar  Indeed it is a mistake in the documentation, care to fix it with a PR in case you would like to contribute? Otherwise we can handle it too. 
> @zolabar Indeed it is a mistake in the documentation, care to fix it with a PR in case you would like to contribute? Otherwise we can handle it too.

@ilayn, ok, thanks for the feedback. I‘ll do the pr

Resolving patch:
diff --git a/scipy/signal/_filter_design.py b/scipy/signal/_filter_design.py
--- a/scipy/signal/_filter_design.py
+++ b/scipy/signal/_filter_design.py
@@ -2095,7 +2095,7 @@ def bilinear(b, a, fs=1.0):
     Return a digital IIR filter from an analog one using a bilinear transform.
 
     Transform a set of poles and zeros from the analog s-plane to the digital
-    z-plane using Tustin's method, which substitutes ``(z-1) / (z+1)`` for
+    z-plane using Tustin's method, which substitutes ``2*fs*(z-1) / (z+1)`` for
     ``s``, maintaining the shape of the frequency response.
 
     Parameters
@@ -2615,7 +2615,7 @@ def bilinear_zpk(z, p, k, fs):
     Return a digital IIR filter from an analog one using a bilinear transform.
 
     Transform a set of poles and zeros from the analog s-plane to the digital
-    z-plane using Tustin's method, which substitutes ``(z-1) / (z+1)`` for
+    z-plane using Tustin's method, which substitutes ``2*fs*(z-1) / (z+1)`` for
     ``s``, maintaining the shape of the frequency response.
 
     Parameters


Test patch:
Repository: scipy/scipy

Issue:
DOC: Setting correct number of knots in splprep for task=-1
### Describe your issue.

I can't get splprep for task=-1 to work.

No matter what number I use for the number of knots I always get this error message. I also tried setting k to different values, but that didn't help either.

The [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.splprep.html) says that t must be an integer, but I've seen examples using an array:

```
t: int, optional
    The knots needed for task=-1.
```

I haven't looked at the code yet.


### Reproducing Code Example

```python
import numpy as np
from scipy import interpolate
s = np.linspace(0, 1, 10000)

tck, u = interpolate.splprep([np.sin(s), np.cos(s)], task=-1, t=100,)
```


### Error message

```shell
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/scipy/interpolate/_fitpack_py.py", line 153, in splprep
    res = _impl.splprep(x, w, u, ub, ue, k, task, s, t, full_output, nest, per,
  File "/usr/local/lib/python3.9/site-packages/scipy/interpolate/_fitpack_impl.py", line 260, in splprep
    raise TypeError('There must be at least 2*k+2 knots for task=-1')
TypeError: There must be at least 2*k+2 knots for task=-1
```


### SciPy/NumPy/Python version information

1.10.0 1.24.1 sys.version_info(major=3, minor=9, micro=16, releaselevel='final', serial=0)


Discussion:
You need to supply the knots themselves, not just their number, I'm afraid. 
Yes, this is the case.

Looking into the source file. `t` is clearly an array:

https://github.com/scipy/scipy/blob/dde50595862a4f9cede24b5d1c86935c30f1f88a/scipy/interpolate/fitpack/parcur.f#L103-L104

https://github.com/scipy/scipy/blob/dde50595862a4f9cede24b5d1c86935c30f1f88a/scipy/interpolate/fitpack/parcur.f#L95

https://github.com/scipy/scipy/blob/dde50595862a4f9cede24b5d1c86935c30f1f88a/scipy/interpolate/fitpack/parcur.f#L260

Therefore, this is a documentation bug.
Hi! I'd like to work on this, but I'm new to open source. Can someone please guide me through this? :D

Resolving patch:
diff --git a/scipy/interpolate/_fitpack_py.py b/scipy/interpolate/_fitpack_py.py
--- a/scipy/interpolate/_fitpack_py.py
+++ b/scipy/interpolate/_fitpack_py.py
@@ -63,8 +63,9 @@ def splprep(x, w=None, u=None, ub=None, ue=None, k=3, task=0, s=None, t=None,
         standard-deviation of y, then a good `s` value should be found in
         the range ``(m-sqrt(2*m),m+sqrt(2*m))``, where m is the number of
         data points in x, y, and w.
-    t : int, optional
-        The knots needed for task=-1.
+    t : array, optional
+        The knots needed for ``task=-1``.
+        There must be at least ``2*k+2`` knots.
     full_output : int, optional
         If non-zero, then return optional outputs.
     nest : int, optional


Test patch:
Repository: scipy/scipy

Issue:
BUG: wrong dependencies for pooch
Pooch made an update which removes the deps to `appdirs`. Apparently we should update to `platformdirs`. See https://github.com/fatiando/pooch/pull/339

It means our CI is failing with: https://dev.azure.com/scipy-org/SciPy/_build/results?buildId=23474&view=logs&jobId=ede89041-5e8e-5201-ce5c-f68c2cbf02dd&j=ede89041-5e8e-5201-ce5c-f68c2cbf02dd&t=bf6d2fae-c4b4-5aaf-e29f-d3092465da33

```
scipy.datasets.clear_cache
--------------------------

File "build/testenv/lib/python3.9/site-packages/scipy/datasets/_utils.py", line 78, in clear_cache
Failed example:
    datasets.clear_cache([datasets.ascent])
Exception raised:
    Traceback (most recent call last):
      File "/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/doctest.py", line 1334, in __run
        exec(compile(example.source, filename, "single",
      File "<doctest clear_cache[3]>", line 1, in <module>
        datasets.clear_cache([datasets.ascent])
      File "/home/vsts/work/1/s/build/testenv/lib/python3.9/site-packages/scipy/datasets/_utils.py", line 81, in clear_cache
        _clear_cache(datasets)
      File "/home/vsts/work/1/s/build/testenv/lib/python3.9/site-packages/scipy/datasets/_utils.py", line 19, in _clear_cache
        raise ImportError("Missing optional dependency 'pooch' required "
    ImportError: Missing optional dependency 'pooch' required for scipy.datasets module. Please use pip or conda to install 'pooch'.
```

cc @AnirudhDagar


Discussion:

Resolving patch:
diff --git a/scipy/datasets/_utils.py b/scipy/datasets/_utils.py
--- a/scipy/datasets/_utils.py
+++ b/scipy/datasets/_utils.py
@@ -3,9 +3,9 @@
 from ._registry import method_files_map
 
 try:
-    import appdirs
+    import platformdirs
 except ImportError:
-    appdirs = None
+    platformdirs = None
 
 
 def _clear_cache(datasets, cache_dir=None, method_map=None):
@@ -14,12 +14,12 @@ def _clear_cache(datasets, cache_dir=None, method_map=None):
         method_map = method_files_map
     if cache_dir is None:
         # Use default cache_dir path
-        if appdirs is None:
-            # appdirs is pooch dependency
+        if platformdirs is None:
+            # platformdirs is pooch dependency
             raise ImportError("Missing optional dependency 'pooch' required "
                               "for scipy.datasets module. Please use pip or "
                               "conda to install 'pooch'.")
-        cache_dir = appdirs.user_cache_dir("scipy-data")
+        cache_dir = platformdirs.user_cache_dir("scipy-data")
 
     if not os.path.exists(cache_dir):
         print(f"Cache Directory {cache_dir} doesn't exist. Nothing to clear.")


Test patch:
Repository: scipy/scipy

Issue:
DEP: Warn on deprecated windows-import in base `scipy.signal` namespace
This was discussed in #7898 and executed in #7900 for SciPy 1.1. However, the deprecation mechanism there only inserts a warning into the docstring.

I think we should start emitting actual DeprecationWarnings for those functions that are imported from the wrong name space (i.e. `scipy.signal.<x>` instead of `scipy.signal.windows.<x>`).

CC @larsoner @rgommers 


Discussion:
That sounds good to me, it's been long enough.
OK cool. Milestoning this for 1.11, in case we still manage to squeeze it in. FYI, in case you're interested @j-bowhay ;-)
Agreed!

Resolving patch:
diff --git a/scipy/signal/__init__.py b/scipy/signal/__init__.py
--- a/scipy/signal/__init__.py
+++ b/scipy/signal/__init__.py
@@ -306,6 +306,8 @@
 use the classes to create a reusable function instead.
 
 """
+import warnings
+
 from . import _sigtools, windows
 from ._waveforms import *
 from ._max_len_seq import max_len_seq
@@ -351,6 +353,11 @@ def deco(name):
     # Add deprecation to docstring
 
     def wrapped(*args, **kwargs):
+        warnings.warn(f"Importing {name} from 'scipy.signal' is deprecated "
+                      "and will raise an error in SciPy 1.13.0. Please use "
+                      f"'scipy.signal.window.{name}' or the convenience "
+                      "function 'scipy.signal.get_window' instead.",
+                      DeprecationWarning, stacklevel=2)
         return f(*args, **kwargs)
 
     wrapped.__name__ = name
@@ -379,7 +386,7 @@ def wrapped(*args, **kwargs):
 
 del deprecated_windows, name, deco
 
-__all__ = [s for s in dir() if not s.startswith('_')]
+__all__ = [s for s in dir() if not s.startswith('_') and s != "warnings"]
 
 from scipy._lib._testutils import PytestTester
 test = PytestTester(__name__)


Test patch:
diff --git a/scipy/signal/tests/test_windows.py b/scipy/signal/tests/test_windows.py
--- a/scipy/signal/tests/test_windows.py
+++ b/scipy/signal/tests/test_windows.py
@@ -6,10 +6,12 @@
                            assert_allclose,
                            assert_equal, assert_, assert_array_less,
                            suppress_warnings)
+import pytest
 from pytest import raises as assert_raises
 
 from scipy.fft import fft
 from scipy.signal import windows, get_window, resample, hann as dep_hann
+from scipy import signal
 
 
 window_funcs = [
@@ -37,6 +39,15 @@
     ('lanczos', ()),
     ]
 
+@pytest.mark.parametrize(["method", "args"], window_funcs)
+def test_deprecated_import(method, args):
+    if method in ('taylor', 'lanczos', 'dpss'):
+        pytest.skip("Deprecation test not applicable")
+    func = getattr(signal, method)
+    msg = f"Importing {method}"
+    with pytest.deprecated_call(match=msg):
+        func(1, *args)
+        
 
 class TestBartHann:
Repository: scipy/scipy

Issue:
DOC: sparse doc build warning causing failure (including in CI)
> /home/circleci/repo/build-install/lib/python3.9/site-packages/scipy/sparse/_matrix.py:docstring of scipy.sparse._matrix.spmatrix.getnnz:16: WARNING: py:obj reference target not found: count_nonzero

I bet it is something that has changed with all the `sparse` activity happening at the sprint in Seattle.


Discussion:
Spoke with @rossbar in person--he will fix it shortly.

Resolving patch:
diff --git a/scipy/sparse/_matrix.py b/scipy/sparse/_matrix.py
--- a/scipy/sparse/_matrix.py
+++ b/scipy/sparse/_matrix.py
@@ -113,10 +113,6 @@ def getnnz(self, axis=None):
         axis : None, 0, or 1
             Select between the number of values across the whole array, in
             each column, or in each row.
-
-        See also
-        --------
-        count_nonzero : Number of non-zero entries
         """
         return self._getnnz(axis=axis)
 


Test patch:
Repository: scipy/scipy

Issue:
DEP: removal of parameter `centered` of `stats.qmc.LatinHypercube`
Follow-up of #17152


Discussion:

Resolving patch:
diff --git a/scipy/stats/_qmc.py b/scipy/stats/_qmc.py
--- a/scipy/stats/_qmc.py
+++ b/scipy/stats/_qmc.py
@@ -1091,15 +1091,6 @@ class LatinHypercube(QMCEngine):
     ----------
     d : int
         Dimension of the parameter space.
-    centered : bool, optional
-        Center samples within cells of a multi-dimensional grid.
-        Default is False.
-
-        .. deprecated:: 1.10.0
-            `centered` is deprecated as of SciPy 1.10.0 and will be removed in
-            1.12.0. Use `scramble` instead. ``centered=True`` corresponds to
-            ``scramble=False``.
-
     scramble : bool, optional
         When False, center samples within cells of a multi-dimensional grid.
         Otherwise, samples are randomly placed within cells of the grid.
@@ -1273,21 +1264,12 @@ class LatinHypercube(QMCEngine):
     """
 
     def __init__(
-        self, d: IntNumber, *, centered: bool = False,
+        self, d: IntNumber, *,
         scramble: bool = True,
         strength: int = 1,
         optimization: Literal["random-cd", "lloyd"] | None = None,
         seed: SeedType = None
     ) -> None:
-        if centered:
-            scramble = False
-            warnings.warn(
-                "'centered' is deprecated and will be removed in SciPy 1.12."
-                " Please use 'scramble' instead. 'centered=True' corresponds"
-                " to 'scramble=False'.",
-                stacklevel=2
-            )
-
         # Used in `scipy.integrate.qmc_quad`
         self._init_quad = {'d': d, 'scramble': True, 'strength': strength,
                            'optimization': optimization}
@@ -2324,7 +2306,7 @@ def _random_cd(
     Create a base LHS and do random permutations of coordinates to
     lower the centered discrepancy.
     Because it starts with a normal LHS, it also works with the
-    `centered` keyword argument.
+    `scramble` keyword argument.
 
     Two stopping criterion are used to stop the algorithm: at most,
     `n_iters` iterations are performed; or if there is no improvement


Test patch:
diff --git a/scipy/stats/tests/test_qmc.py b/scipy/stats/tests/test_qmc.py
--- a/scipy/stats/tests/test_qmc.py
+++ b/scipy/stats/tests/test_qmc.py
@@ -746,10 +746,6 @@ def test_raises(self):
             engine = qmc.LatinHypercube(d=5, strength=2)
             engine.random(9)
 
-        message = r"'centered' is deprecated"
-        with pytest.warns(UserWarning, match=message):
-            qmc.LatinHypercube(1, centered=True)
-
 
 class TestSobol(QMCEngineTests):
     qmce = qmc.Sobol
Repository: scipy/scipy

Issue:
BUG: dev.py notes needs a small shim
There was a modernization of our docs layout that broke the release process and is fixed by the small patch below, which it may be sensible to merge to `main` then backport to the latest maintenance branch, but I will likely delay that to after `1.11.0rc1` since I'm doing the process now..

```diff
diff --git a/tools/write_release_and_log.py b/tools/write_release_and_log.py
index 49b4783ba..2f158bb63 100644
--- a/tools/write_release_and_log.py
+++ b/tools/write_release_and_log.py
@@ -90,7 +90,7 @@ def compute_sha256(idirs):
 
 def write_release_task(filename='NOTES.txt'):
     idirs = Path('release')
-    source = Path(get_latest_release_doc('doc/release'))
+    source = Path(get_latest_release_doc('doc/source/release'))
     target = Path(filename)
     if target.exists():
         target.remove()
```


Discussion:

Resolving patch:
diff --git a/tools/write_release_and_log.py b/tools/write_release_and_log.py
--- a/tools/write_release_and_log.py
+++ b/tools/write_release_and_log.py
@@ -90,7 +90,7 @@ def compute_sha256(idirs):
 
 def write_release_task(filename='NOTES.txt'):
     idirs = Path('release')
-    source = Path(get_latest_release_doc('doc/release'))
+    source = Path(get_latest_release_doc('doc/source/release'))
     target = Path(filename)
     if target.exists():
         target.remove()


Test patch:
Repository: scipy/scipy

Issue:
BUG: johnsonsu distribution no longer accepts integer `b` parameter
### Describe your issue.

Running on a colab and manually upgrading to latest numpy/scipy, the `johnsonsu` distribution no longer accepts integer arguments. Passing 

```
st.johnsonsu(1, 2., 3, 4).mean()
```
works, but 

```
st.johnsonsu(1, 2, 3, 4).mean()
```

fails.

Both work on scipy 1.10.1 (the default on colab right now).

 
It looks like changing [this line](https://github.com/scipy/scipy/blob/v1.11.0/scipy/stats/_continuous_distns.py#L5278) to 
```
        bn2 = b**-2.
```
would fix it (note the `.` after the 2).


### Reproducing Code Example

```python
st.johnsonsu(1, 2, 3, 4).mean()
```


### Error message

```shell
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-15-3670ad2e6c3d> in <cell line: 1>()
----> 1 st.johnsonsu(1, 2, 3, 4).mean()

3 frames
/usr/local/lib/python3.10/dist-packages/scipy/stats/_distn_infrastructure.py in mean(self)
    506 
    507     def mean(self):
--> 508         return self.dist.mean(*self.args, **self.kwds)
    509 
    510     def var(self):

/usr/local/lib/python3.10/dist-packages/scipy/stats/_distn_infrastructure.py in mean(self, *args, **kwds)
   1352         """
   1353         kwds['moments'] = 'm'
-> 1354         res = self.stats(*args, **kwds)
   1355         if isinstance(res, ndarray) and res.ndim == 0:
   1356             return res[()]

/usr/local/lib/python3.10/dist-packages/scipy/stats/_distn_infrastructure.py in stats(self, *args, **kwds)
   1122 
   1123             if self._stats_has_moments:
-> 1124                 mu, mu2, g1, g2 = self._stats(*goodargs,
   1125                                               **{'moments': moments})
   1126             else:

/usr/local/lib/python3.10/dist-packages/scipy/stats/_continuous_distns.py in _stats(self, a, b, moments)
   5276         mu, mu2, g1, g2 = None, None, None, None
   5277 
-> 5278         bn2 = b**-2
   5279         expbn2 = np.exp(bn2)
   5280         a_b = a / b

ValueError: Integers to negative integer powers are not allowed.
```


### SciPy/NumPy/Python version and system information

```shell
1.11.0 1.25.0 3.10.12
```



Discussion:

Resolving patch:
diff --git a/scipy/stats/_continuous_distns.py b/scipy/stats/_continuous_distns.py
--- a/scipy/stats/_continuous_distns.py
+++ b/scipy/stats/_continuous_distns.py
@@ -5368,7 +5368,7 @@ def _stats(self, a, b, moments='mv'):
         # Numerical improvements left to future enhancements.
         mu, mu2, g1, g2 = None, None, None, None
 
-        bn2 = b**-2
+        bn2 = b**-2.
         expbn2 = np.exp(bn2)
         a_b = a / b
 


Test patch:
Repository: scipy/scipy

Issue:
DOC: incorrect reference to parameter name
### Issue with current documentation:

`scipy.optimize.minimise(method="BFGS")` has a mention in it's documentation to `method='3-point'`. I assume it is supposed to say `jac='3-point'`, given that `method="BFGS"` already? If that's not the case, the wording could still do with a clean-up.

```
If jac in [‘2-point’, ‘3-point’, ‘cs’] the relative step size to use for numerical approximation of the jacobian. The absolute step size is computed as h = rel_step * sign(x) * max(1, abs(x)), possibly adjusted to fit into the bounds. For method='3-point' the sign of h is ignored. If None (default) then step is selected automatically.
```



### Idea or request for content:

Either reword docs to make clear what `method` refers to in this case, or fix the wrong symbol being named in the docs (depending on whether this is a mistake or not).

### Additional context (e.g. screenshots, GIFs)

The doc page is https://docs.scipy.org/doc/scipy-1.11.1/reference/generated/scipy.optimize.minimize.html 
Generated from https://github.com/scipy/scipy/blob/604e7a28e145dd14b77666752b65879bb73b01d7/scipy/optimize/_optimize.py#L340


Discussion:

Resolving patch:
diff --git a/scipy/optimize/_optimize.py b/scipy/optimize/_optimize.py
--- a/scipy/optimize/_optimize.py
+++ b/scipy/optimize/_optimize.py
@@ -337,7 +337,7 @@ def _prepare_scalar_function(fun, x0, jac=None, args=(), bounds=None,
         If `jac in ['2-point', '3-point', 'cs']` the relative step size to
         use for numerical approximation of the jacobian. The absolute step
         size is computed as ``h = rel_step * sign(x0) * max(1, abs(x0))``,
-        possibly adjusted to fit into the bounds. For ``method='3-point'``
+        possibly adjusted to fit into the bounds. For ``jac='3-point'``
         the sign of `h` is ignored. If None (default) then step is selected
         automatically.
     hess : {callable,  '2-point', '3-point', 'cs', None}
@@ -1403,7 +1403,7 @@ def _minimize_bfgs(fun, x0, args=(), jac=None, callback=None,
         If `jac in ['2-point', '3-point', 'cs']` the relative step size to
         use for numerical approximation of the jacobian. The absolute step
         size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
-        possibly adjusted to fit into the bounds. For ``method='3-point'``
+        possibly adjusted to fit into the bounds. For ``jac='3-point'``
         the sign of `h` is ignored. If None (default) then step is selected
         automatically.
     xrtol : float, default: 0
@@ -1742,7 +1742,7 @@ def _minimize_cg(fun, x0, args=(), jac=None, callback=None,
         If `jac in ['2-point', '3-point', 'cs']` the relative step size to
         use for numerical approximation of the jacobian. The absolute step
         size is computed as ``h = rel_step * sign(x) * max(1, abs(x))``,
-        possibly adjusted to fit into the bounds. For ``method='3-point'``
+        possibly adjusted to fit into the bounds. For ``jac='3-point'``
         the sign of `h` is ignored. If None (default) then step is selected
         automatically.
     """


Test patch:
Repository: scipy/scipy

Issue:
DOC: error in scipy.integrate.DOP853
### Issue with current documentation:

This doesn't make sense:

`Note that this is not a literate translation`

I suppose it was meant to be:

`Note that this is not a literal translation`

### Idea or request for content:

_No response_

### Additional context (e.g. screenshots, GIFs)

_No response_


Discussion:
This bit isn't too good either:

`Here rtol controls a relative accuracy (number of correct digits), while atol controls absolute accuracy (number of correct decimal places).`

For most people, "digits" and "decimal places" are the same thing.
PR welcome for the doc fix although please sure be sure to skip the appropriate CI jobs by adding `[skip actions] [skip cirrus]` at the end of the commit message.

> This bit isn't too good either:
> 
> `Here rtol controls a relative accuracy (number of correct digits), while atol controls absolute accuracy (number of correct decimal places).`
> 
> For most people, "digits" and "decimal places" are the same thing.

I personally think this is fine, in numerical analysis digits tend to refer to significant figures rather than decimal places so this description is correct.

Resolving patch:
diff --git a/scipy/integrate/_ivp/rk.py b/scipy/integrate/_ivp/rk.py
--- a/scipy/integrate/_ivp/rk.py
+++ b/scipy/integrate/_ivp/rk.py
@@ -406,7 +406,7 @@ class DOP853(RungeKutta):
     """Explicit Runge-Kutta method of order 8.
 
     This is a Python implementation of "DOP853" algorithm originally written
-    in Fortran [1]_, [2]_. Note that this is not a literate translation, but
+    in Fortran [1]_, [2]_. Note that this is not a literal translation, but
     the algorithmic core and coefficients are the same.
 
     Can be applied in the complex domain.


Test patch: