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

Issue:
ufunc doc not in html build ? 
It seem the docstring of "ufunc" is not in the html build of the docs:

```
In [5]: from numpy import ufunc

In [6]: 'whole array' in ufunc.__doc__
Out[6]: True
```

If I grep the html build for "whole array" there is no results...

ufunc doc is set in `numpy/core/_add_newdocs.py`, like other things so there is no reason for it not to be built, it likely miss a entry in generated API ? Am I really bad at searching ? Or maybe that's on purpose.


Discussion:
> Am I really bad at searching ?

Nope, this does indeed seem to be the case.

I can't imagine why it would be left out on purpose, it's likely an oversight or perhaps an autodoc/autosummary is improperly configured somewhere. Note that all the internal links to `` :class:`ufunc` `` are indeed broken.
> Nope, this does indeed seem to be the case.

Thanks ! I don't know if it matters but it's also one of the only non-module that have both , `-`  and `=` title.
Yeah that `Calling ufuncs` section heading trips up `numpydoc` parsing. Not a huge deal but also not a no-brainer fix either.
As a workaround, can we use `-` for the `Calling ufuncs` header for now? Just so the documentation is not missing.
Using a different style heading wouldn't work I don't think, as numpydoc would still trip on any non-recognized heading name. One workaround that should work is replacing

```
Calling ufuncs
==============
```
with 
```
**Calling ufuncs**
```

Resolving patch:
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py
--- a/numpy/core/_add_newdocs.py
+++ b/numpy/core/_add_newdocs.py
@@ -4457,10 +4457,8 @@
 
     A detailed explanation of ufuncs can be found in the docs for :ref:`ufuncs`.
 
-    Calling ufuncs:
-    ===============
+    **Calling ufuncs:** ``op(*x[, out], where=True, **kwargs)``
 
-    op(*x[, out], where=True, **kwargs)
     Apply `op` to the arguments `*x` elementwise, broadcasting the arguments.
 
     The broadcasting rules are:


Test patch:
Repository: numpy/numpy

Issue:
Ambiguous documentation example for `array_split`
<!-- Please describe the issue in detail here, and fill in the fields below -->

The examples make it unclear as to whether `array_split`, with arguments `ary` and `n`, splits `ary` into

1. `n` arrays of near equal size, or
2.  a few arrays of near equal size, with the maximum array length capped at `n`.

### Reproducing code example:

<!-- A short code example that reproduces the problem/missing feature. It should be
self-contained, i.e., possible to run as-is via 'python myproblem.py' -->

The existing code examples are:
```python
import numpy as np
x = np.arange(8.0)
np.array_split(x, 3)
 #   [array([0.,  1.,  2.]), array([3.,  4.,  5.]), array([6.,  7.])]
x = np.arange(7.0)
np.array_split(x, 3)
 #   [array([0.,  1.,  2.]), array([3.,  4.]), array([5.,  6.])]
```
A better code example is 
```python
import numpy as np
c = np.arange(9)
np.array_split(c, 4)
# [array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]
```
### Link:
https://numpy.org/doc/stable/reference/generated/numpy.array_split.html



Discussion:
Good idea - a documentation PR would be appreciated.

Resolving patch:
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -756,11 +756,11 @@ def array_split(ary, indices_or_sections, axis=0):
     --------
     >>> x = np.arange(8.0)
     >>> np.array_split(x, 3)
-        [array([0.,  1.,  2.]), array([3.,  4.,  5.]), array([6.,  7.])]
+    [array([0.,  1.,  2.]), array([3.,  4.,  5.]), array([6.,  7.])]
 
-    >>> x = np.arange(7.0)
-    >>> np.array_split(x, 3)
-        [array([0.,  1.,  2.]), array([3.,  4.]), array([5.,  6.])]
+    >>> x = np.arange(9)
+    >>> np.array_split(x, 4)
+    [array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]
 
     """
     try:


Test patch:
Repository: numpy/numpy

Issue:
BUG: Typo in `numpy.polydiv`
https://github.com/numpy/numpy/blob/92ebe1e9a6aeb47a881a1226b08218175776f9ea/numpy/lib/polynomial.py#L959

The typo in this line causes wrong return types in cases when `v` is `poly1d`

fix to be: `truepoly = (isinstance(u, poly1d) or isinstance(v, poly1d))`


Discussion:

Resolving patch:
diff --git a/numpy/lib/polynomial.py b/numpy/lib/polynomial.py
--- a/numpy/lib/polynomial.py
+++ b/numpy/lib/polynomial.py
@@ -1017,7 +1017,7 @@ def polydiv(u, v):
     (array([1.5 , 1.75]), array([0.25]))
 
     """
-    truepoly = (isinstance(u, poly1d) or isinstance(u, poly1d))
+    truepoly = (isinstance(u, poly1d) or isinstance(v, poly1d))
     u = atleast_1d(u) + 0.0
     v = atleast_1d(v) + 0.0
     # w has the common type


Test patch:
diff --git a/numpy/lib/tests/test_polynomial.py b/numpy/lib/tests/test_polynomial.py
--- a/numpy/lib/tests/test_polynomial.py
+++ b/numpy/lib/tests/test_polynomial.py
@@ -243,6 +243,15 @@ def test_polydiv(self):
         assert_equal(q.coeffs.dtype, np.complex128)
         assert_equal(r.coeffs.dtype, np.complex128)
         assert_equal(q*a + r, b)
+        
+        c = [1, 2, 3]
+        d = np.poly1d([1, 2, 3])
+        s, t = np.polydiv(c, d)
+        assert isinstance(s, np.poly1d)
+        assert isinstance(t, np.poly1d)
+        u, v = np.polydiv(d, c)
+        assert isinstance(u, np.poly1d)
+        assert isinstance(v, np.poly1d)
 
     def test_poly_coeffs_mutable(self):
         """ Coefficients should be modifiable """
Repository: numpy/numpy

Issue:
Remove `array_{repr,str}_builtin` functions from strfuncs.c
Those two functions depend on the `dump_data` function, which looks buggy to me, and they are never used in practice as they  are overloaded when `arrayprint` is loaded. And `arrayprint` itself is loaded when `numeric` is loaded, which takes place when `numpy` is loaded. That all looks fishy as heck. I propose that the default ndarray `str` and `repr` functions be set to the `arrayprint` implementations.

The `dump_data` function could probably be fixed but I don't think it is worth the effort. The current setup dates back to the time when numpy enhancements came in separate modules and all the strings were ascii.




Discussion:
Note that the trouble began with Python 3 and the change to unicode strings.

Resolving patch:
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -1628,6 +1628,3 @@ def set_string_function(f, repr=True):
             return multiarray.set_string_function(_default_array_str, 0)
     else:
         return multiarray.set_string_function(f, repr)
-
-set_string_function(_default_array_str, False)
-set_string_function(_default_array_repr, True)


Test patch:
Repository: numpy/numpy

Issue:
SIMD: The --cpu-baseline is not correctly configured in benchmark system.
I'm trying to use the newest benchmark system to test the performance, but found out that the option is not working. here is the command that used for benchmarking.
```
python runtests.py --cpu-baseline="avx2" --bench-compare master bench_linalg.Einsum.time_einsum_multiply
```
in this case, the macro `NPY_SIMD `should be 256 because my machine support `avx2 `intrinsics, but the actual value is 128, which is the default minimal settings.


Discussion:

Resolving patch:
diff --git a/benchmarks/asv_pip_nopep517.py b/benchmarks/asv_pip_nopep517.py
new file mode 100644
--- /dev/null
+++ b/benchmarks/asv_pip_nopep517.py
@@ -0,0 +1,15 @@
+"""
+This file is used by asv_compare.conf.json.tpl.
+"""
+import subprocess, sys
+# pip ignores '--global-option' when pep517 is enabled therefore we disable it.
+cmd = [sys.executable, '-mpip', 'wheel', '--no-use-pep517']
+try:
+    output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, universal_newlines=True)
+except Exception as e:
+    output = str(e.output)
+if "no such option" in output:
+    print("old version of pip, escape '--no-use-pep517'")
+    cmd.pop()
+
+subprocess.run(cmd + sys.argv[1:])
diff --git a/runtests.py b/runtests.py
--- a/runtests.py
+++ b/runtests.py
@@ -524,6 +524,7 @@ def asv_compare_config(bench_path, args, h_commits):
 
     is_cached = asv_substitute_config(conf_path, nconf_path,
         numpy_build_options = ' '.join([f'\\"{v}\\"' for v in build]),
+        numpy_global_options= ' '.join([f'--global-option=\\"{v}\\"' for v in ["build"] + build])
     )
     if not is_cached:
         asv_clear_cache(bench_path, h_commits)


Test patch:
Repository: numpy/numpy

Issue:
bad example for `np.linalg.solve`
with all respect, I think the example given in https://github.com/numpy/numpy/blob/92ebe1e9a6aeb47a881a1226b08218175776f9ea/numpy/linalg/linalg.py#L365

is the particularly unsuitable one. Since the coefficient matrix here is symmetric, novice user cannot immediately understand from this example, whether coefficient matrix should be given in row-first order or column-first order.


Discussion:
That's a good point - would you like to make a PR to improve it?
sure. give me a minute

Resolving patch:
diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py
--- a/numpy/linalg/linalg.py
+++ b/numpy/linalg/linalg.py
@@ -361,13 +361,13 @@ def solve(a, b):
 
     Examples
     --------
-    Solve the system of equations ``3 * x0 + x1 = 9`` and ``x0 + 2 * x1 = 8``:
+    Solve the system of equations ``x0 + 2 * x1 = 1`` and ``3 * x0 + 5 * x1 = 2``:
 
-    >>> a = np.array([[3,1], [1,2]])
-    >>> b = np.array([9,8])
+    >>> a = np.array([[1, 2], [3, 5]])
+    >>> b = np.array([1, 2])
     >>> x = np.linalg.solve(a, b)
     >>> x
-    array([2.,  3.])
+    array([-1.,  1.])
 
     Check that the solution is correct:
 


Test patch:
Repository: scrapy/scrapy

Issue:
Timeouts on S3ImageStore due to seek() being run on different threads
I'm on OS X 10.7.3 with python 2.7.2+, boto 2.2.2, and scrapy 0.14.1

When I try to store an image on s3 with the images pipeline I get this S3 Response Error:

`"Your socket connection to the server was not read from or written to within the timeout period. Idle connections will be closed."`

Often, the first couple stores will create keys in the bucket, but most of the files have 0 bytes, or if they are not empty, they are garbled and not in a jpg format. 

I found that if I changed line 124 of the images pipeline to not use twisted threads, it works fine.
From:
`return threads.deferToThread(k.set_contents_from_file, buf, \
                headers=self.HEADERS, policy=self.POLICY)`

To: 
`k.set_contents_from_file( buf, headers=self.HEADERS, policy=self.POLICY)`

I talked to @dangra in irc and he suggested I comment out lines 258 and 257 with the reasoning that "I  am afraid that seek(0) runs in main thread while persist_image does the same in another thread"
https://github.com/scrapy/scrapy/blob/0.14.1/scrapy/contrib/pipeline/images.py#L257



Discussion:

Resolving patch:
diff --git a/scrapy/contrib/pipeline/images.py b/scrapy/contrib/pipeline/images.py
--- a/scrapy/contrib/pipeline/images.py
+++ b/scrapy/contrib/pipeline/images.py
@@ -249,13 +249,12 @@ def _onsuccess(result):
         return dfd
 
     def image_downloaded(self, response, request, info):
-        first_buf = None
+        checksum = None
         for key, image, buf in self.get_images(response, request, info):
+            if checksum is None:
+                checksum = md5sum(buf)
             self.store.persist_image(key, image, buf, info)
-            if first_buf is None:
-                first_buf = buf
-        first_buf.seek(0)
-        return md5sum(first_buf)
+        return checksum
 
     def get_images(self, response, request, info):
         key = self.image_key(request.url)


Test patch:
Repository: scrapy/scrapy

Issue:
Set the 'nofollow' attribute in Link objects
I previously reported this on Trac: http://dev.scrapy.org/ticket/310

The Link object now has a 'nofollow' attribute. This needs support in the link extractors



Discussion:

Resolving patch:
diff --git a/scrapy/contrib/linkextractors/sgml.py b/scrapy/contrib/linkextractors/sgml.py
--- a/scrapy/contrib/linkextractors/sgml.py
+++ b/scrapy/contrib/linkextractors/sgml.py
@@ -71,7 +71,7 @@ def unknown_starttag(self, tag, attrs):
                 if self.scan_attr(attr):
                     url = self.process_value(value)
                     if url is not None:
-                        link = Link(url=url)
+                        link = Link(url=url, nofollow=True if dict(attrs).get('rel') == 'nofollow' else False)
                         self.links.append(link)
                         self.current_link = link
 


Test patch:
diff --git a/scrapy/tests/test_contrib_linkextractors.py b/scrapy/tests/test_contrib_linkextractors.py
--- a/scrapy/tests/test_contrib_linkextractors.py
+++ b/scrapy/tests/test_contrib_linkextractors.py
@@ -85,6 +85,17 @@ def test_matches(self):
         self.assertEqual(lx.matches(url1), True)
         self.assertEqual(lx.matches(url2), True)
 
+    def test_link_nofollow(self):
+        html = """
+        <a href="page.html?action=print" rel="nofollow">Printer-friendly page</a>
+        <a href="about.html">About us</a>
+        """
+        response = HtmlResponse("http://example.org/page.html", body=html)
+        lx = SgmlLinkExtractor()
+        self.assertEqual([link for link in lx.extract_links(response)],
+            [ Link(url='http://example.org/page.html?action=print', text=u'Printer-friendly page', nofollow=True),
+              Link(url='http://example.org/about.html', text=u'About us', nofollow=False) ])
+
 class SgmlLinkExtractorTestCase(unittest.TestCase):
     def setUp(self):
         body = get_testdata('link_extractor', 'sgml_linkextractor.html')
Repository: scrapy/scrapy

Issue:
Deprecated class inheritance check bug
``` python
>>> from scrapy.spider import BaseSpider
>>> class A(BaseSpider):
...     pass
... 
>>> class B(BaseSpider):
...     pass
... 
>>> isinstance(A('foo'), B)
True
```



Discussion:

Resolving patch:
diff --git a/scrapy/utils/deprecate.py b/scrapy/utils/deprecate.py
--- a/scrapy/utils/deprecate.py
+++ b/scrapy/utils/deprecate.py
@@ -79,12 +79,18 @@ def __instancecheck__(cls, inst):
                        for c in {type(inst), inst.__class__})
 
         def __subclasscheck__(cls, sub):
+            if cls is not DeprecatedClass.deprecated_class:
+                # we should do the magic only if second `issubclass` argument
+                # is the deprecated class itself - subclasses of the
+                # deprecated class should not use custom `__subclasscheck__`
+                # method.
+                return super(DeprecatedClass, cls).__subclasscheck__(sub)
+
             if not inspect.isclass(sub):
                 raise TypeError("issubclass() arg 1 must be a class")
 
             mro = getattr(sub, '__mro__', ())
-            candidates = {cls, new_class}
-            return any(c in candidates for c in mro)
+            return any(c in {cls, new_class} for c in mro)
 
         def __call__(cls, *args, **kwargs):
             old = DeprecatedClass.deprecated_class


Test patch:
diff --git a/scrapy/tests/test_utils_deprecate.py b/scrapy/tests/test_utils_deprecate.py
--- a/scrapy/tests/test_utils_deprecate.py
+++ b/scrapy/tests/test_utils_deprecate.py
@@ -145,6 +145,9 @@ class UpdatedUserClass1a(NewName):
             class OutdatedUserClass1(DeprecatedName):
                 pass
 
+            class OutdatedUserClass1a(DeprecatedName):
+                pass
+
             class UnrelatedClass(object):
                 pass
 
@@ -159,6 +162,8 @@ class OldStyleClass:
         assert not issubclass(UnrelatedClass, DeprecatedName)
         assert not issubclass(OldStyleClass, DeprecatedName)
         assert not issubclass(OldStyleClass, DeprecatedName)
+        assert not issubclass(OutdatedUserClass1, OutdatedUserClass1a)
+        assert not issubclass(OutdatedUserClass1a, OutdatedUserClass1)
 
         self.assertRaises(TypeError, issubclass, object(), DeprecatedName)
 
@@ -175,6 +180,9 @@ class UpdatedUserClass2a(NewName):
             class OutdatedUserClass2(DeprecatedName):
                 pass
 
+            class OutdatedUserClass2a(DeprecatedName):
+                pass
+
             class UnrelatedClass(object):
                 pass
 
@@ -186,6 +194,9 @@ class OldStyleClass:
         assert isinstance(UpdatedUserClass2(), DeprecatedName)
         assert isinstance(UpdatedUserClass2a(), DeprecatedName)
         assert isinstance(OutdatedUserClass2(), DeprecatedName)
+        assert isinstance(OutdatedUserClass2a(), DeprecatedName)
+        assert not isinstance(OutdatedUserClass2a(), OutdatedUserClass2)
+        assert not isinstance(OutdatedUserClass2(), OutdatedUserClass2a)
         assert not isinstance(UnrelatedClass(), DeprecatedName)
         assert not isinstance(OldStyleClass(), DeprecatedName)
Repository: scrapy/scrapy

Issue:
Sort spider names on 'scrapy list' command
Hey there, 

i think the spider names on the `scrapy list` command should be order by name in the console output. 



Discussion:

Resolving patch:
diff --git a/scrapy/commands/list.py b/scrapy/commands/list.py
--- a/scrapy/commands/list.py
+++ b/scrapy/commands/list.py
@@ -11,5 +11,5 @@ def short_desc(self):
 
     def run(self, args, opts):
         crawler = self.crawler_process.create_crawler()
-        for s in crawler.spiders.list():
+        for s in sorted(crawler.spiders.list()):
             print(s)


Test patch:
Repository: scrapy/scrapy

Issue:
Enabled extensions, middlewares, pipelines
I found that this information isn't being printed anymore.

The responsible of this bug is [this line](https://github.com/scrapy/scrapy/pull/816/files#diff-fee03a44ad4de98d9361d89947c8aba3R83), seems that `spider` is `None` on `eventDict` at the moment the components are instantiated.

I'm not sure how to fix it because I 'm not quite sure what it is attempting to block.

/cc @curita



Discussion:

Resolving patch:
diff --git a/scrapy/commands/shell.py b/scrapy/commands/shell.py
--- a/scrapy/commands/shell.py
+++ b/scrapy/commands/shell.py
@@ -58,14 +58,13 @@ def run(self, args, opts):
         crawler.engine = crawler._create_engine()
         crawler.engine.start()
 
-        self.crawler_process.start(start_reactor=False)
         self._start_crawler_thread()
 
         shell = Shell(crawler, update_vars=self.update_vars, code=opts.code)
         shell.start(url=url)
 
     def _start_crawler_thread(self):
-        t = Thread(target=self.crawler_process._start_reactor,
+        t = Thread(target=self.crawler_process.start,
                    kwargs={'stop_after_crawl': False})
         t.daemon = True
         t.start()
diff --git a/scrapy/crawler.py b/scrapy/crawler.py
--- a/scrapy/crawler.py
+++ b/scrapy/crawler.py
@@ -115,6 +115,8 @@ def __init__(self, settings):
         super(CrawlerProcess, self).__init__(settings)
         install_shutdown_handlers(self._signal_shutdown)
         self.stopping = False
+        self.log_observer = log.start_from_settings(self.settings)
+        log.scrapy_info(settings)
 
     def _signal_shutdown(self, signum, _):
         install_shutdown_handlers(self._signal_kill)
@@ -131,13 +133,7 @@ def _signal_kill(self, signum, _):
         self._stop_logging()
         reactor.callFromThread(self._stop_reactor)
 
-    def start(self, stop_after_crawl=True, start_reactor=True):
-        self.log_observer = log.start_from_settings(self.settings)
-        log.scrapy_info(self.settings)
-        if start_reactor:
-            self._start_reactor(stop_after_crawl)
-
-    def _start_reactor(self, stop_after_crawl=True):
+    def start(self, stop_after_crawl=True):
         if stop_after_crawl:
             d = defer.DeferredList(self.crawl_deferreds)
             if d.called:


Test patch:
Repository: scrapy/scrapy

Issue:
Unhandled error in Deferred (RobotsTxtMiddleware)
**Dev story**:
Let's say spider downloads all .zip files from http://habrahabr.ru/post/212029/ page
Url with .zip files looks like this: http://layer6.jenkins.tox.im/job/qt_gui_win32/lastSuccessfulBuild/artifact/qt/build/release/TOX-Qt-GUI.zip

It's a polite spider, so settings file contains:
`ROBOTSTXT_OBEY = True`

Middleware parses habrahabr.ru robots.txt file as well as 'external' robots.txt file from layer6.jenkins.tox.im. It's expected behaviour. 
But if request will be returned with error then the output would be:

```
2015-04-02 17:06:16+0300 [habrahabr] DEBUG: Gave up retrying <GET http://layer6.jenkins.tox.im/robots.txt> (failed 1 times): DNS lookup failed: address 'layer6.jenkins.tox.im' not found: [Errno 8] nodename nor servname provided, or not known.

2015-04-02 17:06:16+0300 [-] ERROR: Unhandled error in Deferred:
2015-04-02 17:06:16+0300 [-] Unhandled Error
    Traceback (most recent call last):
    Failure: twisted.internet.error.DNSLookupError: DNS lookup failed: address 'layer6.jenkins.tox.im' not found: [Errno 8] nodename nor servname provided, or not known.
```



Discussion:

Resolving patch:
diff --git a/scrapy/contrib/downloadermiddleware/robotstxt.py b/scrapy/contrib/downloadermiddleware/robotstxt.py
--- a/scrapy/contrib/downloadermiddleware/robotstxt.py
+++ b/scrapy/contrib/downloadermiddleware/robotstxt.py
@@ -49,8 +49,14 @@ def robot_parser(self, request, spider):
             )
             dfd = self.crawler.engine.download(robotsreq, spider)
             dfd.addCallback(self._parse_robots)
+            dfd.addErrback(self._logerror, robotsreq, spider)
         return self._parsers[netloc]
 
+    def _logerror(self, failure, request, spider):
+        if failure.type is not IgnoreRequest:
+            log.msg(format="Error downloading %%(request)s: %s" % failure.value,
+                    level=log.ERROR, request=request, spider=spider)
+
     def _parse_robots(self, response):
         rp = robotparser.RobotFileParser(response.url)
         rp.parse(response.body.splitlines())


Test patch: