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

Issue:
DEP: remove spatial.distance.matching
It's been deprecated since https://github.com/scipy/scipy/pull/7630


Discussion:

Resolving patch:
diff --git a/scipy/spatial/distance.py b/scipy/spatial/distance.py
--- a/scipy/spatial/distance.py
+++ b/scipy/spatial/distance.py
@@ -92,7 +92,6 @@
     'kulsinski',
     'kulczynski1',
     'mahalanobis',
-    'matching',
     'minkowski',
     'num_obs_dm',
     'num_obs_y',
@@ -1354,17 +1353,6 @@ def yule(u, v, w=None):
         return float(2.0 * half_R / (ntt * nff + half_R))
 
 
-@np.deprecate(message="spatial.distance.matching is deprecated in scipy 1.0.0; "
-                      "use spatial.distance.hamming instead.")
-def matching(u, v, w=None):
-    """
-    Compute the Hamming distance between two boolean 1-D arrays.
-
-    This is a deprecated synonym for :func:`hamming`.
-    """
-    return hamming(u, v, w=w)
-
-
 def dice(u, v, w=None):
     """
     Compute the Dice dissimilarity between two boolean 1-D arrays.


Test patch:
diff --git a/scipy/spatial/tests/test_distance.py b/scipy/spatial/tests/test_distance.py
--- a/scipy/spatial/tests/test_distance.py
+++ b/scipy/spatial/tests/test_distance.py
@@ -54,12 +54,12 @@
     _validate_vector, _METRICS_NAMES, _METRICS)
 
 # these were missing: chebyshev cityblock kulsinski
-# jensenshannon, matching and seuclidean are referenced by string name.
+# jensenshannon  and seuclidean are referenced by string name.
 from scipy.spatial.distance import (braycurtis, canberra, chebyshev, cityblock,
                                     correlation, cosine, dice, euclidean,
                                     hamming, jaccard, jensenshannon,
                                     kulsinski, kulczynski1, mahalanobis,
-                                    matching, minkowski, rogerstanimoto,
+                                    minkowski, rogerstanimoto,
                                     russellrao, seuclidean, sokalmichener,
                                     sokalsneath, sqeuclidean, yule)
 
@@ -522,7 +522,7 @@ def test_cdist_calling_conventions(self):
                 if verbose > 2:
                     print("testing: ", metric, " with: ", eo_name)
                 if metric in {'dice', 'yule', 'kulsinski',
-                              'matching', 'rogerstanimoto',
+                              'rogerstanimoto',
                               'russellrao', 'sokalmichener',
                               'sokalsneath',
                               'kulczynski1'} and 'bool' not in eo_name:
Repository: scipy/scipy

Issue:
jc should be (n-1)/2
The docs say (n+1)/2 but assume that n runs from from 0 to n-1

https://github.com/scipy/scipy/blob/ced4d67ec8bfd7e25e5087c7dedc53bd8bd632d0/scipy/fft/_fftlog.py#L74

so it should be calculated as jc = (n-1)/2. This is also what the code does:

https://github.com/scipy/scipy/blob/ced4d67ec8bfd7e25e5087c7dedc53bd8bd632d0/scipy/fft/_fftlog.py#L121


Discussion:
I'll take this one, I'm at PyCon at the moment so I'll work on this over the next few days and at the sprints Mon. / Tues.; still a relative beginner so I'll give it my best shot
Let me know if you get stuck

Resolving patch:
diff --git a/scipy/fft/_fftlog.py b/scipy/fft/_fftlog.py
--- a/scipy/fft/_fftlog.py
+++ b/scipy/fft/_fftlog.py
@@ -71,7 +71,7 @@ def fht(a, dln, mu, offset=0.0, bias=0.0):
         r_j = r_c \exp[(j-j_c) \, \mathtt{dln}]
 
     centred about the point :math:`r_c`.  Note that the central index
-    :math:`j_c = (n+1)/2` is half-integral if :math:`n` is even, so that
+    :math:`j_c = (n-1)/2` is half-integral if :math:`n` is even, so that
     :math:`r_c` falls between two input elements.  Similarly, the output
     array `A` is a periodic sequence of length :math:`n`, also uniformly
     logarithmically spaced with spacing `dln`


Test patch:
Repository: scipy/scipy

Issue:
DEP: execute deprecation of inexact indices into sparse matrices
It's been deprecated for 5 years, since #7864

CC @perimosocordiae


Discussion:

Resolving patch:
diff --git a/scipy/sparse/_sputils.py b/scipy/sparse/_sputils.py
--- a/scipy/sparse/_sputils.py
+++ b/scipy/sparse/_sputils.py
@@ -3,7 +3,6 @@
 
 import sys
 import operator
-import warnings
 import numpy as np
 from scipy._lib._util import prod
 
@@ -213,8 +212,8 @@ def isintlike(x):
         except (TypeError, ValueError):
             return False
         if loose_int:
-            warnings.warn("Inexact indices into sparse matrices are deprecated",
-                          DeprecationWarning)
+            msg = "Inexact indices into sparse matrices are not allowed"
+            raise ValueError(msg)
         return loose_int
     return True
 


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
@@ -44,10 +44,11 @@ def test_isintlike(self):
         assert_equal(sputils.isintlike(-4), True)
         assert_equal(sputils.isintlike(np.array(3)), True)
         assert_equal(sputils.isintlike(np.array([3])), False)
-        with suppress_warnings() as sup:
-            sup.filter(DeprecationWarning,
-                       "Inexact indices into sparse matrices are deprecated")
-            assert_equal(sputils.isintlike(3.0), True)
+        with assert_raises(
+            ValueError,
+            match="Inexact indices into sparse matrices are not allowed"
+        ):
+            sputils.isintlike(3.0)
 
         assert_equal(sputils.isintlike(2.5), False)
         assert_equal(sputils.isintlike(1 + 3j), False)
Repository: scipy/scipy

Issue:
ENH: double call for `solve` in each iteration of `BroydenFirst`
https://github.com/scipy/scipy/blob/2b4b1f088ca8b76cff26c1cd56322486f8c23658/scipy/optimize/_nonlin.py#L889

In the above function, it seems that in the majority of iterations, `solve` (through `self.Gm.matvec(f)`) is being called twice per function call for no reason as I understand it.

Wouldn't the following save time on computation every iteration?

```python
    def solve(self, f, tol=0):
        r = self.Gm.matvec(f)
        if not np.isfinite(r).all():
            # singular; reset the Jacobian approximation
            self.setup(self.last_x, self.last_f, self.func)

            # CHANGE FROM HERE
            return self.Gm.matvec(f)

        return r
```


Discussion:
Hi @Ar-Kareem, thank you for reporting. Did you try out your proposal? Are the existing tests passing? 

~How did you came to the conclusion that `solve` was called twice as needed?~ Ok I see what you mean. Not my area, but seems like you are correct. Do you want to make a PR?

Please provide a bit more information.
Sorry for not providing more information,

I am not familiar with scipy. I'm currently working on a paper that deals with Broyden's method and was merely looking at the source code to compare with my own implementation when I noticed this.

I'm not 100% sure if the double call is actually useless (maybe under the hood it's doing something), I'll make a pull-request and see if the tests are passing.

Resolving patch:
diff --git a/scipy/optimize/_nonlin.py b/scipy/optimize/_nonlin.py
--- a/scipy/optimize/_nonlin.py
+++ b/scipy/optimize/_nonlin.py
@@ -891,7 +891,8 @@ def solve(self, f, tol=0):
         if not np.isfinite(r).all():
             # singular; reset the Jacobian approximation
             self.setup(self.last_x, self.last_f, self.func)
-        return self.Gm.matvec(f)
+            return self.Gm.matvec(f)
+        return r
 
     def matvec(self, f):
         return self.Gm.solve(f)


Test patch:
Repository: scipy/scipy

Issue:
BUG: `skewnorm.pdf` has incorrect behaviour at plus/minus infinity for `shape=0`
### Describe your issue.

The pdf of the skew normal should reduce to a normal distribution when shape parameter (`a`) is `0`, and in particular the expected result for `skewnorm.pdf(-inf, 0)` and `skewnorm.pdf(inf, 0)` is `0`. However, the implementation directly uses the definition of the skew normal pdf as `2*norm.pdf(x)*norm.cdf(a*x)`, which, as `inf*0` results in `nan`, leads to an `nan` argument for `norm.cdf` and hence the whole expression.

A simple possible fix would be to use: 
```
np.multiply(norm.pdf(x), norm.cdf(a*x), where=np.isfinite(x), out=res)
```
with `res` to be a zero array of appropriate size.

### Reproducing Code Example

```python
import numpy as np
from scipy.stats import skewnorm

skewnorm.pdf(-np.inf, 0)
```


### Error message

```shell
/usr/local/lib/python3.9/site-packages/scipy/stats/_continuous_distns.py:7480: RuntimeWarning: invalid value encountered in multiply
  return 2.*_norm_pdf(x)*_norm_cdf(a*x)
nan
```


### SciPy/NumPy/Python version information

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


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
@@ -7635,7 +7635,10 @@ def _shape_info(self):
         return [_ShapeInfo("a", False, (-np.inf, np.inf), (False, False))]
 
     def _pdf(self, x, a):
-        return 2.*_norm_pdf(x)*_norm_cdf(a*x)
+        return _lazywhere(
+            a == 0, (x, a), lambda x, a: _norm_pdf(x),
+            f2=lambda x, a: 2.*_norm_pdf(x)*_norm_cdf(a*x)
+        )
 
     def _cdf_single(self, x, *args):
         _a, _b = self._get_support(*args)


Test patch:
diff --git a/scipy/stats/tests/test_continuous_basic.py b/scipy/stats/tests/test_continuous_basic.py
--- a/scipy/stats/tests/test_continuous_basic.py
+++ b/scipy/stats/tests/test_continuous_basic.py
@@ -878,3 +878,16 @@ def test_frozen_attributes():
     frozen_norm = stats.norm()
     assert isinstance(frozen_norm, rv_continuous_frozen)
     delattr(stats.norm, 'pmf')
+
+
+def test_skewnorm_pdf_gh16038():
+    rng = np.random.default_rng(0)
+    x, a = -np.inf, 0
+    npt.assert_equal(stats.skewnorm.pdf(x, a), stats.norm.pdf(x))
+    x, a = rng.random(size=(3, 3)), rng.random(size=(3, 3))
+    mask = rng.random(size=(3, 3)) < 0.5
+    a[mask] = 0
+    x_norm = x[mask]
+    res = stats.skewnorm.pdf(x, a)
+    npt.assert_equal(res[mask], stats.norm.pdf(x_norm))
+    npt.assert_equal(res[~mask], stats.skewnorm.pdf(x[~mask], a[~mask]))
Repository: scipy/scipy

Issue:
DEP: Execute deprecation of scipy.linalg.blas.{clapack, flapack}
Deprecated in #406 over 9 years ago


Discussion:

Resolving patch:
diff --git a/scipy/linalg/lapack.py b/scipy/linalg/lapack.py
--- a/scipy/linalg/lapack.py
+++ b/scipy/linalg/lapack.py
@@ -820,10 +820,6 @@
     HAS_ILP64 = False
     _flapack_64 = None
 
-# Backward compatibility
-from scipy._lib._util import DeprecatedImport as _DeprecatedImport
-clapack = _DeprecatedImport("scipy.linalg.blas.clapack", "scipy.linalg.lapack")
-flapack = _DeprecatedImport("scipy.linalg.blas.flapack", "scipy.linalg.lapack")
 
 # Expose all functions (only flapack --- clapack is an implementation detail)
 empty_module = None


Test patch:
Repository: scipy/scipy

Issue:
BUG: Error in error message for incorrect sample dimension in `interpn`
### Describe your issue.

While debugging #16508 I noticed a potentially incorrect error message in `interpn`.
https://github.com/scipy/scipy/blob/3c59bb7b19d3e8b4bff9087adcae73ba77405d9e/scipy/interpolate/_rgi.py#L602-L605
The check here is `xi.shape[-1] != len(grid)` however the error message prints `(xi.shape[1], len(grid)`.

### Reproducing Code Example

```python
N/A
```


### Error message

```shell
N/A
```


### SciPy/NumPy/Python version information

N/A


Discussion:
Thanks @j-bowhay.  Will you be able to submit a pull request to fix this?
Yes will do

Resolving patch:
diff --git a/scipy/interpolate/_rgi.py b/scipy/interpolate/_rgi.py
--- a/scipy/interpolate/_rgi.py
+++ b/scipy/interpolate/_rgi.py
@@ -602,7 +602,7 @@ def interpn(points, values, xi, method="linear", bounds_error=True,
     if xi.shape[-1] != len(grid):
         raise ValueError("The requested sample points xi have dimension "
                          "%d, but this RegularGridInterpolator has "
-                         "dimension %d" % (xi.shape[1], len(grid)))
+                         "dimension %d" % (xi.shape[-1], len(grid)))
 
     if bounds_error:
         for i, p in enumerate(xi.T):


Test patch:
diff --git a/scipy/interpolate/tests/test_rgi.py b/scipy/interpolate/tests/test_rgi.py
--- a/scipy/interpolate/tests/test_rgi.py
+++ b/scipy/interpolate/tests/test_rgi.py
@@ -815,3 +815,13 @@ def test_invalid_points_order(self):
         match = "must be strictly ascending or descending"
         with pytest.raises(ValueError, match=match):
             interpn((x, y), z, xi)
+
+    def test_invalid_xi_dimensions(self):
+        # https://github.com/scipy/scipy/issues/16519
+        points = [(0, 1)]
+        values = [0, 1]
+        xi = np.ones((1, 1, 3))
+        msg = ("The requested sample points xi have dimension 3, but this "
+               "RegularGridInterpolator has dimension 1")
+        with assert_raises(ValueError, match=msg):
+            interpn(points, values, xi)
Repository: scipy/scipy

Issue:
BUG: scipy.signal documentation suggests it returns zpk but in fact returns ba transfer function
### Describe your issue.

The docstring of scipy.signal.bilinear is confusing:

```    Returns
    -------
    z : ndarray
        Numerator of the transformed digital filter transfer function.
    p : ndarray
        Denominator of the transformed digital filter transfer function.
```

While the description says "numerator" and "denominator" as you would expect, the return names z, p suggest it is returning the roots of the polynomials rather than their coefficients.  This also affects the generated web documentation.

### Reproducing Code Example

```python
scipy.signal.??
```


### Error message

```shell
None
```


### SciPy/NumPy/Python version information

`1.6.3 1.20.3 sys.version_info(major=3, minor=8, micro=8, releaselevel='final', serial=0)`


Discussion:

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
@@ -2073,9 +2073,9 @@ def bilinear(b, a, fs=1.0):
 
     Returns
     -------
-    z : ndarray
+    b : ndarray
         Numerator of the transformed digital filter transfer function.
-    p : ndarray
+    a : ndarray
         Denominator of the transformed digital filter transfer function.
 
     See Also


Test patch:
Repository: scipy/scipy

Issue:
BUG: Visualization of CWT matrix in signal.cwt example code
### Describe your issue.

When show the matrix which from `signal.cwt` in a figure, the x_axis represents length of  `t`, the  y_axis represents `widths` (corresponding to the scale of ricker wavelet) in example code from the Scipy website https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.cwt.html. 

It is mistake as shown in Figure 1, because a smaller width means a more narrow peak theoretically. 

**The correct figure should be like as Figure 2 which data is the y_axis flip of the cwt matrix**. 

Figure 1 is very misleading though there is nothing wrong when calculate the cwt matrix. For a better experience and improving Scipy , the bug is given.

![image](https://user-images.githubusercontent.com/48829659/141977807-82383ade-a60b-4965-827e-5bfdfaf0f482.png)
Figure 1

![image](https://user-images.githubusercontent.com/48829659/141978086-82ee86c6-6271-4eaa-b228-f991b71b72fb.png)
Figure 2

### Reproducing Code Example

```python
from scipy import signal
import matplotlib.pyplot as plt
import numpy as np
t = np.linspace(-1, 1, 200, endpoint=False)
sig  = np.cos(2 * np.pi * 7 * t) + signal.gausspulse(t - 0.4, fc=2)
widths = np.arange(1, 31)
cwtmatr = signal.cwt(sig, signal.ricker, widths)
plt.imshow(cwtmatr, extent=[-1, 1, 1, 31], cmap='PRGn', aspect='auto',
           vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
#plt.imshow(np.flip(cwtmatr, axis=0), extent=[-1, 1, 1, 31], cmap='PRGn', aspect='auto',
#           vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
plt.show()
```


### Error message

```shell
none
```


### SciPy/NumPy/Python version information

1.5.4 1.19.5 sys.version_info(major=3, minor=6, micro=9, releaselevel='final', serial=0)


Discussion:

Resolving patch:
diff --git a/scipy/signal/_wavelets.py b/scipy/signal/_wavelets.py
--- a/scipy/signal/_wavelets.py
+++ b/scipy/signal/_wavelets.py
@@ -452,7 +452,11 @@ def cwt(data, wavelet, widths, dtype=None, **kwargs):
     >>> sig  = np.cos(2 * np.pi * 7 * t) + signal.gausspulse(t - 0.4, fc=2)
     >>> widths = np.arange(1, 31)
     >>> cwtmatr = signal.cwt(sig, signal.ricker, widths)
-    >>> plt.imshow(cwtmatr, extent=[-1, 1, 31, 1], cmap='PRGn', aspect='auto',
+
+    .. note:: For cwt matrix plotting it is advisable to flip the y-axis
+
+    >>> cwtmatr_yflip = np.flipud(cwtmatr)
+    >>> plt.imshow(cwtmatr_yflip, extent=[-1, 1, 1, 31], cmap='PRGn', aspect='auto',
     ...            vmax=abs(cwtmatr).max(), vmin=-abs(cwtmatr).max())
     >>> plt.show()
     """


Test patch:
Repository: scipy/scipy

Issue:
BUG: lombscargle fails if argument is a view
### Describe your issue.

Since #13316 was merged (i.e., in the scipy v1.7.x series), signal.lombscargle has failed if a positional argument is a view.

### Reproducing Code Example

```python
from scipy.signal import lombscargle
import numpy as np

x = np.arange(16, dtype=float)
yc = np.random.randn(16) + 1j * np.random.randn(16)
freqs = np.array([1, 2, 3], dtype=float)
crash = lombscargle(x, yc.imag, freqs)
```


### Error message

```shell
In [15]: run lombscargle_pythran_bug
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/work/programs/py/scipy_test/lombscargle_pythran_bug.py in <module>
      5 yc = np.random.randn(16) + 1j * np.random.randn(16)
      6 freqs = np.array([1, 2, 3], dtype=float)
----> 7 crash = lombscargle(x, yc.imag, freqs)

~/miniconda3/envs/py37/lib/python3.7/site-packages/scipy/signal/spectral.py in lombscargle(x, y, freqs, precenter, normalize)
    148         pgram = _lombscargle(x, y - y.mean(), freqs)
    149     else:
--> 150         pgram = _lombscargle(x, y, freqs)
    151
    152     if normalize:

TypeError: Invalid call to pythranized function `_lombscargle(float64[:], float64[:] (is a view), float64[:])'
Candidates are:

    - _lombscargle(float64[:], float64[:], float64[:])
```


### SciPy/NumPy/Python version information

1.7.3 1.21.5 sys.version_info(major=3, minor=7, micro=12, releaselevel='final', serial=0)


Discussion:
Thank you @efiring for reporting.

@serge-sans-paille is this expected? I can see from the doc a note about deep copying. Could this be conflicting with the view here?

Resolving patch:
diff --git a/scipy/signal/_spectral_py.py b/scipy/signal/_spectral_py.py
--- a/scipy/signal/_spectral_py.py
+++ b/scipy/signal/_spectral_py.py
@@ -134,9 +134,9 @@ def lombscargle(x,
     >>> plt.show()
 
     """
-    x = np.asarray(x, dtype=np.float64)
-    y = np.asarray(y, dtype=np.float64)
-    freqs = np.asarray(freqs, dtype=np.float64)
+    x = np.ascontiguousarray(x, dtype=np.float64)
+    y = np.ascontiguousarray(y, dtype=np.float64)
+    freqs = np.ascontiguousarray(freqs, dtype=np.float64)
 
     assert x.ndim == 1
     assert y.ndim == 1


Test patch:
Repository: scipy/scipy

Issue:
DOC-Update for InterpolatedUnivariateSpline and LSQUnivariateSpline
<!-- 
Thank you for taking the time to file a bug report. 
Please fill in the fields below, deleting the sections that 
don't apply to your issue. You can view the final output
by clicking the preview button above.
Note: This is a comment, and won't appear in the output.
-->

My issue is about inconsistency in the nomenclature of the  inherited classes:

1. `InterpolatedUnivariateSpline(UnivariateSpline):`
2. `LSQUnivariateSpline(UnivariateSpline):`

The inconsistency has two sources:

1. Default is not consistent defined as shown in the issue #14093
2. Default values are not defined like in case of parameter `k`:
https://github.com/scipy/scipy/blob/31351394351f944b9cf87c1fbc54213192cfe180/scipy/interpolate/fitpack2.py#L593-L594
`k` should be 3.

#### Reproducing code example:
<!-- 
If you place your code between the triple backticks below, 
it will be rendered as a code block. 
-->

https://github.com/scipy/scipy/blob/31351394351f944b9cf87c1fbc54213192cfe180/scipy/interpolate/fitpack2.py#L573-L611

https://github.com/scipy/scipy/blob/31351394351f944b9cf87c1fbc54213192cfe180/scipy/interpolate/fitpack2.py#L687-L730



#### Scipy/Numpy/Python version information:
<!-- You can simply run the following and paste the result in a code block
```
import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
```
-->
Current master branch


Discussion:

Resolving patch:
diff --git a/scipy/interpolate/_fitpack2.py b/scipy/interpolate/_fitpack2.py
--- a/scipy/interpolate/_fitpack2.py
+++ b/scipy/interpolate/_fitpack2.py
@@ -627,7 +627,8 @@ class InterpolatedUnivariateSpline(UnivariateSpline):
         2-sequence specifying the boundary of the approximation interval. If
         None (default), ``bbox=[x[0], x[-1]]``.
     k : int, optional
-        Degree of the smoothing spline.  Must be 1 <= `k` <= 5.
+        Degree of the smoothing spline.  Must be ``1 <= k <= 5``. Default is
+        ``k = 3``, a cubic spline.
     ext : int or str, optional
         Controls the extrapolation mode for elements
         not in the interval defined by the knot sequence.


Test patch:
Repository: scipy/scipy

Issue:
Add legend to `rv_histogram` plot in docs
Hi scipy folks, 

I was wondering whether it would add to the documentation to add legends to the example rv_histogram plot [here](https://docs.scipy.org/doc/scipy-1.8.1/reference/generated/scipy.stats.rv_histogram.html). In order to add this, I think I'd just have to add a `plt.legend()` [here](https://github.com/scipy/scipy/blob/7c6d6aa0d48b1f91ce4e24a19e08e9410f815b68/scipy/stats/_continuous_distns.py#L9645), right? 



Discussion:
Hi @jo-mueller, thank you for reporting. Yes this would be a good improvement and you correctly identified the fix. Another optional thing to consider while we are at it is to use the object oriented approach for Matplotlib.
Hi @tupui ,

thanks for the feedback.

> the object oriented approach for Matplotlib.

With that you mean something like this in the example?

```python
import matplotlib.pyplot as plt
X = np.linspace(-5.0, 5.0, 100)

fig, ax = plt.subplots()
ax.set_title("PDF from Template")
ax.hist(data, density=True, bins=100)
ax.plot(X, hist_dist.pdf(X), label='PDF')
ax.plot(X, hist_dist.cdf(X), label='CDF')
ax.legend()
fig.show()
```
Yes, exactly.

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
@@ -9638,11 +9638,13 @@ class rv_histogram(rv_continuous):
 
     >>> import matplotlib.pyplot as plt
     >>> X = np.linspace(-5.0, 5.0, 100)
-    >>> plt.title("PDF from Template")
-    >>> plt.hist(data, density=True, bins=100)
-    >>> plt.plot(X, hist_dist.pdf(X), label='PDF')
-    >>> plt.plot(X, hist_dist.cdf(X), label='CDF')
-    >>> plt.show()
+    >>> fig, ax = plt.subplots()
+    >>> ax.set_title("PDF from Template")
+    >>> ax.hist(data, density=True, bins=100)
+    >>> ax.plot(X, hist_dist.pdf(X), label='PDF')
+    >>> ax.plot(X, hist_dist.cdf(X), label='CDF')
+    >>> ax.legend()
+    >>> fig.show()
 
     """
     _support_mask = rv_continuous._support_mask


Test patch: