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

Issue:
Missing complex conjugation in scipy.sparse.linalg.LinearOperator
I noticed that there is a complex conjugation missing in the implementation of ```scipy.sparse.linalg.interface._ScaledLinearOperator._adjoint```:

```
    def _adjoint(self):
        A, alpha = self.args
        return A.H * alpha
 ```

The correct version should be:

```
    def _adjoint(self):
        A, alpha = self.args
        return A.H * np.conj(alpha)
 ```

Considering also the other issues posted for the ```LinearOperator``` class, I have the impression that the implementation is not very mature yet. However, in my opinion, it is a very useful interface for linear operators, especially for matrix-free implementations, and therefore I consider it worth to further improve on it.

### Reproducing code example:
```
>>> import numpy as np
>>> from scipy.sparse.linalg import aslinearoperator

>>> mat = np.arange(9.0).reshape((3, 3))
>>> vec = np.arange(3.0)

>>> result_array = (1j * mat).conj().T.dot(vec)
>>> result_linop = (1j * aslinearoperator(mat)).adjoint().dot(vec)

>>> print(result_array)
[0.-15.j 0.-18.j 0.-21.j]

>>> print(result_linop)
[0.+15.j 0.+18.j 0.+21.j]
```

### Scipy/Numpy/Python version information:
```
1.1.0 1.14.3 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
```




Discussion:

Resolving patch:
diff --git a/scipy/sparse/linalg/interface.py b/scipy/sparse/linalg/interface.py
--- a/scipy/sparse/linalg/interface.py
+++ b/scipy/sparse/linalg/interface.py
@@ -564,7 +564,7 @@ def _matmat(self, x):
 
     def _adjoint(self):
         A, alpha = self.args
-        return A.H * alpha
+        return A.H * np.conj(alpha)
 
 
 class _PowerLinearOperator(LinearOperator):


Test patch:
diff --git a/scipy/sparse/linalg/tests/test_interface.py b/scipy/sparse/linalg/tests/test_interface.py
--- a/scipy/sparse/linalg/tests/test_interface.py
+++ b/scipy/sparse/linalg/tests/test_interface.py
@@ -352,3 +352,15 @@ def matvec(v):
     # operator dtype)
     A = interface.LinearOperator((2, 2), matvec=matvec)
     assert_equal(call_count[0], 1)
+
+def test_adjoint_conjugate():
+    X = np.array([[1j]])
+    A = interface.aslinearoperator(X)
+
+    B = 1j * A
+    Y = 1j * X
+
+    v = np.array([1])
+
+    assert_equal(B.dot(v), Y.dot(v))
+    assert_equal(B.H.dot(v), Y.T.conj().dot(v))
Repository: scipy/scipy

Issue:
ENH: scipy.sparse: copy keyword added to asformat method
I added a `copy` keyword to the `asformat` method of the sparse matrices in `scipy.sparse`.


Discussion:
Thanks for the comments. I made the proposed changes.
Looks good, merging.

Resolving patch:
diff --git a/scipy/sparse/base.py b/scipy/sparse/base.py
--- a/scipy/sparse/base.py
+++ b/scipy/sparse/base.py
@@ -297,20 +297,19 @@ def __len__(self):
                         " or shape[0]")
 
     def asformat(self, format, copy=False):
-        """Return this matrix in the passed sparse format.
+        """Return this matrix in the passed format.
 
         Parameters
         ----------
         format : {str, None}
-            The desired sparse matrix format ("csr", "csc", "lil", "dok", ...)
+            The desired matrix format ("csr", "csc", "lil", "dok", "array", ...)
             or None for no conversion.
         copy : bool, optional
             If True, the result is guaranteed to not share data with self.
 
         Returns
         -------
-        A : This matrix in the passed sparse format.
-
+        A : This matrix in the passed format.
         """
         if format is None or format == self.format:
             if copy:
@@ -322,8 +321,12 @@ def asformat(self, format, copy=False):
                 convert_method = getattr(self, 'to' + format)
             except AttributeError:
                 raise ValueError('Format {} is unknown.'.format(format))
-            else:
+
+            # Forward the copy kwarg, if it's accepted.
+            try:
                 return convert_method(copy=copy)
+            except TypeError:
+                return convert_method()
 
     ###################################################################
     #  NOTE: All arithmetic operations use csr_matrix by default.


Test patch:
diff --git a/scipy/sparse/tests/test_base.py b/scipy/sparse/tests/test_base.py
--- a/scipy/sparse/tests/test_base.py
+++ b/scipy/sparse/tests/test_base.py
@@ -1701,6 +1701,13 @@ def test_sparse_format_conversions(self):
             assert_equal(c.format,format)
             assert_array_equal(c.todense(), D)
 
+        for format in ['array', 'dense']:
+            a = A.asformat(format)
+            assert_array_equal(a, D)
+
+            b = self.spmatrix(D+3j).asformat(format)
+            assert_array_equal(b, D+3j)
+
     def test_tobsr(self):
         x = array([[1,0,2,0],[0,0,0,0],[0,0,4,5]])
         y = array([[0,1,2],[3,0,5]])
Repository: scipy/scipy

Issue:
BUG: linalg.subspace_angles gives wrong results
The function subspace_angles gives wrong results this can be shown with a simple example:
Two matrices have two vectors pointing to the same direction, but the last ones are orthogonoal to each other and are not contained in the space of the other ones. Therefore the subspace angles must be 0, 0 and pi/2.


### Reproducing code example:
```
import numpy as np
from scipy.linalg import subspace_angles

A = np.array([[1, 0, 0],
       [0, 1, 0],
       [0, 0, 1],
       [0, 0, 0],
       [0, 0, 0]])

B = np.array([[1. , 0. , 0. ],
       [0. , 1. , 0. ],
       [0. , 0. , 0. ],
       [0. , 0., 0. ],
       [0. , 0. , 1. ]])

sangles = subspace_angles(A,B)
print(sangles) # Produces wrong angles!
```

### Error message:
```
# No error message
```

### Scipy/Numpy/Python version information:
```
<<Output from 'import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)'>>
1.0.0 1.14.0 sys.version_info(major=3, minor=6, micro=4, releaselevel='final', serial=0)
```




Discussion:
I am going to send a pull request for this issue.

Resolving patch:
diff --git a/scipy/linalg/decomp_svd.py b/scipy/linalg/decomp_svd.py
--- a/scipy/linalg/decomp_svd.py
+++ b/scipy/linalg/decomp_svd.py
@@ -405,7 +405,8 @@ def subspace_angles(A, B):
     Returns
     -------
     angles : ndarray, shape (min(N, K),)
-        The subspace angles between the column spaces of `A` and `B`.
+        The subspace angles between the column spaces of `A` and `B` in
+        descending order.
 
     See Also
     --------
@@ -489,5 +490,6 @@ def subspace_angles(A, B):
         mu_arcsin = 0.
 
     # 5. Compute the principal angles
-    theta = where(mask, mu_arcsin, arccos(clip(sigma, -1., 1.)))
+    # with reverse ordering of sigma because smallest sigma belongs to largest angle theta
+    theta = where(mask, mu_arcsin, arccos(clip(sigma[::-1], -1., 1.)))
     return theta


Test patch:
diff --git a/scipy/linalg/tests/test_decomp.py b/scipy/linalg/tests/test_decomp.py
--- a/scipy/linalg/tests/test_decomp.py
+++ b/scipy/linalg/tests/test_decomp.py
@@ -2722,6 +2722,20 @@ def test_subspace_angles():
     assert_raises(ValueError, subspace_angles, x, x[0])
     assert_raises(ValueError, subspace_angles, x[:-1], x)
 
+    # Test branch if mask.any is True:
+    A = np.array([[1, 0, 0],
+                  [0, 1, 0],
+                  [0, 0, 1],
+                  [0, 0, 0],
+                  [0, 0, 0]])
+    B = np.array([[1, 0, 0],
+                  [0, 1, 0],
+                  [0, 0, 0],
+                  [0, 0, 0],
+                  [0, 0, 1]])
+    expected = np.array([np.pi/2, 0, 0])
+    assert_allclose(subspace_angles(A, B), expected, rtol=1e-12)
+
 
 class TestCDF2RDF(object):
Repository: scipy/scipy

Issue:
doc/linalg: add cho_solve_banded to see also of cholesky_banded
See title. Maybe also improve the example in `linalg.cholesky_banded`.

 I'd just submit a PR, but I don't have git available right now. 


Discussion:
I am willing to take a stab at this
@souravsingh Go for it.
I am new to open source contribution but I also want to contribute to this.

@shashvatshahi1998 Thanks for your interest. We don't really assign issues to individuals. You can send a pull request directly if noone else sent already. 

By the way, we have more in #7168 for grabs in case you feel like it.

Resolving patch:
diff --git a/scipy/linalg/decomp_cholesky.py b/scipy/linalg/decomp_cholesky.py
--- a/scipy/linalg/decomp_cholesky.py
+++ b/scipy/linalg/decomp_cholesky.py
@@ -252,6 +252,11 @@ def cholesky_banded(ab, overwrite_ab=False, lower=False, check_finite=True):
     -------
     c : (u + 1, M) ndarray
         Cholesky factorization of a, in the same banded format as ab
+        
+    See also
+    --------
+    cho_solve_banded : Solve a linear set equations, given the Cholesky factorization
+                of a banded hermitian.
 
     Examples
     --------


Test patch:
Repository: scipy/scipy

Issue:
truncnorm does not work if b < a in scipy.stats
truncnorm does not check that `a < b`. If `b > a`, one can produce rvs but the pdf and cdf do not work.
Should be easy to fix using `_argcheck`. 

### Reproducing code example:
```
from scipy import stats
import numpy as np

x = np.arange(1, 2, 0.1)
stats.truncnorm(2, 1).pdf(x) # all 0
stats.truncnorm(2, 1).cdf(1) # 1.0
stats.truncnorm(2, 1).cdf(0.999) # 0.0
stats.truncnorm(2, 1).rvs(size=5, random_state=123) 
# array([1.1880652 , 1.54116815, 1.61108676, 1.29490424, 1.17234318])
```

This does not make sense.

### Scipy/Numpy/Python version information:
```
1.0.0 1.14.1 sys.version_info(major=3, minor=5, micro=4, 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
@@ -6254,7 +6254,7 @@ def _argcheck(self, a, b):
                                -(self._sb - self._sa),
                                self._nb - self._na)
         self._logdelta = np.log(self._delta)
-        return a != b
+        return a < b
 
     def _pdf(self, x, a, b):
         return _norm_pdf(x) / self._delta


Test patch:
Repository: scipy/scipy

Issue:
RootResults not mentioned in reference guide, and could use better __str__
RootResults should be mentioned in the reference guide (like OptimizationResult), and have a `__str__` like OptimizationResult.



Discussion:
Agreed. It's very odd though that `root` itself returns an `OptimizeResult` and the various scalar root-finding methods a `RootResult`. 

If there was no back-compatibility issues I would suggest returning the same OptimizeResult for all of these functions but I guess it's not going to happen...
(Also, for nitpicking, one may wonder why it's OptimizeResult but RootResults (plural).)

related to #4204 which adds the docstring, but not the reference in the documentation

Resolving patch:
diff --git a/scipy/optimize/__init__.py b/scipy/optimize/__init__.py
--- a/scipy/optimize/__init__.py
+++ b/scipy/optimize/__init__.py
@@ -147,6 +147,8 @@
    ridder - Ridder's method.
    bisect - Bisection method.
    newton - Secant method or Newton's method.
+   RootResults - The root finding result returned by some root finders.
+
 
 Fixed point finding:
 
diff --git a/scipy/optimize/zeros.py b/scipy/optimize/zeros.py
--- a/scipy/optimize/zeros.py
+++ b/scipy/optimize/zeros.py
@@ -9,7 +9,7 @@
 _xtol = 2e-12
 _rtol = 4 * np.finfo(float).eps
 
-__all__ = ['newton', 'bisect', 'ridder', 'brentq', 'brenth']
+__all__ = ['newton', 'bisect', 'ridder', 'brentq', 'brenth', 'RootResults']
 
 CONVERGED = 'converged'
 SIGNERR = 'sign error'
@@ -530,7 +530,7 @@ def ridder(f, a, b, args=(),
     full_output : bool, optional
         If `full_output` is False, the root is returned.  If `full_output` is
         True, the return value is ``(x, r)``, where `x` is the root, and `r` is
-        a RootResults object.
+        a `RootResults` object.
     disp : bool, optional
         If True, raise RuntimeError if the algorithm didn't converge.
 
@@ -646,7 +646,7 @@ def brentq(f, a, b, args=(),
     full_output : bool, optional
         If `full_output` is False, the root is returned.  If `full_output` is
         True, the return value is ``(x, r)``, where `x` is the root, and `r` is
-        a RootResults object.
+        a `RootResults` object.
     disp : bool, optional
         If True, raise RuntimeError if the algorithm didn't converge.
 
@@ -764,7 +764,7 @@ def brenth(f, a, b, args=(),
     full_output : bool, optional
         If `full_output` is False, the root is returned.  If `full_output` is
         True, the return value is ``(x, r)``, where `x` is the root, and `r` is
-        a RootResults object.
+        a `RootResults` object.
     disp : bool, optional
         If True, raise RuntimeError if the algorithm didn't converge.
 


Test patch:
Repository: scipy/scipy

Issue:
Correct the spelling to approximation
https://github.com/scipy/scipy/blob/f238270111976d00615686395df0986847c25132/scipy/signal/signaltools.py#L1996


Discussion:

Resolving patch:
diff --git a/scipy/signal/signaltools.py b/scipy/signal/signaltools.py
--- a/scipy/signal/signaltools.py
+++ b/scipy/signal/signaltools.py
@@ -2367,7 +2367,7 @@ def resample_poly(x, up, down, axis=0, window=('kaiser', 5.0)):
         raise ValueError('up and down must be >= 1')
 
     # Determine our up and down factors
-    # Use a rational approimation to save computation time on really long
+    # Use a rational approximation to save computation time on really long
     # signals
     g_ = gcd(up, down)
     up //= g_


Test patch:
Repository: scipy/scipy

Issue:
Mention sampling method for rvs in doc
It would be nice if the default method used for drawing samples (i.e. inverse transform sampling) would be mentioned somewhere in the documentation.

The source code explains it:
https://github.com/scipy/scipy/blob/v1.1.0/scipy/stats/_distn_infrastructure.py#L881
```
## Use basic inverse cdf algorithm for RV generation as default.
U = self._random_state.random_sample(self._size)
Y = self._ppf(U, *args)
return Y
```

But in my opinion this is a bit too hidden for something that is not at all obvious and more than just a trivial implementation detail.

Thanks :)


Discussion:

Resolving patch:
diff --git a/scipy/stats/_distn_infrastructure.py b/scipy/stats/_distn_infrastructure.py
--- a/scipy/stats/_distn_infrastructure.py
+++ b/scipy/stats/_distn_infrastructure.py
@@ -1407,7 +1407,16 @@ class rv_continuous(rv_generic):
 
       _logpdf, _cdf, _logcdf, _ppf, _rvs, _isf, _sf, _logsf
 
-    Rarely would you override ``_isf``, ``_sf`` or ``_logsf``, but you could.
+    The default method ``_rvs`` relies on the inverse of the cdf, ``_ppf``,
+    applied to a uniform random variate. In order to generate random variates
+    efficiently, either the default ``_ppf`` needs to be overwritten (e.g.
+    if the inverse cdf can expressed in an explicit form) or a sampling
+    method needs to be implemented in a custom ``_rvs`` method.
+
+    If possible, you should override ``_isf``, ``_sf`` or ``_logsf``.
+    The main reason would be to improve numerical accuracy: for example,
+    the survival function ``_sf`` is computed as ``1 - _cdf`` which can
+    result in loss of precision if ``_cdf(x)`` is close to one.
 
     **Methods that can be overwritten by subclasses**
     ::
@@ -1445,7 +1454,7 @@ class rv_continuous(rv_generic):
     rv = generic(<shape(s)>, loc=0, scale=1)
         `rv_frozen` object with the same methods but holding the given shape,
         location, and scale fixed
-        
+
     **Statistics**
 
     Statistics are computed using numerical integration by default.


Test patch:
Repository: scipy/scipy

Issue:
Example from documentation of scipy.sparse.linalg.eigs raises AttributeError
The example at https://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.linalg.eigs.html is not running and raises an `AttributeError`.

This could be fixed by modifying the example to call
```
from scipy.sparse.linalg import eigs
id = np.eye(13)
vals, vecs = eigs(id, k=6)
``` 
instead. 


### Reproducing code example:
```
import scipy.sparse as sparse
id = np.eye(13)
vals, vecs = sparse.linalg.eigs(id, k=6)
```

### Error message:
```
AttributeError                            Traceback (most recent call last)
<ipython-input-2-e3c8d9e33d7e> in <module>()
      1 import scipy.sparse as sparse
      2 id = np.eye(13)
----> 3 vals, vecs = sparse.linalg.eigs(id, k=6)

AttributeError: module 'scipy.sparse' has no attribute 'linalg'
```

### Scipy/Numpy/Python version information:
```
1.1.0 1.15.2 sys.version_info(major=3, minor=6, micro=6, releaselevel='final', serial=0)
```




Discussion:

Resolving patch:
diff --git a/scipy/sparse/linalg/eigen/arpack/arpack.py b/scipy/sparse/linalg/eigen/arpack/arpack.py
--- a/scipy/sparse/linalg/eigen/arpack/arpack.py
+++ b/scipy/sparse/linalg/eigen/arpack/arpack.py
@@ -1224,9 +1224,9 @@ def eigs(A, k=6, M=None, sigma=None, which='LM', v0=None,
     --------
     Find 6 eigenvectors of the identity matrix:
 
-    >>> import scipy.sparse as sparse
+    >>> from scipy.sparse.linalg import eigs
     >>> id = np.eye(13)
-    >>> vals, vecs = sparse.linalg.eigs(id, k=6)
+    >>> vals, vecs = eigs(id, k=6)
     >>> vals
     array([ 1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j,  1.+0.j])
     >>> vecs.shape


Test patch:
Repository: scipy/scipy

Issue:
Default value for "mode" in "ndimage.shift"
In scipy.ndimage.shift the mode's default value is 'constant', but [in the documentation](https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.shift.html#scipy.ndimage.shift) it says Default is 'reflect'.
Which of the two is wrong?


Discussion:
The documentation of the ndimage funcs come from 

https://github.com/scipy/scipy/blob/14142ff70d84a6ce74044a27919c850e893648f7/scipy/ndimage/_ni_docstrings.py#L34-L56

if they are marked with the decorator .  

Here it seems that the autodocs need to be corrected to `constant` since the signature shows `constant` which is the value that is passed by default and this applies to all funcs.
Xref #8528

Resolving patch:
diff --git a/scipy/ndimage/_ni_docstrings.py b/scipy/ndimage/_ni_docstrings.py
--- a/scipy/ndimage/_ni_docstrings.py
+++ b/scipy/ndimage/_ni_docstrings.py
@@ -34,7 +34,7 @@
 _mode_doc = (
 """mode : {'reflect', 'constant', 'nearest', 'mirror', 'wrap'}, optional
     The `mode` parameter determines how the input array is extended
-    when the filter overlaps a border. Default is 'reflect'. Behavior
+    when the filter overlaps a border. Default is 'constant'. Behavior
     for each valid value is as follows:
 
     'reflect' (`d c b a | a b c d | d c b a`)


Test patch:
Repository: scipy/scipy

Issue:
Error in docstring of show_options ?
<!-- 
Thank you for taking the time to report a SciPy issue.
Please describe the issue in detail, and for bug reports
fill in the fields below. You can delete the sections that 
don't apply to your issue. You can view the final output
by clicking the preview button above.
-->
Hi,

My issue is about the docstring of the [show_options](https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.show_options.html#scipy.optimize.show_options) function. Here is the piece of code of interest:
https://github.com/scipy/scipy/blob/14142ff70d84a6ce74044a27919c850e893648f7/scipy/optimize/optimize.py#L2900-L2906

I think that the text in Returns should be:
`Either None (for disp=True) or the text string (disp=False)`
since the message is printed if disp=True and returned if disp=False:

https://github.com/scipy/scipy/blob/14142ff70d84a6ce74044a27919c850e893648f7/scipy/optimize/optimize.py#L3034-L3038

Or am I getting something wrong?

Best regards,
Johann


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
@@ -2971,7 +2971,7 @@ def show_options(solver=None, method=None, disp=True):
     Returns
     -------
     text
-        Either None (for disp=False) or the text string (disp=True)
+        Either None (for disp=True) or the text string (disp=False)
 
     Notes
     -----


Test patch:
Repository: scipy/scipy

Issue:
request for clarification in documentation
From examination of the code that is wrapped by `scipy.interpolate.LSQSphereBivariateSpline`, I discovered that this method fits a bivariate cubic spline.  It would be helpful if the documentation were updated to indicate that the order of the spline is 3 (cubic or bicubic).


Discussion:
PR welcome.
taking this up!

Resolving patch:
diff --git a/scipy/interpolate/fitpack2.py b/scipy/interpolate/fitpack2.py
--- a/scipy/interpolate/fitpack2.py
+++ b/scipy/interpolate/fitpack2.py
@@ -1393,6 +1393,9 @@ class LSQSphereBivariateSpline(SphereBivariateSpline):
     """
     Weighted least-squares bivariate spline approximation in spherical
     coordinates.
+    
+    Determines a smooth bicubic spline according to a given
+    set of knots in the `theta` and `phi` directions.
 
     .. versionadded:: 0.11.0
 


Test patch:
Repository: scipy/scipy

Issue:
exponnorm.pdf returns NAN for small K
For small values of K exponnorm.pdf returns nan. 

### Reproducing code example:
```
from scipy.stats import exponnorm
exponnorm.pdf(1, K=0.01)
Out[3]: nan
```

### Error message:
```
...\Anaconda3\lib\site-packages\scipy\stats\_continuous_distns.py:1410: RuntimeWarning: overflow encountered in multiply
  return 0.5 * invK * expval * sc.erfc(-(x - invK) / np.sqrt(2))
...\Anaconda3\lib\site-packages\scipy\stats\_continuous_distns.py:1410: RuntimeWarning: invalid value encountered in multiply
  return 0.5 * invK * expval * sc.erfc(-(x - invK) / np.sqrt(2))
```

### Scipy/Numpy/Python version information:
```
import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.2.1 1.16.2 sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)
```



Discussion:
It's interesting. It does try to avoid this overflow,
https://github.com/scipy/scipy/blob/v1.2.1/scipy/stats/_continuous_distns.py#L1410

```
# Avoid overflows; setting np.exp(exparg) to the max float works
#  all right here
expval = _lazywhere(exparg < _LOGXMAX, (exparg,), np.exp, _XMAX)
return 0.5 * invK * expval * sc.erfc(-(x - invK) / np.sqrt(2))
```

*but* when `expval` equals `_XMAX`, the result of multiplying it by `invK` overflows. The resulting `inf` is multiplied by the zero value of `erfc`, which results in a nan. The simplest fix seems to be to fix the order of multiplications by bracketing the product,  `(expval * sc.erfc(-(x - invK))`. 

Would you be interested in sending a pull request, @s04lg934jkg ? This would need a test, too https://github.com/scipy/scipy/blob/v1.2.1/scipy/stats/tests/test_distributions.py#L1272


Hi, can I work on this ?
Go for it @7vikpeculiar 

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
@@ -1407,7 +1407,7 @@ def _pdf(self, x, K):
         # Avoid overflows; setting np.exp(exparg) to the max float works
         #  all right here
         expval = _lazywhere(exparg < _LOGXMAX, (exparg,), np.exp, _XMAX)
-        return 0.5 * invK * expval * sc.erfc(-(x - invK) / np.sqrt(2))
+        return 0.5 * invK * (expval * sc.erfc(-(x - invK) / np.sqrt(2)))
 
     def _logpdf(self, x, K):
         invK = 1.0 / K


Test patch:
diff --git a/scipy/stats/tests/test_distributions.py b/scipy/stats/tests/test_distributions.py
--- a/scipy/stats/tests/test_distributions.py
+++ b/scipy/stats/tests/test_distributions.py
@@ -1331,6 +1331,9 @@ def test_extremes_x(self):
         # Test for extreme values against overflows
         assert_almost_equal(stats.exponnorm.pdf(-900, 1), 0.0)
         assert_almost_equal(stats.exponnorm.pdf(+900, 1), 0.0)
+        assert_almost_equal(stats.exponnorm.pdf(1, 0.01), 0.0)
+        assert_almost_equal(stats.exponnorm.pdf(-900, 0.01), 0.0)
+        assert_almost_equal(stats.exponnorm.pdf(+900, 0.01), 0.0)
 
 
 class TestGenExpon(object):