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

Issue:
unexpected 'str' during Arrow test
testing on Windows Python 3.4.4/Qt5.5.1/ PyQtgraph github of 20160102, I have thefollowing  error on "Arrow" test:

```
Using PyQt5 (default graphics system)
Using PyQt5 (default graphics system)
Using PyQt5 (default graphics system)
Using PyQt5 (default graphics system)
Traceback (most recent call last):
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\examples\Arrow.py", line 50, in <module>
    anim = a.makeAnimation(loop=-1)
  File "D:\WinPython\basedir34\buildQt5\winpython-3.4.4.amd64\python-3.4.4.amd64
\lib\site-packages\pyqtgraph\graphicsItems\CurvePoint.py", line 94, in makeAnima
tion
    anim = QtCore.QPropertyAnimation(self, prop)
TypeError: arguments did not match any overloaded call:
  QPropertyAnimation(QObject parent=None): too many arguments
  QPropertyAnimation(QObject, QByteArray, QObject parent=None): argument 2 has u
nexpected type 'str'

```



Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/CurvePoint.py b/pyqtgraph/graphicsItems/CurvePoint.py
--- a/pyqtgraph/graphicsItems/CurvePoint.py
+++ b/pyqtgraph/graphicsItems/CurvePoint.py
@@ -91,6 +91,11 @@ def paint(self, *args):
         pass
     
     def makeAnimation(self, prop='position', start=0.0, end=1.0, duration=10000, loop=1):
+        # In Python 3, a bytes object needs to be used as a property name in
+        # QPropertyAnimation. PyQt stopped automatically encoding a str when a
+        # QByteArray was expected in v5.5 (see qbytearray.sip).
+        if not isinstance(prop, bytes):
+            prop = prop.encode('latin-1')
         anim = QtCore.QPropertyAnimation(self, prop)
         anim.setDuration(duration)
         anim.setStartValue(start)


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
`examples/Flowchart.py` fails to produce output
The output plot is blank. The GaussianFilter node in the graph has the following traceback in it:

``` python
File "/usr/local/lib/python2.7/site-packages/pyqtgraph/flowchart/Node.py", line 304, in update
    out = self.process(**strDict(vals))
File "/usr/local/lib/python2.7/site-packages/pyqtgraph/flowchart/library/common.py", line 108, in process
    out = self.processData(In)
File "/usr/local/lib/python2.7/site-packages/pyqtgraph/flowchart/library/common.py", line 182, in newFn
    return fn(self, data, *args, **kargs)
File "/usr/local/lib/python2.7/site-packages/pyqtgraph/flowchart/library/Filters.py", line 167, in processData
    return pgfn.gaussianFilter(data, self.ctrls['sigma'].value())
File "/usr/local/lib/python2.7/site-packages/pyqtgraph/functions.py", line 1195, in gaussianFilter
    filtered = scale * np.fft.irfft(np.fft.rfft(filtered, shape, axis=ax) *
File "/usr/local/lib/python2.7/site-packages/numpy/fft/fftpack.py", line 366, in rfft
    a = array(a, copy=True, dtype=float)
```

Some digging reveals that `MetaArray.__array__` doesn't support numpy's `__array__` protocol fully: it doesn't support an optional `dtype`. I can patch around it by adding unused `*args` and `**kwargs` to it and just ignore them, but I'm not sure this is the correct way to go.



Discussion:

Resolving patch:
diff --git a/pyqtgraph/metaarray/MetaArray.py b/pyqtgraph/metaarray/MetaArray.py
--- a/pyqtgraph/metaarray/MetaArray.py
+++ b/pyqtgraph/metaarray/MetaArray.py
@@ -358,7 +358,7 @@ def asarray(self):
         else:
             return np.array(self._data)
             
-    def __array__(self):
+    def __array__(self, dtype=None):
         ## supports np.array(metaarray_instance) 
         return self.asarray()
             


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
QLayoutWidget Add Label Error: No method AddItem
The code in QLayoutWidget looks something like:

```
    def addLabel(self, text=' ', row=None, col=None, rowspan=1, colspan=1, **kargs):
        """
        Create a QLabel with *text* and place it in the next available cell (or in the cell specified)
        All extra keyword arguments are passed to QLabel().
        Returns the created widget.
        """
        text = QtGui.QLabel(text, **kargs)
        self.addItem(text, row, col, rowspan, colspan)
        return text
```

I think it should have `self.addWidget` instead of `self.addItem` as addItem method is missing.

Error:

```
AttributeError: 'LayoutWidget' object has no attribute 'addItem'
```



Discussion:
?

Resolving patch:
diff --git a/pyqtgraph/widgets/LayoutWidget.py b/pyqtgraph/widgets/LayoutWidget.py
--- a/pyqtgraph/widgets/LayoutWidget.py
+++ b/pyqtgraph/widgets/LayoutWidget.py
@@ -39,7 +39,7 @@ def addLabel(self, text=' ', row=None, col=None, rowspan=1, colspan=1, **kargs):
         Returns the created widget.
         """
         text = QtGui.QLabel(text, **kargs)
-        self.addItem(text, row, col, rowspan, colspan)
+        self.addWidget(text, row, col, rowspan, colspan)
         return text
         
     def addLayout(self, row=None, col=None, rowspan=1, colspan=1, **kargs):
@@ -49,7 +49,7 @@ def addLayout(self, row=None, col=None, rowspan=1, colspan=1, **kargs):
         Returns the created widget.
         """
         layout = LayoutWidget(**kargs)
-        self.addItem(layout, row, col, rowspan, colspan)
+        self.addWidget(layout, row, col, rowspan, colspan)
         return layout
         
     def addWidget(self, item, row=None, col=None, rowspan=1, colspan=1):


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Retina display 3D issue
When opening a 3D example on a Mac with a Retina (HiDPI) display, the scene is only rendered in the bottom left quadrant of the window.

<img width="591" alt="screen shot 2017-06-09 at 10 19 47 am" src="https://user-images.githubusercontent.com/6744917/26986652-54c5a4ea-4cfd-11e7-89ae-ae855d020a9f.png">

Anaconda environment includes:

numpy                     1.11.3                   py35_0  
pyopengl                  3.1.1a1             np111py35_0  
pyqt                      5.6.0                    py35_1  
pyqtgraph                 0.10.0+gaf4c673           <pip>
scipy                     0.19.0              np111py35_0  



Discussion:
I have reported the same in issue #422 with a fix. I just haven't made a pull request for it.



Resolving patch:
diff --git a/pyqtgraph/opengl/GLViewWidget.py b/pyqtgraph/opengl/GLViewWidget.py
--- a/pyqtgraph/opengl/GLViewWidget.py
+++ b/pyqtgraph/opengl/GLViewWidget.py
@@ -80,7 +80,7 @@ def setBackgroundColor(self, *args, **kwds):
     def getViewport(self):
         vp = self.opts['viewport']
         if vp is None:
-            return (0, 0, self.width(), self.height())
+            return (0, 0, self.width() * self.devicePixelRatio(), self.height() * self.devicePixelRatio())
         else:
             return vp
         
@@ -99,7 +99,7 @@ def setProjection(self, region=None):
     def projectionMatrix(self, region=None):
         # Xw = (Xnd + 1) * width/2 + X
         if region is None:
-            region = (0, 0, self.width(), self.height())
+            region = (0, 0, self.width() * self.devicePixelRatio(), self.height() * self.devicePixelRatio())
         
         x0, y0, w, h = self.getViewport()
         dist = self.opts['distance']
diff --git a/pyqtgraph/widgets/RawImageWidget.py b/pyqtgraph/widgets/RawImageWidget.py
--- a/pyqtgraph/widgets/RawImageWidget.py
+++ b/pyqtgraph/widgets/RawImageWidget.py
@@ -122,7 +122,7 @@ def paintGL(self):
             if not self.uploaded:
                 self.uploadTexture()
             
-            glViewport(0, 0, self.width(), self.height())
+            glViewport(0, 0, self.width() * self.devicePixelRatio(), self.height() * self.devicePixelRatio())
             glEnable(GL_TEXTURE_2D)
             glBindTexture(GL_TEXTURE_2D, self.texture)
             glColor4f(1,1,1,1)


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
"Koch Fractal" example is missing an import [develop branch]
The "Koch Fractal" example is missing the import for the `reduce()` function.

```
Traceback (most recent call last):
  File "C:\Anaconda3\lib\site-packages\pyqtgraph\examples\fractal.py", line 106, in <module>
    update()
  File "C:\Anaconda3\lib\site-packages\pyqtgraph\examples\fractal.py", line 86, in update
    mats = reduce(matmul, mats)
NameError: name 'reduce' is not defined
```

Adding `from functools import reduce` fixes it.


Discussion:

Resolving patch:
diff --git a/examples/fractal.py b/examples/fractal.py
--- a/examples/fractal.py
+++ b/examples/fractal.py
@@ -4,6 +4,7 @@
 """
 import initExample ## Add path to library (just for examples; you do not need this)
 
+from functools import reduce
 import pyqtgraph as pg
 from pyqtgraph.Qt import QtCore, QtGui
 import numpy as np
@@ -111,12 +112,4 @@ def matmul(a, b):
     import sys
     if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
         QtGui.QApplication.instance().exec_()
-
-
-
-
-
-
-
-
     
\ No newline at end of file


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
OverflowError in Point.py
It seems like [this old (2013) bug](https://bugs.launchpad.net/pyqtgraph/+bug/1234528) still hasn't been fixed. I've just bumped into the same error.

I will test solution suggested by author.


Discussion:

Resolving patch:
diff --git a/pyqtgraph/Point.py b/pyqtgraph/Point.py
--- a/pyqtgraph/Point.py
+++ b/pyqtgraph/Point.py
@@ -105,7 +105,13 @@ def _math_(self, op, x):
     
     def length(self):
         """Returns the vector length of this Point."""
-        return (self[0]**2 + self[1]**2) ** 0.5
+        try:
+            return (self[0]**2 + self[1]**2) ** 0.5
+        except OverflowError:
+            try:
+                return self[1] / np.sin(np.arctan2(self[1], self[0]))
+            except OverflowError:
+                return np.inf
     
     def norm(self):
         """Returns a vector in the same direction with unit length."""


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
"Must specify at least one of rect, xRange, or yRange" under PyQt5 ARM
When i trying to run pyqtgraph under my PyQt5 ARM there is such issue. There is no problem with any other PyQt5 app. Any hints please?

```
# python
Python 2.7.13 (default, May 11 2018, 11:36:17) 
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyqtgraph as pg 
>>> pg.__version__
'0.10.0'
>>> pg.plot([1,2,3,4])
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
libEGL warning: DRI2: failed to authenticate
None
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/oe-core4/build/tmp/work/armv7ahf-neon-poky-linux-gnueabi/python-pyqtgraph/0.10.0-r0/image//usr/lib/python2.7/site-packages/pyqtgraph/__init__.py", line 409, in plot
  File "/opt/oe-core4/build/tmp/work/armv7ahf-neon-poky-linux-gnueabi/python-pyqtgraph/0.10.0-r0/image//usr/lib/python2.7/site-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 640, in plot
  File "/opt/oe-core4/build/tmp/work/armv7ahf-neon-poky-linux-gnueabi/python-pyqtgraph/0.10.0-r0/image//usr/lib/python2.7/site-packages/pyqtgraph/graphicsItems/PlotItem/PlotItem.py", line 512, in addItem
  File "/opt/oe-core4/build/tmp/work/armv7ahf-neon-poky-linux-gnueabi/python-pyqtgraph/0.10.0-r0/image//usr/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ViewBox/ViewBox.py", line 407, in addItem
  File "/opt/oe-core4/build/tmp/work/armv7ahf-neon-poky-linux-gnueabi/python-pyqtgraph/0.10.0-r0/image//usr/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ViewBox/ViewBox.py", line 914, in updateAutoRange
  File "/opt/oe-core4/build/tmp/work/armv7ahf-neon-poky-linux-gnueabi/python-pyqtgraph/0.10.0-r0/image//usr/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ViewBox/ViewBox.py", line 512, in setRange
Exception: Must specify at least one of rect, xRange, or yRange. (gave rect=<type 'NoneType'>)

```


Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py
--- a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py
+++ b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py
@@ -847,10 +847,6 @@ def updateAutoRange(self):
                         childRange[ax][1] += wp
                     targetRect[ax] = childRange[ax]
                     args['xRange' if ax == 0 else 'yRange'] = targetRect[ax]
-            if len(args) == 0:
-                return
-            args['padding'] = 0
-            args['disableAutoRange'] = False
             
              # check for and ignore bad ranges
             for k in ['xRange', 'yRange']:
@@ -858,6 +854,11 @@ def updateAutoRange(self):
                     if not np.all(np.isfinite(args[k])):
                         r = args.pop(k)
                         #print("Warning: %s is invalid: %s" % (k, str(r))
+            
+            if len(args) == 0:
+                return
+            args['padding'] = 0
+            args['disableAutoRange'] = False
                         
             self.setRange(**args)
         finally:


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
TableWidget saving broken
Invoking the *Save* feature via context menu on a `TableWidget` fails on PyQt5 because `QFileDialog.getSaveFileName` returns a tuple `filename, filter`, not just the filename.

I suppose PyQt4 and/or PySide behave differently. 


Discussion:

Resolving patch:
diff --git a/examples/relativity/relativity.py b/examples/relativity/relativity.py
--- a/examples/relativity/relativity.py
+++ b/examples/relativity/relativity.py
@@ -159,17 +159,21 @@ def treeChanged(self, *args):
         self.setAnimation(self.params['Animate'])
         
     def save(self):
-        fn = str(pg.QtGui.QFileDialog.getSaveFileName(self, "Save State..", "untitled.cfg", "Config Files (*.cfg)"))
-        if fn == '':
+        filename = pg.QtGui.QFileDialog.getSaveFileName(self, "Save State..", "untitled.cfg", "Config Files (*.cfg)")
+        if isinstance(filename, tuple):
+            filename = filename[0]  # Qt4/5 API difference
+        if filename == '':
             return
         state = self.params.saveState()
-        pg.configfile.writeConfigFile(state, fn) 
+        pg.configfile.writeConfigFile(state, str(filename)) 
         
     def load(self):
-        fn = str(pg.QtGui.QFileDialog.getOpenFileName(self, "Save State..", "", "Config Files (*.cfg)"))
-        if fn == '':
+        filename = pg.QtGui.QFileDialog.getOpenFileName(self, "Save State..", "", "Config Files (*.cfg)")
+        if isinstance(filename, tuple):
+            filename = filename[0]  # Qt4/5 API difference
+        if filename == '':
             return
-        state = pg.configfile.readConfigFile(fn) 
+        state = pg.configfile.readConfigFile(str(filename)) 
         self.loadState(state)
         
     def loadPreset(self, param, preset):
diff --git a/pyqtgraph/imageview/ImageView.py b/pyqtgraph/imageview/ImageView.py
--- a/pyqtgraph/imageview/ImageView.py
+++ b/pyqtgraph/imageview/ImageView.py
@@ -790,9 +790,11 @@ def export(self, fileName):
             
     def exportClicked(self):
         fileName = QtGui.QFileDialog.getSaveFileName()
+        if isinstance(fileName, tuple):
+            fileName = fileName[0]  # Qt4/5 API difference
         if fileName == '':
             return
-        self.export(fileName)
+        self.export(str(fileName))
         
     def buildMenu(self):
         self.menu = QtGui.QMenu()
diff --git a/pyqtgraph/widgets/TableWidget.py b/pyqtgraph/widgets/TableWidget.py
--- a/pyqtgraph/widgets/TableWidget.py
+++ b/pyqtgraph/widgets/TableWidget.py
@@ -351,9 +351,11 @@ def saveAll(self):
 
     def save(self, data):
         fileName = QtGui.QFileDialog.getSaveFileName(self, "Save As..", "", "Tab-separated values (*.tsv)")
+        if isinstance(fileName, tuple):
+            fileName = fileName[0]  # Qt4/5 API difference
         if fileName == '':
             return
-        open(fileName, 'w').write(data)
+        open(str(fileName), 'w').write(data)
 
     def contextMenuEvent(self, ev):
         self.contextMenu.popup(ev.globalPos())


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
ViewBox: "UnboundLocalError: local variable 'mask' referenced before assignment"
https://github.com/pyqtgraph/pyqtgraph/blob/585390e16ebbc7eb993c78216cc88e439c5bfe60/pyqtgraph/graphicsItems/ViewBox/ViewBox.py#L1128


Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py
--- a/pyqtgraph/graphicsItems/ViewBox/ViewBox.py
+++ b/pyqtgraph/graphicsItems/ViewBox/ViewBox.py
@@ -1124,8 +1124,8 @@ def itemBoundingRect(self, item):
         """Return the bounding rect of the item in view coordinates"""
         return self.mapSceneToView(item.sceneBoundingRect()).boundingRect()
 
-    def wheelEvent(self, ev, axis=None):        
-        if axis is not None and axis >= 0 and axis < len(mask):
+    def wheelEvent(self, ev, axis=None):
+        if axis in (0, 1):
             mask = [False, False]
             mask[axis] = self.state['mouseEnabled'][axis]
         else:


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
ImageItem: autoDownsample forces qimage recalculation every render
The way autoDownsample is currently implemented forces the entire Image to be downsampled, the lut/levels to be applied and the ARGB and QImage to be recalculated every single time the image is updated. This happens even if the calculated downsample is 1 (ie. no downsampling needed). This leads to using autoDownsample often making drawing images slower than not downsampling. That is kind of counterproductive.

This happens because in viewTransformChanged, the qimage is simply set to None if autoDownsampling is enabled, and an update is forced which calls render. There everything is realculated every time. viewTranformChanged is called everytime the image is moved or zoomed in/out on.

However, since the entire image is downsampled and the LUT applied to it, a new recalculation would only be needed if the downsampling factors change (because of zooming in or out) or if the LUT/levels are changed (which works with a different event pathway).

[Edit] A relatively easy fix is to do the check for the xds, yds in viewTransformChanged and only delete the qimage if that is different from before.


Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ImageItem.py b/pyqtgraph/graphicsItems/ImageItem.py
--- a/pyqtgraph/graphicsItems/ImageItem.py
+++ b/pyqtgraph/graphicsItems/ImageItem.py
@@ -51,6 +51,7 @@ def __init__(self, image=None, **kargs):
         self.levels = None  ## [min, max] or [[redMin, redMax], ...]
         self.lut = None
         self.autoDownsample = False
+        self._lastDownsample = (1, 1)
 
         self.axisOrder = getConfigOption('imageAxisOrder')
 
@@ -551,8 +552,19 @@ def pixelSize(self):
 
     def viewTransformChanged(self):
         if self.autoDownsample:
-            self.qimage = None
-            self.update()
+            o = self.mapToDevice(QtCore.QPointF(0,0))
+            x = self.mapToDevice(QtCore.QPointF(1,0))
+            y = self.mapToDevice(QtCore.QPointF(0,1))
+            w = Point(x-o).length()
+            h = Point(y-o).length()
+            if w == 0 or h == 0:
+                self.qimage = None
+                return
+            xds = max(1, int(1.0 / w))
+            yds = max(1, int(1.0 / h))
+            if (xds, yds) != self._lastDownsample:
+                self.qimage = None
+                self.update()
 
     def mouseDragEvent(self, ev):
         if ev.button() != QtCore.Qt.LeftButton:


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
ValueError: mmap length is greater than file size 
It's been many months since I'm using pyqtgraph and it's amazing. But recently when I've updated my maxOS to High Sierra 10.13.6 I'm facing following issue:
`ValueError: mmap length is greater than file size`
When I'm trying to run the pyqtgraph remote plotting example, the same is being thrown
Complete log is [here](https://gist.github.com/sachinsngh165/65df4e4f3dc81a283379dc032cf48220)
I'm using PyQt4+ python2.7
Also same error with PyQt5 + Python3
Please help me out it's urgent as I have to complete my project within a week.


Discussion:
I don't have an OSX 10.13 system to test on, but you could try playing with the file size here:
https://github.com/pyqtgraph/pyqtgraph/blob/develop/pyqtgraph/widgets/RemoteGraphicsView.py#L154
I would try replacing that line with something like:
```self.shmFile.write(b'\x00' * (4 * mmap.PAGESIZE + 1))```
just to see whether that is the source of the problem. It seems a bit unlikely, though, since the line that generates the error is also requesting `mmap.PAGESIZE` as the length to be mapped. Another thing I would try is just printing out mmap.PAGESIZE on both main process and subprocess to be sure they are the same (possibly the remote process is using a different python version?)
Thank you @campagnola, I would try your suggestions.
Also faced the same problem on Mac, trying @campagnola's suggestion didn't work for me.  

I think the issue is when the file is written at line 154, it is not immediately flushed.  Adding `self.shmFile.flush()` after that line (and before mmap call) solves the problem for me.  Changing line 153 to `tempfile.NamedTemporaryFile(buffering=0, prefix='pyqtgraph_shmem_')` also works it seems.

Resolving patch:
diff --git a/pyqtgraph/widgets/RemoteGraphicsView.py b/pyqtgraph/widgets/RemoteGraphicsView.py
--- a/pyqtgraph/widgets/RemoteGraphicsView.py
+++ b/pyqtgraph/widgets/RemoteGraphicsView.py
@@ -152,6 +152,7 @@ def __init__(self, *args, **kwds):
         else:
             self.shmFile = tempfile.NamedTemporaryFile(prefix='pyqtgraph_shmem_')
             self.shmFile.write(b'\x00' * (mmap.PAGESIZE+1))
+            self.shmFile.flush()
             fd = self.shmFile.fileno()
             self.shm = mmap.mmap(fd, mmap.PAGESIZE, mmap.MAP_SHARED, mmap.PROT_WRITE)
         atexit.register(self.close)


Test patch: