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

Issue:
DOC: scipy.optimize.root_scalar
This bit:

> f is assumed to return the value of derivative along with the objective function.

specifies the wrong order (which has to be (f,df)).  It should say:

> f is assumed to return the value the objective function along with the derivative.


Discussion:

Resolving patch:
diff --git a/scipy/optimize/_root_scalar.py b/scipy/optimize/_root_scalar.py
--- a/scipy/optimize/_root_scalar.py
+++ b/scipy/optimize/_root_scalar.py
@@ -93,13 +93,14 @@ def root_scalar(f, args=(), method=None, bracket=None,
         A second guess.
     fprime : bool or callable, optional
         If `fprime` is a boolean and is True, `f` is assumed to return the
-        value of derivative along with the objective function.
+        value of the objective function and of the derivative.
         `fprime` can also be a callable returning the derivative of `f`. In
         this case, it must accept the same arguments as `f`.
     fprime2 : bool or callable, optional
         If `fprime2` is a boolean and is True, `f` is assumed to return the
-        value of 1st and 2nd derivatives along with the objective function.
-        `fprime2` can also be a callable returning the 2nd derivative of `f`.
+        value of the objective function and of the
+        first and second derivatives.
+        `fprime2` can also be a callable returning the second derivative of `f`.
         In this case, it must accept the same arguments as `f`.
     xtol : float, optional
         Tolerance (absolute) for termination.


Test patch:
Repository: scipy/scipy

Issue:
DOC: scipy.interpolate.splev
> der : int, optional
>   The order of derivative of the spline to compute (must be less than or equal to k).

It is not said what "k" is.


Discussion:

Resolving patch:
diff --git a/scipy/interpolate/fitpack.py b/scipy/interpolate/fitpack.py
--- a/scipy/interpolate/fitpack.py
+++ b/scipy/interpolate/fitpack.py
@@ -310,7 +310,7 @@ def splev(x, tck, der=0, ext=0):
         of the spline. (Also see Notes.)
     der : int, optional
         The order of derivative of the spline to compute (must be less than
-        or equal to k).
+        or equal to k, the degree of the spline).
     ext : int, optional
         Controls the value returned for elements of ``x`` not in the
         interval defined by the knot sequence.


Test patch:
Repository: scipy/scipy

Issue:
SciPy 1.3.0rc2 Release Note Edits
@tylerjereddy suggested opening an issue for release note edits.

For addition to "Backwards incompatible changes":

`scipy.optimize` changes
- ----------------------

The default method for `linprog` is now `'interior-point'`. The method's robustness and speed come at cost: solutions may not be accurate to machine precision or correspond with a vertex of the polytope defined by the constraints. To revert to the original simplex method, include the argument `method='simplex'`.


Discussion:
Thanks Matt -- a pure release note edit should be safe to do when I'm preparing `1.3.0` "final" in the coming days.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -56,8 +56,8 @@
 MAJOR = 1
 MINOR = 3
 MICRO = 0
-ISRELEASED = True
-VERSION = '%d.%d.%drc2' % (MAJOR, MINOR, MICRO)
+ISRELEASED = False
+VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
 
 
 # Return the git revision as a string


Test patch:
diff --git a/scipy/stats/tests/test_stats.py b/scipy/stats/tests/test_stats.py
--- a/scipy/stats/tests/test_stats.py
+++ b/scipy/stats/tests/test_stats.py
@@ -369,7 +369,7 @@ def test_more_basic_examples(self):
 
         # The expected r and p are exact.
         assert_allclose(r, -1.0)
-        assert_allclose(p, 0.0)
+        assert_allclose(p, 0.0, atol=1e-7)
 
     def test_unequal_lengths(self):
         x = [1, 2, 3]
Repository: scipy/scipy

Issue:
MAINT: gpg versions, signing, and release docs/ steps
On some popular platforms, you basically [need to use GPG2](https://askubuntu.com/a/875179) if you want to use `gpg-agent` to avoid entering your signing credentials over and over when handling various assets during the SciPy release process.

In practice, this meant a few things for me, that maybe should be documented in release process description, but code changes would be harder since `gpg2` is still `gpg` on some platforms.

We could perhaps mention that the following might be needed for platforms with `gpg2` requirements:
- `git config --global gpg.program gpg2` for `git tag -s` commands
- `twine upload -s --sign-with gpg2` to avoid calling old `gpg` & requiring password each time

It is still harder than that to have everything "just work" portably on any given release managers platform with no manual intervention though. Locally, I also needed:

```diff
diff --git a/pavement.py b/pavement.py
index e439db680..6caa734ff 100644
--- a/pavement.py
+++ b/pavement.py
@@ -685,7 +685,7 @@ SHA256
         ftarget.writelines(['%s\n' % c for c in compute_sha256(idirs)])

     # Sign release
-    cmd = ['gpg', '--clearsign', '--armor']
+    cmd = ['gpg2', '--clearsign', '--armor']
     if hasattr(options, 'gpg_key'):
         cmd += ['--default-key', options.gpg_key]
     cmd += ['--output', str(target), str(tmp_target)]
```

But that may break things for platforms & distributions where `gpg` is actually `gpg2` instead of the old version.

I didn't have much success aliasing the old name to the new command / executable & having gpg-agent use it, but others may have better success with that.


Discussion:
feel free to make that change in `pavement.py` I think, with a comment that says "if this doesn't work for you, change to `gpg`". 

Resolving patch:
diff --git a/pavement.py b/pavement.py
--- a/pavement.py
+++ b/pavement.py
@@ -684,8 +684,9 @@ def write_release_task(options, filename='NOTES.txt'):
 """)
         ftarget.writelines(['%s\n' % c for c in compute_sha256(idirs)])
 
-    # Sign release
-    cmd = ['gpg', '--clearsign', '--armor']
+    # Sign release; on some platforms gpg2 may actually
+    # be named gpg
+    cmd = ['gpg2', '--clearsign', '--armor']
     if hasattr(options, 'gpg_key'):
         cmd += ['--default-key', options.gpg_key]
     cmd += ['--output', str(target), str(tmp_target)]


Test patch:
Repository: scipy/scipy

Issue:
Typo in scipy.stats.t documentation
It looks like the t distribution documentation  at https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.t.html#scipy.stats.t has a typo in the formula for the probability density function. The normalization constant should have 
Gamma(nu/2) in the denominator, not Gamma(nu) , as currently displayed.


Discussion:
Yup, a typo. Care to submit a PR with the fix?
Sorry, I am not a developer and am particularly unfamiliar with GitHub - I wouldn't know what to do :-)

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
@@ -5244,7 +5244,7 @@ class t_gen(rv_continuous):
     .. math::
 
         f(x, \nu) = \frac{\Gamma((\nu+1)/2)}
-                        {\sqrt{\pi \nu} \Gamma(\nu)}
+                        {\sqrt{\pi \nu} \Gamma(\nu/2)}
                     (1+x^2/\nu)^{-(\nu+1)/2}
 
     where :math:`x` is a real number and the degrees of freedom parameter


Test patch:
Repository: scipy/scipy

Issue:
Typo in scipy.stats.nct documentation
Keen to be corrected on this, but I think there's a typo in the documentation at https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.nct.html

The sentence after the first equation reads

 _"(denoted nct in the implementation)"_

But should, I believe,  read:

_"(denoted **nc** in the implementation)"_ 



Discussion:
Definitely a typo, PR welcome

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
@@ -5325,7 +5325,7 @@ class nct_gen(rv_continuous):
     has a non-central Student's t distribution on the real line.
     The degrees of freedom parameter :math:`k` (denoted ``df`` in the
     implementation) satisfies :math:`k > 0` and the noncentrality parameter
-    :math:`c` (denoted ``nct`` in the implementation) is a real number.
+    :math:`c` (denoted ``nc`` in the implementation) is a real number.
 
     %(after_notes)s
 


Test patch:
Repository: scipy/scipy

Issue:
DOC: Add pybind11 requirment to HACKING.rst.txt
The addition of the scipy.fft module (#10238) adds pybind11 as an additional
build time dependency. This has already been documented in
INSTALL.rst.txt (#10348) but not in HACKING.rst.txt. This commit adds
pybind11 to the required dependencies.


Discussion:

Resolving patch:
diff --git a/doc/source/conf.py b/doc/source/conf.py
--- a/doc/source/conf.py
+++ b/doc/source/conf.py
@@ -104,19 +104,10 @@
 # The name of the Pygments (syntax highlighting) style to use.
 pygments_style = 'sphinx'
 
-# Enusre all our internal links work
+# Ensure all our internal links work
 nitpicky = True
 exclude_patterns = [  # glob-style
-    # these are all included directly in dev/index.rst:
-    'dev/decisions.rst',
-    'dev/deprecations.rst',
-    'dev/distributing.rst',
-    'dev/github.rst',
-    'dev/licensing.rst',
-    'dev/modules.rst',
-    'dev/newfeatures.rst',
-    'dev/releasing.rst',
-    'dev/versioning.rst',
+
 ]
 
 # be strict about warnings in our examples, we should write clean code
@@ -325,6 +316,7 @@
     'python': ('https://docs.python.org/dev', None),
     'numpy': ('https://docs.scipy.org/doc/numpy', None),
     'matplotlib': ('https://matplotlib.org', None),
+    'asv': ('https://asv.readthedocs.io/en/stable/', None),
 }
 
 


Test patch:
Repository: scipy/scipy

Issue:
Documentation error for K-sample Anderson test
<!-- 
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.
-->

The[ documentation for the k sample Anderson test](https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.anderson_ksamp.html) has incorrect values for the significance levels associated with the returned critical values.

Currently the documentaion shows:
`    critical_values : array
        The critical values for significance levels 25%, 10%, 5%, 2.5%, 1%.`

Where as the the code in morestats.py on line 2039 shows:
`sig = np.array([0.25, 0.1, 0.05, 0.025, 0.01, 0.005, 0.001])`

There is also an issue with the signifance_level as the value is not floored at 1%, but at 0.1% as outlined in the notes.

I am using scipy version 1.2. However these errors are present in the version 1.3 docs as well.



Discussion:
Yes, that is an error in the documentation.

Resolving patch:
diff --git a/scipy/stats/morestats.py b/scipy/stats/morestats.py
--- a/scipy/stats/morestats.py
+++ b/scipy/stats/morestats.py
@@ -1919,11 +1919,12 @@ def anderson_ksamp(samples, midrank=True):
     statistic : float
         Normalized k-sample Anderson-Darling test statistic.
     critical_values : array
-        The critical values for significance levels 25%, 10%, 5%, 2.5%, 1%.
+        The critical values for significance levels 25%, 10%, 5%, 2.5%, 1%,
+        0.5%, 0.1%.
     significance_level : float
         An approximate significance level at which the null hypothesis for the
         provided samples can be rejected. The value is floored / capped at
-        1% / 25%.
+        0.1% / 25%.
 
     Raises
     ------


Test patch:
Repository: scipy/scipy

Issue:
distance matrix lacks dtype checks / warnings
scipy.spatial.distance_matrix issues no warning of possible overflows when using unusual dtypes (e.g. uint16, etc.). It calculates the distances, but the results are affected by the overflows, and therefore are incorrect. Also, the results affected by overflow are returned in float64 dtype (instead of original dtype), what makes it harder to figure out what happened.

I'm not sure if the warning is worth adding, but I came across this behaviour today in a project that uses openCV, where uint type numpy arrays are often used.

### Reproducing code example:

```
from scipy.spatial import distance_matrix
import numpy as np

points_1 = np.array([[352, 916]])
points_2 = np.array([[350,660]])

print(distance_matrix(points_1, points_2)) # [[256.00781238]] (OK)

points_1 = points_1.astype('uint16')
points_2 = points_2.astype('uint16')

print(distance_matrix(points_1, points_2)) # [[2.]] (not OK)
print(distance_matrix(points_1, points_2).dtype) # float64 (confusing)

```

### Scipy/Numpy/Python version information:
```
import sys, scipy, numpy; print(scipy.__version__, numpy.__version__, sys.version_info)
1.3.0 1.16.4 sys.version_info(major=3, minor=6, micro=7, releaselevel='final', serial=0)
```




Discussion:

Resolving patch:
diff --git a/scipy/spatial/kdtree.py b/scipy/spatial/kdtree.py
--- a/scipy/spatial/kdtree.py
+++ b/scipy/spatial/kdtree.py
@@ -38,6 +38,15 @@ def minkowski_distance_p(x, y, p=2):
     """
     x = np.asarray(x)
     y = np.asarray(y)
+
+    # Find smallest common datatype with float64 (return type of this function) - addresses #10262.
+    # Don't just cast to float64 for complex input case.
+    common_datatype = np.promote_types(np.promote_types(x.dtype, y.dtype), 'float64')
+
+    # Make sure x and y are numpy arrays of correct datatype.
+    x = x.astype(common_datatype)
+    y = y.astype(common_datatype)
+
     if p == np.inf:
         return np.amax(np.abs(y-x), axis=-1)
     elif p == 1:


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
@@ -1525,6 +1525,12 @@ def test_minkowski(self):
                 assert_almost_equal(dist1p5, (1.0 + 2.0**1.5)**(2. / 3))
                 dist2 = wminkowski(x, y, p=2)
 
+            # Check that casting input to minimum scalar type doesn't affect result (issue #10262).
+            # This could be extended to more test inputs with np.min_scalar_type(np.max(input_matrix)).
+            a = np.array([352, 916])
+            b = np.array([350, 660])
+            assert_equal(minkowski(a, b), minkowski(a.astype('uint16'), b.astype('uint16')))
+
     def test_old_wminkowski(self):
         with suppress_warnings() as wrn:
             wrn.filter(message="`wminkowski` is deprecated")
Repository: scipy/scipy

Issue:
griddata docstring doesn't make any sense
The docstring for `griddata` refers to many different integers:

`D`, `n`, `ndim`, `M`:

```
Interpolate unstructured D-dimensional data.

Parameters
----------
points : ndarray of floats, shape (n, D)
    Data point coordinates. Can either be an array of
    shape (n, D), or a tuple of `ndim` arrays.
values : ndarray of float or complex, shape (n,)
    Data values.
xi : ndarray of float, shape (M, D)
    Points at which to interpolate data.
```

The only one that is defined is `D`, so users have no idea what the others are.

Furthermore the example provided contradicts the docstring as xi is passed as a tuple but the docstring says it must be a ndarray.



Discussion:
The integers are defined by the shapes of the input arrays.

The `xi` description needs to be extended though, looks like it can be both 2-D ndarray or tuple of 1-D arrays.

I wish to work on this . Will be sending the PR.

Some clarification probably still needed.
@pv can you explain more?

Resolving patch:
diff --git a/scipy/interpolate/ndgriddata.py b/scipy/interpolate/ndgriddata.py
--- a/scipy/interpolate/ndgriddata.py
+++ b/scipy/interpolate/ndgriddata.py
@@ -92,12 +92,11 @@ def griddata(points, values, xi, method='linear', fill_value=np.nan,
 
     Parameters
     ----------
-    points : ndarray of floats, shape (n, D)
-        Data point coordinates. Can either be an array of
-        shape (n, D), or a tuple of `ndim` arrays.
+    points : 2-D ndarray of floats with shape (n, D), or length D tuple of 1-D ndarrays with shape (n,).
+        Data point coordinates. 
     values : ndarray of float or complex, shape (n,)
         Data values.
-    xi : 2-D ndarray of float or tuple of 1-D array, shape (M, D)
+    xi : 2-D ndarray of floats with shape (m, D), or length D tuple of ndarrays broadcastable to the same shape.
         Points at which to interpolate data.
     method : {'linear', 'nearest', 'cubic'}, optional
         Method of interpolation. One of


Test patch:
Repository: scipy/scipy

Issue:
BUG: interpolate.NearestNDInterpolator with pandas
interpolate.NearestNDInterpolator does not work as expected when used  with selected pandas dataframe.
This is due to the index being maintained when making selections in pandas.

### Reproducing code example:
```
import numpy as np
import pandas as pd
from scipy import interpolate

df = pd.DataFrame(np.array([[0, 0, 0, 0, 1, 0, 1],
                            [0, 0, 0, 0, 0, 1, 1],
                            [0, 0, 0, 0, 1, 1, 2]]).T, columns=['x', 'y', 'z'])
df_select = df[3:]
NI = interpolate.NearestNDInterpolator((df_select.x, df_select.y), df_select.z)
print(NI([0.1, 0.9], [0.1, 0.9]))
```
I expect [0, 2] to be output.
But output is [Nan, 0] as pandas.Series.

This is due to the index being maintained when making selections in pandas.
Specifically, `df_select.z` has index[3, 4, 5, 6].
But, self.tree.query (xi) line 81, in scipy/interpolate/ndgriddata.py returns a index that assumes that the index starts from zero.
So, self.tree.query (xi) return [0, 3]
Therefore, self.values[i] line 82, in scipy/interpolate/ndgriddata.py using Invalid index.

### Note
if case of
```
df_select = df[3:].reset_index()
```
or
```
NI = interpolate.NearestNDInterpolator((df_select.x, df_select.y), np.array(df_select.z))
```
it works as expected.

Also, this bug does not occur in interpolate.LinearNDInterpolator.

### Scipy/Numpy/Python version information:
```
1.3.0 1.16.4 sys.version_info(major=3, minor=6, micro=8, releaselevel='final', serial=0)
```



Discussion:

Resolving patch:
diff --git a/scipy/interpolate/ndgriddata.py b/scipy/interpolate/ndgriddata.py
--- a/scipy/interpolate/ndgriddata.py
+++ b/scipy/interpolate/ndgriddata.py
@@ -62,7 +62,7 @@ def __init__(self, x, y, rescale=False, tree_options=None):
         if tree_options is None:
             tree_options = dict()
         self.tree = cKDTree(self.points, **tree_options)
-        self.values = y
+        self.values = np.asarray(y)
 
     def __call__(self, *args):
         """


Test patch:
diff --git a/scipy/interpolate/tests/test_ndgriddata.py b/scipy/interpolate/tests/test_ndgriddata.py
--- a/scipy/interpolate/tests/test_ndgriddata.py
+++ b/scipy/interpolate/tests/test_ndgriddata.py
@@ -175,3 +175,17 @@ def test_nearest_options():
     nndi_o = NearestNDInterpolator(x, y, tree_options=opts)
     assert_allclose(nndi(x), nndi_o(x), atol=1e-14)
 
+
+def test_nearest_list_argument():
+    nd = np.array([[0, 0, 0, 0, 1, 0, 1],
+                   [0, 0, 0, 0, 0, 1, 1],
+                   [0, 0, 0, 0, 1, 1, 2]])
+    d = nd[:, 3:]
+
+    # z is np.array
+    NI = NearestNDInterpolator((d[0], d[1]), d[2])
+    assert_array_equal(NI([0.1, 0.9], [0.1, 0.9]), [0, 2])
+
+    # z is list
+    NI = NearestNDInterpolator((d[0], d[1]), list(d[2]))
+    assert_array_equal(NI([0.1, 0.9], [0.1, 0.9]), [0, 2])
Repository: scipy/scipy

Issue:
TST: Travis CI fails (with pytest 5.0 ?)
Example logs: https://travis-ci.org/scipy/scipy/jobs/552251037

Perhaps this is because of the recent pytest release.

Potentially relevant snippet of error output:

```
E   _pytest.config.ConftestImportFailure: (local('/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/scipy/conftest.py'), (<class 'DeprecationWarning'>, DeprecationWarning("the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses",), <traceback object at 0x7f335c515748>))
```

Probably less relevant, but perhaps useful to fix while we're at it:
```
/home/travis/virtualenv/python3.6.3/lib/python3.6/site-packages/_pytest/config/__init__.py:297: PytestConfigWarning: pytest-faulthandler plugin has been merged into the core, please remove it from your requirements.
  name.replace("_", "-")

```

I tried to reproduce locally on my Mac without much success and indeed some other CI services do also seem to pass when picking up pytest 5.0. Maybe there's a warning flag or env variable I'm missing to trigger it. It looks like an older pytest gets installed & then removed in the full log, but the runner seems to properly use pytest 5.0, so not sure that's an issue.



Discussion:
Sebastian fixed those problems for NumPy: https://github.com/numpy/numpy/pull/13864
I suppose we could try adding the warning filter before `import imp` in our source, but I'm not sure we have a good reason to continue using that over `importlib` on master branch at this point.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -108,9 +108,9 @@ def get_version_info():
     elif os.path.exists('scipy/version.py'):
         # must be a source distribution, use existing version file
         # load it as a separate module to not load scipy/__init__.py
-        import imp
-        version = imp.load_source('scipy.version', 'scipy/version.py')
-        GIT_REVISION = version.git_revision
+        import runpy
+        ns = runpy.run_path('scipy/version.py')
+        GIT_REVISION = ns['git_revision']
     else:
         GIT_REVISION = "Unknown"
 


Test patch: