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

Issue:
MAINT: Missleading Error Message for IIR Filter
When using `scipy.singal.iirfilter` (or any other related filter design method), it is possible to trigger the error `Digital filter critical frequencies must be 0 < Wn < 1`:

```python
from scipy.signal import iirfilter
iirfilter(2, Wn=5, btype='low')
```
This error message is correct and helpful in the default case, but when the newish `fs` parameter is used, the error message is misleading/wrong:

```python
from scipy.signal import iirfilter
iirfilter(2, Wn=600, fs=1000, btype='low')   # Error message
iirfilter(2, Wn=300, fs=1000, btype='low')   # No Error message
```

This error message is generated in [this line](https://github.com/scipy/scipy/blob/b3a2071ce3952748c5e98ef7328d2b8eab77b2dc/scipy/signal/filter_design.py#L2346):
```py
if not analog:
    if numpy.any(Wn <= 0) or numpy.any(Wn >= 1):
        raise ValueError("Digital filter critical frequencies "
                                   "must be 0 < Wn < 1")
```

I would suggest to change it to:
```py
if not analog:
    if numpy.any(Wn <= 0) or numpy.any(Wn >= 1):
        if fs is not None:
            raise ValueError("Digital filter critical frequencies "
                                       "must be 0 < Wn < fs/2 (fs={})".format(fs))
        raise ValueError("Digital filter critical frequencies "
                           "must be 0 < Wn < 1")
```

If this is ok, I would start a pull request with this change




Discussion:
This was indeed on my todo list then I forgot. Please go ahead @AKuederle. Thanks for raising the issue. I would also add the actual value of `fs/2` in brackets in the inequality for a better understanding.

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
@@ -2343,6 +2343,9 @@ def iirfilter(N, Wn, rp=None, rs=None, btype='band', analog=False,
     # Pre-warp frequencies for digital filter design
     if not analog:
         if numpy.any(Wn <= 0) or numpy.any(Wn >= 1):
+            if fs is not None:
+                raise ValueError("Digital filter critical frequencies "
+                                 "must be 0 < Wn < fs/2 (fs={} -> fs/2={})".format(fs, fs/2))
             raise ValueError("Digital filter critical frequencies "
                              "must be 0 < Wn < 1")
         fs = 2.0


Test patch:
Repository: scipy/scipy

Issue:
Missing reference in `scipy.optimize.line_search` 
At the end of the docs of `scipy.optimize.line_search` it states
```
For the zoom phase it uses an algorithm by [...].
```

Anyone remembers what the `[...]` stands for, so that we could complete that missing information?

Probably slightly related to https://github.com/scipy/scipy/issues/4257, which addresses some document issues with `line_search`. That issue is quite old, so I thought I'd open a new issue.


Discussion:

Resolving patch:
diff --git a/scipy/optimize/linesearch.py b/scipy/optimize/linesearch.py
--- a/scipy/optimize/linesearch.py
+++ b/scipy/optimize/linesearch.py
@@ -259,9 +259,7 @@ def line_search_wolfe2(f, myfprime, xk, pk, gfk=None, old_fval=None,
     -----
     Uses the line search algorithm to enforce strong Wolfe
     conditions. See Wright and Nocedal, 'Numerical Optimization',
-    1999, pp. 59-60.
-
-    For the zoom phase it uses an algorithm by [...].
+    1999, pp. 59-61.
 
     """
     fc = [0]
@@ -375,9 +373,7 @@ def scalar_search_wolfe2(phi, derphi, phi0=None,
     -----
     Uses the line search algorithm to enforce strong Wolfe
     conditions. See Wright and Nocedal, 'Numerical Optimization',
-    1999, pp. 59-60.
-
-    For the zoom phase it uses an algorithm by [...].
+    1999, pp. 59-61.
 
     """
 
@@ -525,8 +521,15 @@ def _quadmin(a, fa, fpa, b, fb):
 
 def _zoom(a_lo, a_hi, phi_lo, phi_hi, derphi_lo,
           phi, derphi, phi0, derphi0, c1, c2, extra_condition):
-    """
+    """Zoom stage of approximate linesearch satisfying strong Wolfe conditions.
+    
     Part of the optimization algorithm in `scalar_search_wolfe2`.
+    
+    Notes
+    -----
+    Implements Algorithm 3.6 (zoom) in Wright and Nocedal,
+    'Numerical Optimization', 1999, pp. 61.
+
     """
 
     maxiter = 10


Test patch:
Repository: scipy/scipy

Issue:
Sparse matrix constructor data type detection changes on Numpy 1.18.0
There is some change in Numpy 1.18.0 with regard to integer data type selection. (This is currently causing refguide-check failures on master.)

On Numpy 1.18.0 we get
```
>>> scipy.sparse.csc_matrix(np.array([[1]])).dtype.type
<class 'numpy.longlong'>
>>> scipy.sparse.csc_matrix(np.array([[0]])).dtype.type
<class 'numpy.int64'>
```
whereas on 1.17.4 both result to `<class 'numpy.int64'>`. The integer type sizes are the same (`sizeof(long long) == sizeof(npy_int64)`), so this is some subtlety about which one gets picked by the csc_matrix constructor. Interestingly, `np.array()` picks always the `numpy.int64` one, so this might more probably be issue in scipy.sparse.


Discussion:
The upcast function which is used here to avoid overflows is converting the type from `numpy.int64` to`numpy.longlong` .

https://github.com/scipy/scipy/blob/76da841e41090c77f682afd77a951da455abed91/scipy/sparse/coo.py#L364-L369

Since integer type sizes are same here it isn't even providing any protection against overflow afaik.

On Numpy 1.18.0 `scipy.sparse.sputils.upcast()`  converts `numpy.int64` to `numpy.longlong` which is different from what happens in Numpy 1.17.4 where no conversion takes place.

Resolving patch:
diff --git a/scipy/sparse/sputils.py b/scipy/sparse/sputils.py
--- a/scipy/sparse/sputils.py
+++ b/scipy/sparse/sputils.py
@@ -12,7 +12,7 @@
            'isshape', 'issequence', 'isdense', 'ismatrix', 'get_sum_dtype']
 
 supported_dtypes = ['bool', 'int8', 'uint8', 'short', 'ushort', 'intc',
-                    'uintc', 'longlong', 'ulonglong', 'single', 'double',
+                    'uintc', 'l', 'L', 'longlong', 'ulonglong', 'single', 'double',
                     'longdouble', 'csingle', 'cdouble', 'clongdouble']
 supported_dtypes = [np.typeDict[x] for x in supported_dtypes]
 


Test patch:
Repository: scipy/scipy

Issue:
Documentation on SHGO inequality constraints appears contradictory
In the argument list for `shgo` (https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.shgo.html) describing **constraints**, it reads as follows:

```
g(x) <= 0 applied as g : R^n -> R^m
```

This would imply that `g(x)` should be non-positive in order to satisfy the constraint. However, the cattle-feed example in the documentation indicates that the functions for the inequality constraints should be non-*negative*, with `g1(x)` and `g2(x)` explicitly indicated as being `>= 0`.

To make things even more confusing, in the same cattle-feed example, the values of `g1(x)` and `g2(x)` at the minimizing value `res.x` are shown to be *negative*, implying that the constraints aren't satisfied.


Discussion:
Thanks for the report @jjramsey. @Stefan-Endres could you please have a look at this one?

Resolving patch:
diff --git a/scipy/optimize/_shgo.py b/scipy/optimize/_shgo.py
--- a/scipy/optimize/_shgo.py
+++ b/scipy/optimize/_shgo.py
@@ -45,7 +45,7 @@ def shgo(func, bounds, args=(), constraints=None, n=100, iters=1, callback=None,
         Constraints definition.
         Function(s) ``R**n`` in the form::
 
-            g(x) <= 0 applied as g : R^n -> R^m
+            g(x) >= 0 applied as g : R^n -> R^m
             h(x) == 0 applied as h : R^n -> R^p
 
         Each constraint is defined in a dictionary with fields:


Test patch:
Repository: scipy/scipy

Issue:
BUG: optimize: '**kw' argument of 'newton_krylov' is not documented
The signature for `optimize.newton_krylov` includes `**kw`, but `kw` is not documented in the `Parameters` section of the docstring.  The docstring should explain what is allowed, or at least explain how to find out (e.g. "Additional keyword arguments are passed to `foo`; see the `foo` docstring for more details.").



Discussion:
Actually, the `**kw` is documented in the Parameters under line 1350.

```
inner_tol, inner_maxiter, ...
        Parameters to pass on to the \"inner\" Krylov solver.
        See `scipy.sparse.linalg.gmres` for details.
```

All the parameters starting with `**inner_` except of mentioned elsewhere are going to be stripped of this prefix and passed to the Krylov solvers, such as `inner_tol` changing to `tol`.

I'm submitting a documentation fix without changing the mechanism itself, however, some may think it should be clarified.


Resolving patch:
diff --git a/scipy/optimize/nonlin.py b/scipy/optimize/nonlin.py
--- a/scipy/optimize/nonlin.py
+++ b/scipy/optimize/nonlin.py
@@ -1373,6 +1373,10 @@ class KrylovJacobian(Jacobian):
         the iterative solvers in `scipy.sparse.linalg`.
 
         The default is `scipy.sparse.linalg.lgmres`.
+    inner_maxiter : int, optional
+        Parameter to pass to the "inner" Krylov solver: maximum number of
+        iterations. Iteration will stop after maxiter steps even if the
+        specified tolerance has not been achieved.
     inner_M : LinearOperator or InverseJacobian
         Preconditioner for the inner Krylov iteration.
         Note that you can use also inverse Jacobians as (adaptive)
@@ -1386,12 +1390,14 @@ class KrylovJacobian(Jacobian):
         If the preconditioner has a method named 'update', it will be called
         as ``update(x, f)`` after each nonlinear step, with ``x`` giving
         the current point, and ``f`` the current function value.
-    inner_tol, inner_maxiter, ...
-        Parameters to pass on to the \"inner\" Krylov solver.
-        See `scipy.sparse.linalg.gmres` for details.
     outer_k : int, optional
         Size of the subspace kept across LGMRES nonlinear iterations.
         See `scipy.sparse.linalg.lgmres` for details.
+    inner_kwargs : kwargs
+        Keyword parameters for the "inner" Krylov solver
+        (defined with `method`). Parameter names must start with
+        the `inner_` prefix which will be stripped before passing on
+        the inner method. See, e.g., `scipy.sparse.linalg.gmres` for details.
     %(params_extra)s
 
     See Also


Test patch:
Repository: scipy/scipy

Issue:
Where is the Wiener Filter derived from?
I am using the Wiener Filter to do speech enhancement (1D data) and while I see the [source code](https://github.com/scipy/scipy/blob/v0.14.0/scipy/signal/signaltools.py#L441), I'm unsure where it was derived from. Is there an academic or authoritative source that it came from?


Discussion:
Reading https://scipy.github.io/devdocs/tutorial/signal.html#wiener-filter it's probably the same as wiener2 in Octave/Matlab, whose reference points to Lim, Jae S., Two-Dimensional Signal and Image Processing, Englewood Cliffs, NJ, Prentice Hall, 1990, p. 548.

The documentation should be updated with this, and also the docstring should be changed to be clearer about what the function does and in what sense is this a "Wiener filter".
Thanks for replying so quickly @pv. 
May I look into making the necessary changes in the docstrings and documentation?

Resolving patch:
diff --git a/scipy/signal/signaltools.py b/scipy/signal/signaltools.py
--- a/scipy/signal/signaltools.py
+++ b/scipy/signal/signaltools.py
@@ -1432,6 +1432,31 @@ def wiener(im, mysize=None, noise=None):
     out : ndarray
         Wiener filtered result with the same shape as `im`.
 
+    Examples
+    --------
+
+    >>> from scipy.misc import face
+    >>> from scipy.signal.signaltools import wiener
+    >>> import matplotlib.pyplot as plt
+    >>> import numpy as np
+    >>> img = np.random.random((40, 40))    #Create a random image
+    >>> filtered_img = wiener(img, (5, 5))  #Filter the image
+    >>> f, (plot1, plot2) = plt.subplots(1, 2)
+    >>> plot1.imshow(img)
+    >>> plot2.imshow(filtered_img)
+    >>> plt.show()
+
+    Notes
+    -----
+    This implementation is similar to wiener2 in Matlab/Octave.
+    For more details see [1]_
+
+    References
+    ----------
+    .. [1] Lim, Jae S., Two-Dimensional Signal and Image Processing,
+           Englewood Cliffs, NJ, Prentice Hall, 1990, p. 548.
+
+
     """
     im = np.asarray(im)
     if mysize is None:


Test patch:
Repository: scipy/scipy

Issue:
Wrongly typed comparison in integrate.quad
I believe there is an trivial typo in the `integrate.quad` implementation:

https://github.com/scipy/scipy/blob/832bdf3b0378f05bd0f74ff5f00464524729c6d8/scipy/integrate/quadpack.py#L385

The comparison to `a` should be a `a == - Inf`. After

https://github.com/scipy/scipy/blob/832bdf3b0378f05bd0f74ff5f00464524729c6d8/scipy/integrate/quadpack.py#L338

`a` should be definitely smaller then `b` and i.e. smaller than `Inf`. This line is correct:
https://github.com/scipy/scipy/blob/832bdf3b0378f05bd0f74ff5f00464524729c6d8/scipy/integrate/quadpack.py#L368


Discussion:
Indeed, looks like a typo. Care to send a PR with the fix?

Resolving patch:
diff --git a/scipy/integrate/quadpack.py b/scipy/integrate/quadpack.py
--- a/scipy/integrate/quadpack.py
+++ b/scipy/integrate/quadpack.py
@@ -387,7 +387,7 @@ def quad(func, a, b, args=(), full_output=0, epsabs=1.49e-8, epsrel=1.49e-8,
 
     if ier in [1,2,3,4,5,7]:
         if full_output:
-            if weight in ['cos', 'sin'] and (b == Inf or a == Inf):
+            if weight in ['cos', 'sin'] and (b == Inf or a == -Inf):
                 return retval[:-1] + (msg, explain)
             else:
                 return retval[:-1] + (msg,)


Test patch:
Repository: scipy/scipy

Issue:
output of special.voigt_profile when sigma=0
Hey!

scipy.special.voigt_profile(x, sigma, gamma, out=None) returns NA when sigma=0.
However, I would have expected/it would be useful if in that case it returns a Lorentzian profile, as e.g. described here:
http://apps.jcns.fz-juelich.de/man/voigt.html
Best,
Alex


Discussion:

Resolving patch:
diff --git a/scipy/special/add_newdocs.py b/scipy/special/add_newdocs.py
--- a/scipy/special/add_newdocs.py
+++ b/scipy/special/add_newdocs.py
@@ -112,6 +112,10 @@ def add_newdoc(name, doc):
     standard deviation ``sigma`` and a 1-D Cauchy distribution with half-width at
     half-maximum ``gamma``.
 
+    If ``sigma = 0``, PDF of Cauchy distribution is returned.
+    Conversely, if ``gamma = 0``, PDF of Normal distribution is returned.
+    If ``sigma = gamma = 0``, the return value is ``Inf`` for ``x = 0``, and ``0`` for all other ``x``.
+
     Parameters
     ----------
     x : array_like


Test patch:
diff --git a/scipy/special/tests/test_faddeeva.py b/scipy/special/tests/test_faddeeva.py
--- a/scipy/special/tests/test_faddeeva.py
+++ b/scipy/special/tests/test_faddeeva.py
@@ -11,7 +11,12 @@ class TestVoigtProfile(object):
     @pytest.mark.parametrize('x, sigma, gamma', [
         (np.nan, 1, 1),
         (0, np.nan, 1),
-        (0, 1, np.nan)
+        (0, 1, np.nan),
+        (1, np.nan, 0),
+        (np.nan, 1, 0),
+        (1, 0, np.nan),
+        (np.nan, 0, 1),
+        (np.nan, 0, 0)
     ])
     def test_nan(self, x, sigma, gamma):
         assert np.isnan(sc.voigt_profile(x, sigma, gamma))
@@ -57,3 +62,24 @@ def test_symmetry(self):
             rtol=1e-15,
             atol=0
         )
+
+    @pytest.mark.parametrize('x, sigma, gamma, desired', [
+        (0, 0, 0, np.inf),
+        (1, 0, 0, 0)
+    ])
+    def test_corner_cases(self, x, sigma, gamma, desired):
+        assert sc.voigt_profile(x, sigma, gamma) == desired
+
+    @pytest.mark.parametrize('sigma1, gamma1, sigma2, gamma2', [
+        (0, 1, 1e-16, 1),
+        (1, 0, 1, 1e-16),
+        (0, 0, 1e-16, 1e-16)
+    ])
+    def test_continuity(self, sigma1, gamma1, sigma2, gamma2):
+        x = np.linspace(1, 10, 20)
+        assert_allclose(
+            sc.voigt_profile(x, sigma1, gamma1),
+            sc.voigt_profile(x, sigma2, gamma2),
+            rtol=1e-16,
+            atol=1e-16
+        )
Repository: scipy/scipy

Issue:
typo in docstring of scipy.stats.norminvgauss
There  is a typo in the [documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norminvgauss.html#scipy.stats.norminvgauss) for ``scipy.stats.norminvgauss``.

In the expression for the pdf, f(x,a,b), the bessel function, K_1(...) should be in the numerator, not the denominator. 

(I checked this in Wikipedia, in the source code and in one of the references.)


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
@@ -3922,8 +3922,8 @@ class norminvgauss_gen(rv_continuous):
 
     .. math::
 
-        f(x, a, b) = (a \exp(\sqrt{a^2 - b^2} + b x)) /
-                     (\pi \sqrt{1 + x^2} \, K_1(a \sqrt{1 + x^2}))
+        f(x, a, b) = \frac{a \, K_1(a \sqrt{1 + x^2})}{\pi \sqrt{1 + x^2}} \,
+                     \exp(\sqrt{a^2 - b^2} + b x)
 
     where :math:`x` is a real number, the parameter :math:`a` is the tail
     heaviness and :math:`b` is the asymmetry parameter satisfying


Test patch:
Repository: scipy/scipy

Issue:
SmoothBivariateSpline bbox parameter
<!-- 
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 SmoothBivariateSpline documantation 


<!-- 
If you place your code between the triple backticks below, 
it will be rendered as a code block. 
-->
It is not mistake, but a clarification. I searched some info about parameters and 
i found the information only through another documentation page.


In this doc about [LSQBivariateSpline](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.LSQBivariateSpline.html#scipy.interpolate.LSQBivariateSpline)  we have info about parameters tx and ty , but in doc site about [SmoothBivariateSpline](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.SmoothBivariateSpline.html#scipy.interpolate.SmoothBivariateSpline) we havn't  info about parameters tx and ty, and we cant set this parameters when call constructor, but bbox by default use it. In parent class [BivariateSpline](https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.BivariateSpline.html#scipy.interpolate.BivariateSpline) we also havn't info about tx, ty.


```
bbox: array_like, optional
Sequence of length 4 specifying the boundary of the rectangular approximation domain.
By default, bbox=[min(x,tx),max(x,tx), min(y,ty),max(y,ty)].
```

#### Scipy/Numpy/Python version information: 1.4.1 SciPy
<!-- 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)
```
-->


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
@@ -1015,7 +1015,7 @@ class SmoothBivariateSpline(BivariateSpline):
     bbox : array_like, optional
         Sequence of length 4 specifying the boundary of the rectangular
         approximation domain.  By default,
-        ``bbox=[min(x,tx),max(x,tx), min(y,ty),max(y,ty)]``.
+        ``bbox=[min(x), max(x), min(y), max(y)]``.
     kx, ky : ints, optional
         Degrees of the bivariate spline. Default is 3.
     s : float, optional


Test patch:
Repository: scipy/scipy

Issue:
Small error in gamma continuous rv fit comments
https://github.com/scipy/scipy/blob/adc4f4f7bab120ccfab9383aba272954a0a12fb0/scipy/stats/_continuous_distns.py#L2794

The comment and the line below it currently read:
```python
                # shape and scale are both free.
                # The MLE for the shape parameter `a` is the solution to:
                # np.log(a) - sc.digamma(a) - np.log(xbar) +
                #                             np.log(data.mean) = 0
                s = np.log(xbar) - np.log(data).mean()
```

The comment should read:

```python
                # shape and scale are both free.
                # The MLE for the shape parameter `a` is the solution to:
                # np.log(a) - sc.digamma(a) - np.log(xbar) +
                #                             np.log(data).mean() = 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
@@ -2896,7 +2896,7 @@ def fit(self, data, *args, **kwds):
                 # shape and scale are both free.
                 # The MLE for the shape parameter `a` is the solution to:
                 # np.log(a) - sc.digamma(a) - np.log(xbar) +
-                #                             np.log(data.mean) = 0
+                #                             np.log(data).mean() = 0
                 s = np.log(xbar) - np.log(data).mean()
                 func = lambda a: np.log(a) - sc.digamma(a) - s
                 aest = (3-s + np.sqrt((s-3)**2 + 24*s)) / (12*s)


Test patch:
Repository: scipy/scipy

Issue:
Document implicit sum in csr_matrix() constructor
<!-- 
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 csr_matrix().

#### Reproducing code example:
<!-- 
If you place your code between the triple backticks below, 
it will be rendered as a code block. 
-->

```
from scipy.sparse import csr_matrix
csr_matrix(([1,1,1],([0,0,0],[0,0,0])), shape=(1,1)).todense()
```
Result: matrix([[3]])
Expected: matrix([[1]])
This is an implicit behaviour. I can not find anything about this in the documentation.
I assume, there are 3 options:
1. Raise a error.
2. Use only last value in the list.
3. Document current behaviour.



Discussion:
This is indeed the intended behavior, and it's documented (albeit not very prominently) here:
https://docs.scipy.org/doc/scipy/reference/sparse.html#example-2

I agree that we should make this more prominent in the docs.
I think, it will be ok if you add notice right to https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
@aikho I would love to work on this. Do you want me to add the above example as a notice to https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
@sameshl would be great to add something similar to example 2 from https://docs.scipy.org/doc/scipy/reference/sparse.html#example-2 right to https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.html
Hi! My guess is that @sameshl is not working on this, and wouldn't be angry if I'll make the PR
@erheron please go ahead!

Resolving patch:
diff --git a/scipy/sparse/csr.py b/scipy/sparse/csr.py
--- a/scipy/sparse/csr.py
+++ b/scipy/sparse/csr.py
@@ -100,6 +100,16 @@ class csr_matrix(_cs_matrix):
            [0, 0, 3],
            [4, 5, 6]])
 
+    Duplicate entries are summed together:
+
+    >>> row = np.array([0, 1, 2, 0])
+    >>> col = np.array([0, 1, 1, 0])
+    >>> data = np.array([1, 2, 4, 8])
+    >>> csr_matrix((data, (row, col)), shape=(3, 3)).toarray()
+    array([[9, 0, 0],
+           [0, 2, 0],
+           [4, 0, 0]])
+
     As an example of how to construct a CSR matrix incrementally,
     the following snippet builds a term-document matrix from texts:
 


Test patch: