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

Issue:
DEP: remove object arrays in sparse matrices
A warning (not explicitly a `DeprecationWarning`) was added in #2719 for #2528; current usage [here](https://github.com/scipy/scipy/blob/v1.8.0/scipy/sparse/_sputils.py#L114).


Discussion:
Given that the warning just says
```
warnings.warn("object dtype is not supported by sparse matrices")
```

I'd usually suggest turning this into a proper deprecation warning with announced removal. _But_, reading #2528, it seems that object types for sparse matrices simply are not fully implemented and/or expected to work. There was already an attempt to turn this into an outright error, though @pv [noted](https://github.com/scipy/scipy/issues/2528#issuecomment-23031188) then (in 2013):
> I changed the PR to raise a warning rather than error on object dtypes --- I think this change needs some deprecation first.

I would suggest just raising an error outright for 1.9 - does that sound reasonable to you @pv @rgommers?
Yes that's fine, the warning has been there for a decade.
Yep, raising a ValueError makes sense here.

Resolving patch:
diff --git a/scipy/sparse/_sputils.py b/scipy/sparse/_sputils.py
--- a/scipy/sparse/_sputils.py
+++ b/scipy/sparse/_sputils.py
@@ -111,7 +111,9 @@ def getdtype(dtype, a=None, default=None):
     else:
         newdtype = np.dtype(dtype)
         if newdtype == np.object_:
-            warnings.warn("object dtype is not supported by sparse matrices")
+            raise ValueError(
+                "object dtype is not supported by sparse matrices"
+            )
 
     return newdtype
 


Test patch:
diff --git a/scipy/sparse/tests/test_sputils.py b/scipy/sparse/tests/test_sputils.py
--- a/scipy/sparse/tests/test_sputils.py
+++ b/scipy/sparse/tests/test_sputils.py
@@ -21,6 +21,12 @@ def test_getdtype(self):
         assert_equal(sputils.getdtype(None, default=float), float)
         assert_equal(sputils.getdtype(None, a=A), np.int8)
 
+        with assert_raises(
+            ValueError,
+            match="object dtype is not supported by sparse matrices",
+        ):
+            sputils.getdtype("O")
+
     def test_isscalarlike(self):
         assert_equal(sputils.isscalarlike(3.0), True)
         assert_equal(sputils.isscalarlike(-4), True)
Repository: scipy/scipy

Issue:
DEP: Remove mlab mode from dendrogram
Never implemented, deprecated since #6643.


Discussion:

Resolving patch:
diff --git a/scipy/cluster/hierarchy.py b/scipy/cluster/hierarchy.py
--- a/scipy/cluster/hierarchy.py
+++ b/scipy/cluster/hierarchy.py
@@ -3308,11 +3308,11 @@ def llf(id):
     else:
         raise TypeError('The second argument must be a number')
 
-    if truncate_mode not in ('lastp', 'mlab', 'mtica', 'level', 'none', None):
-        # 'mlab' and 'mtica' are kept working for backwards compat.
+    if truncate_mode not in ('lastp', 'mtica', 'level', 'none', None):
+        # 'mtica' is kept working for backwards compat.
         raise ValueError('Invalid truncation mode.')
 
-    if truncate_mode == 'lastp' or truncate_mode == 'mlab':
+    if truncate_mode == 'lastp':
         if p > n or p == 0:
             p = n
 
@@ -3541,9 +3541,6 @@ def _dendrogram_calculate_info(Z, p, truncate_mode,
             _append_singleton_leaf_node(Z, p, n, level, lvs, ivl,
                                         leaf_label_func, i, labels)
             return (iv + 5.0, 10.0, 0.0, 0.0)
-    elif truncate_mode in ('mlab',):
-        msg = "Mode 'mlab' is deprecated in scipy 0.19.0 (it never worked)."
-        warnings.warn(msg, DeprecationWarning)
 
     # Otherwise, only truncate if we have a leaf node.
     #


Test patch:
Repository: scipy/scipy

Issue:
DEP: remove sym_pos-keyword of scipy.linalg.solve
Deprecated in documentation since https://github.com/scipy/scipy/pull/6775, sharpened to actual warning in  #15735 / https://github.com/scipy/scipy/pull/15821.


Discussion:

Resolving patch:
diff --git a/scipy/linalg/_basic.py b/scipy/linalg/_basic.py
--- a/scipy/linalg/_basic.py
+++ b/scipy/linalg/_basic.py
@@ -37,7 +37,7 @@ def _solve_check(n, info, lamch=None, rcond=None):
              LinAlgWarning, stacklevel=3)
 
 
-def solve(a, b, sym_pos=False, lower=False, overwrite_a=False,
+def solve(a, b, lower=False, overwrite_a=False,
           overwrite_b=False, check_finite=True, assume_a='gen',
           transposed=False):
     """
@@ -68,13 +68,6 @@ def solve(a, b, sym_pos=False, lower=False, overwrite_a=False,
         Square input data
     b : (N, NRHS) array_like
         Input data for the right hand side.
-    sym_pos : bool, default: False, deprecated
-        Assume `a` is symmetric and positive definite.
-
-        .. deprecated:: 0.19.0
-            This keyword is deprecated and should be replaced by using
-           ``assume_a = 'pos'``. `sym_pos` will be removed in SciPy 1.11.0.
-
     lower : bool, default: False
         Ignored if ``assume_a == 'gen'`` (the default). If True, the
         calculation uses only the data in the lower triangle of `a`;
@@ -168,14 +161,6 @@ def solve(a, b, sym_pos=False, lower=False, overwrite_a=False,
             b1 = b1[:, None]
         b_is_1D = True
 
-    # Backwards compatibility - old keyword.
-    if sym_pos:
-        message = ("The 'sym_pos' keyword is deprecated and should be "
-                   "replaced by using 'assume_a = \"pos\"'. 'sym_pos' will be"
-                   " removed in SciPy 1.11.0.")
-        warn(message, DeprecationWarning, stacklevel=2)
-        assume_a = 'pos'
-
     if assume_a not in ('gen', 'sym', 'her', 'pos'):
         raise ValueError('{} is not a recognized matrix structure'
                          ''.format(assume_a))


Test patch:
diff --git a/scipy/linalg/tests/test_basic.py b/scipy/linalg/tests/test_basic.py
--- a/scipy/linalg/tests/test_basic.py
+++ b/scipy/linalg/tests/test_basic.py
@@ -619,13 +619,6 @@ def test_random_complex(self):
             x = solve(a, b)
             assert_array_almost_equal(dot(a, x), b)
 
-    def test_sym_pos_dep(self):
-        with pytest.warns(
-                DeprecationWarning,
-                match="The 'sym_pos' keyword is deprecated",
-        ):
-            solve([[1.]], [1], sym_pos=True)
-
     def test_random_sym(self):
         n = 20
         a = random([n, n])
Repository: scipy/scipy

Issue:
DEP: remove py_vq2 
Deprecated since #7234


Discussion:

Resolving patch:
diff --git a/scipy/cluster/vq.py b/scipy/cluster/vq.py
--- a/scipy/cluster/vq.py
+++ b/scipy/cluster/vq.py
@@ -262,10 +262,6 @@ def py_vq(obs, code_book, check_finite=True):
     return code, min_dist
 
 
-# py_vq2 was equivalent to py_vq
-py_vq2 = np.deprecate(py_vq, old_name='py_vq2', new_name='py_vq')
-
-
 def _kmeans(obs, guess, thresh=1e-5):
     """ "raw" version of k-means.
 


Test patch:
Repository: scipy/scipy

Issue:
DEP: remove old BSR methods
Deprecated since #6838


Discussion:

Resolving patch:
diff --git a/scipy/sparse/_bsr.py b/scipy/sparse/_bsr.py
--- a/scipy/sparse/_bsr.py
+++ b/scipy/sparse/_bsr.py
@@ -335,18 +335,6 @@ def __setitem__(self,key,val):
     # Arithmetic methods #
     ######################
 
-    @np.deprecate(message="BSR matvec is deprecated in SciPy 0.19.0. "
-                          "Use * operator instead.")
-    def matvec(self, other):
-        """Multiply matrix by vector."""
-        return self * other
-
-    @np.deprecate(message="BSR matmat is deprecated in SciPy 0.19.0. "
-                          "Use * operator instead.")
-    def matmat(self, other):
-        """Multiply this sparse matrix by other matrix."""
-        return self * other
-
     def _add_dense(self, other):
         return self.tocoo(copy=False)._add_dense(other)
 


Test patch:
Repository: scipy/scipy

Issue:
DEP: remove `_ppform`
Deprecated since #7870


Discussion:

Resolving patch:
diff --git a/scipy/interpolate/_interpolate.py b/scipy/interpolate/_interpolate.py
--- a/scipy/interpolate/_interpolate.py
+++ b/scipy/interpolate/_interpolate.py
@@ -419,7 +419,7 @@ class interp1d(_Interpolator1D):
 
     Input values `x` and `y` must be convertible to `float` values like
     `int` or `float`.
-    
+
     If the values in `x` are not unique, the resulting behavior is
     undefined and specific to the choice of `kind`, i.e., changing
     `kind` will change the behavior for duplicates.
@@ -1010,6 +1010,7 @@ class PPoly(_PPolyBase):
     unstable. Precision problems can start to appear for orders
     larger than 20-30.
     """
+
     def _evaluate(self, x, nu, extrapolate, out):
         _ppoly.evaluate(self.c.reshape(self.c.shape[0], self.c.shape[1], -1),
                         self.x, x, nu, bool(extrapolate), out)
@@ -2730,51 +2731,3 @@ def interpn(points, values, xi, method="linear", bounds_error=True,
         result[np.logical_not(idx_valid)] = fill_value
 
         return result.reshape(xi_shape[:-1])
-
-
-# backward compatibility wrapper
-class _ppform(PPoly):
-    """
-    Deprecated piecewise polynomial class.
-
-    New code should use the `PPoly` class instead.
-
-    """
-
-    def __init__(self, coeffs, breaks, fill=0.0, sort=False):
-        warnings.warn("_ppform is deprecated -- use PPoly instead",
-                      category=DeprecationWarning)
-
-        if sort:
-            breaks = np.sort(breaks)
-        else:
-            breaks = np.asarray(breaks)
-
-        PPoly.__init__(self, coeffs, breaks)
-
-        self.coeffs = self.c
-        self.breaks = self.x
-        self.K = self.coeffs.shape[0]
-        self.fill = fill
-        self.a = self.breaks[0]
-        self.b = self.breaks[-1]
-
-    def __call__(self, x):
-        return PPoly.__call__(self, x, 0, False)
-
-    def _evaluate(self, x, nu, extrapolate, out):
-        PPoly._evaluate(self, x, nu, extrapolate, out)
-        out[~((x >= self.a) & (x <= self.b))] = self.fill
-        return out
-
-    @classmethod
-    def fromspline(cls, xk, cvals, order, fill=0.0):
-        # Note: this spline representation is incompatible with FITPACK
-        N = len(xk)-1
-        sivals = np.empty((order+1, N), dtype=float)
-        for m in range(order, -1, -1):
-            fact = spec.gamma(m+1)
-            res = _fitpack._bspleval(xk[:-1], xk, cvals, order, m)
-            res /= fact
-            sivals[order-m, :] = res
-        return cls(sivals, xk, fill=fill)


Test patch:
Repository: scipy/scipy

Issue:
DEP: remove ftol/xtol from neldermead
Deprecated in #5939


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
@@ -686,27 +686,6 @@ def _minimize_neldermead(func, x0, args=(), callback=None,
        51:1, pp. 259-277
 
     """
-    if 'ftol' in unknown_options:
-        warnings.warn("ftol is deprecated for Nelder-Mead,"
-                      " use fatol instead. If you specified both, only"
-                      " fatol is used.",
-                      DeprecationWarning)
-        if (np.isclose(fatol, 1e-4) and
-                not np.isclose(unknown_options['ftol'], 1e-4)):
-            # only ftol was probably specified, use it.
-            fatol = unknown_options['ftol']
-        unknown_options.pop('ftol')
-    if 'xtol' in unknown_options:
-        warnings.warn("xtol is deprecated for Nelder-Mead,"
-                      " use xatol instead. If you specified both, only"
-                      " xatol is used.",
-                      DeprecationWarning)
-        if (np.isclose(xatol, 1e-4) and
-                not np.isclose(unknown_options['xtol'], 1e-4)):
-            # only xtol was probably specified, use it.
-            xatol = unknown_options['xtol']
-        unknown_options.pop('xtol')
-
     _check_unknown_options(unknown_options)
     maxfun = maxfev
     retall = return_all


Test patch:
diff --git a/scipy/optimize/tests/test_optimize.py b/scipy/optimize/tests/test_optimize.py
--- a/scipy/optimize/tests/test_optimize.py
+++ b/scipy/optimize/tests/test_optimize.py
@@ -596,9 +596,6 @@ def test_neldermead_xatol_fatol():
 
     optimize._minimize._minimize_neldermead(func, [1, 1], maxiter=2,
                                             xatol=1e-3, fatol=1e-3)
-    assert_warns(DeprecationWarning,
-                 optimize._minimize._minimize_neldermead,
-                 func, [1, 1], xtol=1e-3, ftol=1e-3, maxiter=2)
 
 
 def test_neldermead_adaptive():
Repository: scipy/scipy

Issue:
BUG: _calc_uniform_order_statistic_medians documentation example disagrees with required import
### Describe your issue.

The documentation on how to use the  _calc_uniform_order_statistic_medians function [states here in the example:](https://github.com/scipy/scipy/blob/59d974bf14ff8c82f3353e2d2a9282d9bda67db5/scipy/stats/_morestats.py#L410):


However, _calc_uniform_order_statistic_medians is not exported into the `scipy.stats` package, [it does not appear in any __init__.py at all](https://github.com/scipy/scipy/search?q=_calc_uniform_order_statistic_medians).


### Reproducing Code Example

```python
    >>> from scipy.stats import _calc_uniform_order_statistic_medians
    >>> _calc_uniform_order_statistic_medians(n)
    array([0.15910358, 0.38545246, 0.61454754, 0.84089642])
```


### Error message

```shell
E   ImportError: cannot import name '_calc_uniform_order_statistic_medians' from 'scipy.stats' (/opt/anaconda3/envs/py310/lib/python3.10/site-packages/scipy/stats/__init__.py)
```

### Potential Fix

I would be happy to make a PR for this, but I'm unsure if we should update the documentation to reflect the correct import::

```python
    >>> from scipy.stats._morestats import _calc_uniform_order_statistic_medians
    >>> _calc_uniform_order_statistic_medians(n)
    array([0.15910358, 0.38545246, 0.61454754, 0.84089642])
```

Or if we should add the import into the `__init__.py` in `scipy.stats` so the code from the documentation works.



### SciPy/NumPy/Python version information

1.8.0 1.21.5 sys.version_info(major=3, minor=10, micro=3, releaselevel='final', serial=0)


Discussion:
Hi @Samreay, thank you for reporting. What is incorrect is the import in the documentation of this function. The function itself is marked on purpose as private with a leading underscore.

You can make a PR to fix the documentation. I don't think we even need to import it because it's local to this file and should already be known.

Resolving patch:
diff --git a/scipy/stats/_morestats.py b/scipy/stats/_morestats.py
--- a/scipy/stats/_morestats.py
+++ b/scipy/stats/_morestats.py
@@ -407,7 +407,7 @@ def _calc_uniform_order_statistic_medians(n):
     and greatest order statistics, and the remaining medians are approximated
     by points spread evenly across a sub-interval of the unit interval:
 
-    >>> from scipy.stats import _calc_uniform_order_statistic_medians
+    >>> from scipy.stats._morestats import _calc_uniform_order_statistic_medians
     >>> _calc_uniform_order_statistic_medians(n)
     array([0.15910358, 0.38545246, 0.61454754, 0.84089642])
 


Test patch:
Repository: scipy/scipy

Issue:
BUG: typo in documentation for scipy.optimize.basinhopping
### Describe your issue.

There's a notational mistake in the examples section on the page https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.basinhopping.html#scipy.optimize.basinhopping. In the code blocks, it should say `f(x)`, not `f(x0)`, since `x` is the value of the parameter that minimizes `f`, whereas `x0` is the initial guess.


### Reproducing Code Example

```python
n/a
```


### Error message

```shell
n/a
```


### SciPy/NumPy/Python version information

n/a


Discussion:
Hi @cam92473, thank you for reporting. You mean these correct `global minimum: x = %.4f, f(x0) = %.4f`?

I agree. Would you like to do a PR to fix it?

Resolving patch:
diff --git a/scipy/optimize/_basinhopping.py b/scipy/optimize/_basinhopping.py
--- a/scipy/optimize/_basinhopping.py
+++ b/scipy/optimize/_basinhopping.py
@@ -569,8 +569,8 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5,
     >>> minimizer_kwargs = {"method": "BFGS"}
     >>> ret = basinhopping(func, x0, minimizer_kwargs=minimizer_kwargs,
     ...                    niter=200)
-    >>> print("global minimum: x = %.4f, f(x0) = %.4f" % (ret.x, ret.fun))
-    global minimum: x = -0.1951, f(x0) = -1.0009
+    >>> print("global minimum: x = %.4f, f(x) = %.4f" % (ret.x, ret.fun))
+    global minimum: x = -0.1951, f(x) = -1.0009
 
     Next consider a 2-D minimization problem. Also, this time, we
     will use gradient information to significantly speed up the search.
@@ -590,10 +590,10 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5,
     >>> x0 = [1.0, 1.0]
     >>> ret = basinhopping(func2d, x0, minimizer_kwargs=minimizer_kwargs,
     ...                    niter=200)
-    >>> print("global minimum: x = [%.4f, %.4f], f(x0) = %.4f" % (ret.x[0],
+    >>> print("global minimum: x = [%.4f, %.4f], f(x) = %.4f" % (ret.x[0],
     ...                                                           ret.x[1],
     ...                                                           ret.fun))
-    global minimum: x = [-0.1951, -0.1000], f(x0) = -1.0109
+    global minimum: x = [-0.1951, -0.1000], f(x) = -1.0109
 
 
     Here is an example using a custom step-taking routine. Imagine you want
@@ -617,10 +617,10 @@ def basinhopping(func, x0, niter=100, T=1.0, stepsize=0.5,
     >>> mytakestep = MyTakeStep()
     >>> ret = basinhopping(func2d, x0, minimizer_kwargs=minimizer_kwargs,
     ...                    niter=200, take_step=mytakestep)
-    >>> print("global minimum: x = [%.4f, %.4f], f(x0) = %.4f" % (ret.x[0],
+    >>> print("global minimum: x = [%.4f, %.4f], f(x) = %.4f" % (ret.x[0],
     ...                                                           ret.x[1],
     ...                                                           ret.fun))
-    global minimum: x = [-0.1951, -0.1000], f(x0) = -1.0109
+    global minimum: x = [-0.1951, -0.1000], f(x) = -1.0109
 
 
     Now, let's do an example using a custom callback function which prints the


Test patch:
Repository: scipy/scipy

Issue:
BUG: Confusing documentation in `ttest_ind_from_stats`
### Is your feature request related to a problem? Please describe.

The documentation in `ttest_ind_from_stats` is confusing.

it states that the variances of  
```
a = np.array([1, 3, 4, 6, 11, 13, 15, 19, 22, 24, 25, 26, 26])
b = np.array([2, 4, 6, 9, 11, 13, 14, 15, 18, 19, 21])
```
are `87.5` and `39.0`, while they are not.

### Describe the solution you'd like.

Fix the table in the start of the examples to have the right values

### Describe alternatives you've considered.

_No response_

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

![image](https://user-images.githubusercontent.com/25847554/163881122-4463643d-e40c-44ad-871a-5b183a2e7f3c.png)
![image](https://user-images.githubusercontent.com/25847554/163881159-8c8b682c-527e-44bf-96b6-95e412dd5d53.png)



Discussion:
OK, its just that ddof=1 should be used.
closing

Resolving patch:
diff --git a/scipy/stats/_stats_py.py b/scipy/stats/_stats_py.py
--- a/scipy/stats/_stats_py.py
+++ b/scipy/stats/_stats_py.py
@@ -5900,13 +5900,13 @@ def ttest_ind_from_stats(mean1, std1, nobs1, mean2, std2, nobs2,
     mean1 : array_like
         The mean(s) of sample 1.
     std1 : array_like
-        The standard deviation(s) of sample 1.
+        The corrected sample standard deviation of sample 1 (i.e. ``ddof=1``).
     nobs1 : array_like
         The number(s) of observations of sample 1.
     mean2 : array_like
         The mean(s) of sample 2.
     std2 : array_like
-        The standard deviations(s) of sample 2.
+        The corrected sample standard deviation of sample 2 (i.e. ``ddof=1``).
     nobs2 : array_like
         The number(s) of observations of sample 2.
     equal_var : bool, optional
@@ -5951,7 +5951,8 @@ def ttest_ind_from_stats(mean1, std1, nobs1, mean2, std2, nobs2,
 
     Examples
     --------
-    Suppose we have the summary data for two samples, as follows::
+    Suppose we have the summary data for two samples, as follows (with the
+    Sample Variance being the corrected sample variance)::
 
                          Sample   Sample
                    Size   Mean   Variance


Test patch:
Repository: scipy/scipy

Issue:
BUG: Confusing documentation in `ttest_ind_from_stats`
### Is your feature request related to a problem? Please describe.

The documentation in `ttest_ind_from_stats` is confusing.

it states that the variances of  
```
a = np.array([1, 3, 4, 6, 11, 13, 15, 19, 22, 24, 25, 26, 26])
b = np.array([2, 4, 6, 9, 11, 13, 14, 15, 18, 19, 21])
```
are `87.5` and `39.0`, while they are not.

### Describe the solution you'd like.

Fix the table in the start of the examples to have the right values

### Describe alternatives you've considered.

_No response_

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

![image](https://user-images.githubusercontent.com/25847554/163881122-4463643d-e40c-44ad-871a-5b183a2e7f3c.png)
![image](https://user-images.githubusercontent.com/25847554/163881159-8c8b682c-527e-44bf-96b6-95e412dd5d53.png)



Discussion:
OK, its just that ddof=1 should be used.
closing
We should document that, though, so I've reopened this. To close this issue, please explain in the Parameters and Examples section that the standard deviation should be the corrected estimate (i.e. calculated with n-1 degrees of freedom). 
Hi @mdhaber, 
There is still a related mistake in this part of the doc
![image](https://user-images.githubusercontent.com/25847554/164959646-812346b3-e88b-4080-96e6-5de35e4c5d41.png)


![image](https://user-images.githubusercontent.com/25847554/164959742-c0c1e007-a8bb-482c-a3e4-6c5e253cbcb9.png)

I see. I assumed the author would have calculated those with `ddof=1`. @fAndreuzzi if you like to change that column to the corrected sample standard deviation (rather than uncorrected variance), I can review.
Thanks @alonme @fAndreuzzi! But I think the t_test below that still needs to be fixed : P

Resolving patch:
diff --git a/scipy/stats/_stats_py.py b/scipy/stats/_stats_py.py
--- a/scipy/stats/_stats_py.py
+++ b/scipy/stats/_stats_py.py
@@ -5989,9 +5989,9 @@ def ttest_ind_from_stats(mean1, std1, nobs1, mean2, std2, nobs2,
     and the variance for a binary observation is estimated by
     :math:`\hat{p}(1-\hat{p})`.
 
-    >>> ttest_ind_from_stats(mean1=0.2, std1=np.sqrt(0.16), nobs1=150,
-    ...                      mean2=0.225, std2=np.sqrt(0.17437), nobs2=200)
-    Ttest_indResult(statistic=-0.564327545549774, pvalue=0.5728947691244874)
+    >>> ttest_ind_from_stats(mean1=0.2, std1=np.sqrt(0.161073), nobs1=150,
+    ...                      mean2=0.225, std2=np.sqrt(0.175251), nobs2=200)
+    Ttest_indResult(statistic=-0.5627187905196761, pvalue=0.5739887114209541)
 
     For comparison, we could compute the t statistic and p-value using
     arrays of 0s and 1s and `scipy.stat.ttest_ind`, as above.


Test patch: