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

Issue:
Bugfix: a user provided handle for ROIs was not set to the correct posit...
I just changed the position of the h.setPos so that also a user provided handle will get initially the correct position on the ROI



Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py
--- a/pyqtgraph/graphicsItems/ROI.py
+++ b/pyqtgraph/graphicsItems/ROI.py
@@ -590,13 +590,13 @@ def addHandle(self, info, index=None):
         ## If a Handle was not supplied, create it now
         if 'item' not in info or info['item'] is None:
             h = Handle(self.handleSize, typ=info['type'], pen=self.handlePen, parent=self)
-            h.setPos(info['pos'] * self.state['size'])
             info['item'] = h
         else:
             h = info['item']
             if info['pos'] is None:
                 info['pos'] = h.pos()
-            
+        h.setPos(info['pos'] * self.state['size'])
+
         ## connect the handle to this ROI
         #iid = len(self.handles)
         h.connectROI(self)
@@ -1273,11 +1273,12 @@ class Handle(UIGraphicsItem):
     sigClicked = QtCore.Signal(object, object)   # self, event
     sigRemoveRequested = QtCore.Signal(object)   # self
     
-    def __init__(self, radius, typ=None, pen=(200, 200, 220), parent=None, deletable=False):
+    def __init__(self, radius, typ=None, pen=(200, 200, 220), parent=None, deletable=False, activePen=(255, 255, 0)):
         self.rois = []
         self.radius = radius
         self.typ = typ
         self.pen = fn.mkPen(pen)
+        self.activePen = fn.mkPen(activePen)
         self.currentPen = self.pen
         self.pen.setWidth(0)
         self.pen.setCosmetic(True)
@@ -1321,7 +1322,7 @@ def hoverEvent(self, ev):
                     hover=True
                     
         if hover:
-            self.currentPen = fn.mkPen(255, 255,0)
+            self.currentPen = self.activePen
         else:
             self.currentPen = self.pen
         self.update()
@@ -1374,15 +1375,19 @@ def mouseDragEvent(self, ev):
                 for r in self.rois:
                     r.stateChangeFinished()
             self.isMoving = False
+            self.currentPen = self.pen
+            self.update()
         elif ev.isStart():
             for r in self.rois:
                 r.handleMoveStarted()
             self.isMoving = True
             self.startPos = self.scenePos()
             self.cursorOffset = self.scenePos() - ev.buttonDownScenePos()
+            self.currentPen = self.activePen
             
         if self.isMoving:  ## note: isMoving may become False in mid-drag due to right-click.
             pos = ev.scenePos() + self.cursorOffset
+            self.currentPen = self.activePen
             self.movePoint(pos, ev.modifiers(), finish=False)
 
     def movePoint(self, pos, modifiers=QtCore.Qt.KeyboardModifier(), finish=True):


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Remove ScatterPlotItem's SpotItems during addItem call
After addItem is called and a new data array is constructed, any previously created SpotItems will have obsolete references to the old data array.  This clears these SpotItems so that new ones can be created with up-to-date array references.



Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ScatterPlotItem.py b/pyqtgraph/graphicsItems/ScatterPlotItem.py
--- a/pyqtgraph/graphicsItems/ScatterPlotItem.py
+++ b/pyqtgraph/graphicsItems/ScatterPlotItem.py
@@ -379,6 +379,9 @@ def addPoints(self, *args, **kargs):
             kargs['y'] = []
             numPts = 0
 
+        ## Clear current SpotItems since the data references they contain will no longer be current
+        self.data['item'][...] = None
+
         ## Extend record array
         oldData = self.data
         self.data = np.empty(len(oldData)+numPts, dtype=self.data.dtype)


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Fix incorrect tick text boundaries calculation on axis by setting the font
In AxisItem.generateDrawSpecs painter should have the same font as tickFont, otherwise it calculates tick text boundaries incorreclty. Without this fix we have tickLabels overflowing each other and everything else on the screen when we change their font. This quick fix solved the issue for us.



Discussion:
## [Current coverage](https://codecov.io/gh/pyqtgraph/pyqtgraph/pull/336?src=pr) is **32.62%**

> Merging [#336](https://codecov.io/gh/pyqtgraph/pyqtgraph/pull/336?src=pr) into [develop](https://codecov.io/gh/pyqtgraph/pyqtgraph/branch/develop?src=pr) will decrease coverage by **-<.01%**

``` diff
@@            develop       #336   diff @@
==========================================
  Files           198        198          
  Lines         27088      27090     +2   
  Methods           0          0          
  Messages          0          0          
  Branches       4512       4513     +1   
==========================================
- Hits           8844       8836     -8   
- Misses        17481      17489     +8   
- Partials        763        765     +2   
```
1. File `...ocess/remoteproxy.py` (not in diff) was modified. [more](https://codecov.io/gh/pyqtgraph/pyqtgraph/commit/6855961b61d565ac93c5b38cbb2f060aef3af0e4/changes?src=pr#7079717467726170682F6D756C746970726F636573732F72656D6F746570726F78792E7079) 
   - Misses `+7` 
   - Partials `+1` 
   - Hits `-8`

> Powered by [Codecov](https://codecov.io?src=pr). Last updated by [670d63c...6855961](https://codecov.io/gh/pyqtgraph/pyqtgraph/compare/670d63cdf443d667eece3b203083692588f41693...6855961b61d565ac93c5b38cbb2f060aef3af0e4)


Resolving patch:
diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py
--- a/pyqtgraph/graphicsItems/AxisItem.py
+++ b/pyqtgraph/graphicsItems/AxisItem.py
@@ -853,8 +853,8 @@ def generateDrawSpecs(self, p):
         interpreted by drawPicture().
         """
         profiler = debug.Profiler()
-
-        #bounds = self.boundingRect()
+        if self.style['tickFont'] is not None:
+            p.setFont(self.style['tickFont'])
         bounds = self.mapRectFromParent(self.geometry())
 
         linkedView = self.linkedView()


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
addition of a saveState and setState for LineSegmentROI
Addition of a saveState and setState for LineSegmentROI. LineSegmentROI and PolyLineROI now have the same behaviour regarding thet state saving and restoring.



Discussion:
@campagnola and @ericdill , any chance one of you find the time to review this PR?

ping @campagnola  and @ericdill 

ping @campagnola and @ericdill 

ping @ericdill and @campagnola.

Is this PR still relevant regarding #349 @campagnola ? I checked the source code, and did not see anything about LineSegment... 

@campagnola, is this PR still relevant regarding #349 ?


Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py
--- a/pyqtgraph/graphicsItems/ROI.py
+++ b/pyqtgraph/graphicsItems/ROI.py
@@ -2121,6 +2121,23 @@ def endpoints(self):
         
     def listPoints(self):
         return [p['item'].pos() for p in self.handles]
+
+    def getState(self):
+        state = ROI.getState(self)
+        state['points'] = [Point(h.pos()) for h in self.getHandles()]
+        return state
+
+    def saveState(self):
+        state = ROI.saveState(self)
+        state['points'] = [tuple(h.pos()) for h in self.getHandles()]
+        return state
+
+    def setState(self, state):
+        ROI.setState(self, state)
+        p1 = [state['points'][0][0]+state['pos'][0], state['points'][0][1]+state['pos'][1]]
+        p2 = [state['points'][1][0]+state['pos'][0], state['points'][1][1]+state['pos'][1]]
+        self.movePoint(self.getHandles()[0], p1, finish=False)
+        self.movePoint(self.getHandles()[1], p2)
             
     def paint(self, p, *args):
         p.setRenderHint(QtGui.QPainter.Antialiasing)


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Add tickAlpha setting to AxisItem style
In the AxisItem class, ticks are arranged in a hierarchy (major, minor, subminor). When you have a plot with gridlines, the higher ticks are drawn with heavier lines. I needed to produce a plot where the gridlines all look the same, but could not find a straightforward way of doing so. I could have subclassed the AxisItem class and used the custom class in my code, but I felt that other people might find this added functionality useful, so I instead created this pull request.



Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/AxisItem.py b/pyqtgraph/graphicsItems/AxisItem.py
--- a/pyqtgraph/graphicsItems/AxisItem.py
+++ b/pyqtgraph/graphicsItems/AxisItem.py
@@ -69,6 +69,7 @@ def __init__(self, orientation, pen=None, textPen=None, linkView=None, parent=No
             'tickLength': maxTickLength,
             'maxTickLevel': 2,
             'maxTextLevel': 2,
+            'tickAlpha': None,  ## If not none, use this alpha for all ticks.
         }
 
         self.textWidth = 30  ## Keeps track of maximum width / height of tick text
@@ -150,6 +151,11 @@ def setStyle(self, **kwds):
 
         showValues          (bool) indicates whether text is displayed adjacent
                             to ticks.
+        tickAlpha           (float or int or None) If None, pyqtgraph will draw the
+                            ticks with the alpha it deems appropriate.  Otherwise, 
+                            the alpha will be fixed at the value passed.  With int, 
+                            accepted values are [0..255].  With vaule of type
+                            float, accepted values are from [0..1].
         =================== =======================================================
 
         Added in version 0.9.9
@@ -955,10 +961,21 @@ def generateDrawSpecs(self, p):
 
             ## length of tick
             tickLength = self.style['tickLength'] / ((i*0.5)+1.0)
-
-            lineAlpha = 255 / (i+1)
-            if self.grid is not False:
-                lineAlpha *= self.grid/255. * np.clip((0.05  * lengthInPixels / (len(ticks)+1)), 0., 1.)
+                
+            lineAlpha = self.style["tickAlpha"]
+            if lineAlpha is None:
+                lineAlpha = 255 / (i+1)
+                if self.grid is not False:
+                    lineAlpha *= self.grid/255. * np.clip((0.05  * lengthInPixels / (len(ticks)+1)), 0., 1.)
+            elif isinstance(lineAlpha, float):
+                lineAlpha *= 255
+                lineAlpha = max(0, int(round(lineAlpha)))
+                lineAlpha = min(255, int(round(lineAlpha)))
+            elif isinstance(lineAlpha, int):
+                if (lineAlpha > 255) or (lineAlpha < 0):
+                    raise ValueError("lineAlpha should be [0..255]")
+            else:
+                raise TypeError("Line Alpha should be of type None, float or int")
 
             for v in ticks:
                 ## determine actual position to draw this tick


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
[ROI] make all ROI subclasses accept the same kwargs
`ROI` subclasses are currently a little awkward to use because they accept a disjoint set of keyword args in `getArrayRegion()`. Fix that and make sure that they all support `axes=(m, n)` for commonality.



Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py
--- a/pyqtgraph/graphicsItems/ROI.py
+++ b/pyqtgraph/graphicsItems/ROI.py
@@ -1662,6 +1662,15 @@ def getHandlePositions(self):
         return pos
         
     def getArrayRegion(self, arr, img=None, axes=(0,1), **kwds):
+        """
+        Return the result of :meth:`~pyqtgraph.ROI.getArrayRegion` for each rect
+        in the chain concatenated into a single ndarray.
+
+        See :meth:`~pyqtgraph.ROI.getArrayRegion` for a description of the
+        arguments.
+
+        Note: ``returnMappedCoords`` is not yet supported for this ROI type.
+        """
         rgns = []
         for l in self.lines:
             rgn = l.getArrayRegion(arr, img, axes=axes, **kwds)
@@ -1775,8 +1784,13 @@ def paint(self, p, opt, widget):
         
     def getArrayRegion(self, arr, img=None, axes=(0, 1), **kwds):
         """
-        Return the result of ROI.getArrayRegion() masked by the elliptical shape
-        of the ROI. Regions outside the ellipse are set to 0.
+        Return the result of :meth:`~pyqtgraph.ROI.getArrayRegion` masked by the
+        elliptical shape of the ROI. Regions outside the ellipse are set to 0.
+
+        See :meth:`~pyqtgraph.ROI.getArrayRegion` for a description of the
+        arguments.
+
+        Note: ``returnMappedCoords`` is not yet supported for this ROI type.
         """
         # Note: we could use the same method as used by PolyLineROI, but this
         # implementation produces a nicer mask.
@@ -2059,8 +2073,13 @@ def shape(self):
 
     def getArrayRegion(self, data, img, axes=(0,1), **kwds):
         """
-        Return the result of ROI.getArrayRegion(), masked by the shape of the 
-        ROI. Values outside the ROI shape are set to 0.
+        Return the result of :meth:`~pyqtgraph.ROI.getArrayRegion`, masked by
+        the shape of the ROI. Values outside the ROI shape are set to 0.
+
+        See :meth:`~pyqtgraph.ROI.getArrayRegion` for a description of the
+        arguments.
+
+        Note: ``returnMappedCoords`` is not yet supported for this ROI type.
         """
         br = self.boundingRect()
         if br.width() > 1000:
@@ -2179,7 +2198,8 @@ def getArrayRegion(self, data, img, axes=(0,1), order=1, returnMappedCoords=Fals
         Since this pulls 1D data from a 2D coordinate system, the return value 
         will have ndim = data.ndim-1
         
-        See ROI.getArrayRegion() for a description of the arguments.
+        See :meth:`~pytqgraph.ROI.getArrayRegion` for a description of the
+        arguments.
         """
         imgPts = [self.mapToItem(img, h.pos()) for h in self.endpoints]
         rgns = []


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
PolyLineROI ignores hoverPen argument
### Short description
When creating a PolyLineROI and specifying the hoverPen argument, the ROI created still uses the default yellow solid line for the hover pen.

### Code to reproduce
<!-- Please provide a minimal working example that reproduces the issue in the code block below.
     Ideally, this should be a full example someone else could run without additional setup. -->
```python
import pyqtgraph as pg

roi=pg.PolyLineROI([(1,1),(1,5),(5,5),(5,1)], hoverPen='b') #Or whatever
```

### Expected behavior
When hovering over the ROI, the pen used to draw the ROI should change to the specified pen

### Real behavior
A solid yellow pen is used instead.
### Tested environment(s)

 * PyQtGraph version: 0.11.0+g11edbc0

### Problem/Solution

In ROI.py, in the _makePen function of _PolyLineSegment, the check for self.mouseHovering or self._parentHovering, line 2247, has the default yellow pen hard-coded as the return value. Instead, it should return self.hoverPen


Discussion:
Additionally, it would appear that self.hoverPen needs to be passed to the call to _PolyLineSegment (as the hoverPen argument) on line 2006, in the addSegment function. Perhaps there are other missing parameters here as well? This is just the one I noticed.
Good catch. I'll try to get this fixed soon.

#1285 for reference

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py
--- a/pyqtgraph/graphicsItems/ROI.py
+++ b/pyqtgraph/graphicsItems/ROI.py
@@ -2003,7 +2003,8 @@ def setState(self, state):
         self.setPoints(state['points'], closed=state['closed'])
         
     def addSegment(self, h1, h2, index=None):
-        seg = _PolyLineSegment(handles=(h1, h2), pen=self.pen, parent=self, movable=False)
+        seg = _PolyLineSegment(handles=(h1, h2), pen=self.pen, hoverPen=self.hoverPen,
+                               parent=self, movable=False)
         if index is None:
             self.segments.append(seg)
         else:
@@ -2244,7 +2245,7 @@ def setParentHover(self, hover):
         
     def _makePen(self):
         if self.mouseHovering or self._parentHovering:
-            return fn.mkPen(255, 255, 0)
+            return self.hoverPen
         else:
             return self.pen
         


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Add MultiPlotItem to docs
I noticed it's missing in reviewing #1324. Also [MultiPlotWidget](https://pyqtgraph.readthedocs.io/en/latest/widgets/multiplotwidget.html) should link to it and indicate it wraps the item's methods. `MultiPlotItem.plot` could also use a docstring.


Discussion:

Resolving patch:
diff --git a/pyqtgraph/graphicsItems/MultiPlotItem.py b/pyqtgraph/graphicsItems/MultiPlotItem.py
--- a/pyqtgraph/graphicsItems/MultiPlotItem.py
+++ b/pyqtgraph/graphicsItems/MultiPlotItem.py
@@ -4,22 +4,33 @@
 Copyright 2010  Luke Campagnola
 Distributed under MIT/X11 license. See license.txt for more information.
 """
-from numpy import ndarray
 from . import GraphicsLayout
 from ..metaarray import *
 
-
 __all__ = ['MultiPlotItem']
+
+
 class MultiPlotItem(GraphicsLayout.GraphicsLayout):
     """
-    Automatically generates a grid of plots from a multi-dimensional array
+    :class:`~pyqtgraph.GraphicsLayout` that automatically generates a grid of
+    plots from a MetaArray.
+
+    .. seealso:: :class:`~pyqtgraph.MultiPlotWidget`: Widget containing a MultiPlotItem
     """
+
     def __init__(self, *args, **kwds):
         GraphicsLayout.GraphicsLayout.__init__(self, *args, **kwds)
         self.plots = []
 
-
     def plot(self, data, **plotArgs):
+        """Plot the data from a MetaArray with each array column as a separate
+        :class:`~pyqtgraph.PlotItem`.
+
+        Axis labels are automatically extracted from the array info.
+
+        ``plotArgs`` are passed to :meth:`PlotItem.plot
+        <pyqtgraph.PlotItem.plot>`.
+        """
         #self.layout.clear()
 
         if hasattr(data, 'implements') and data.implements('MetaArray'):
diff --git a/pyqtgraph/widgets/MultiPlotWidget.py b/pyqtgraph/widgets/MultiPlotWidget.py
--- a/pyqtgraph/widgets/MultiPlotWidget.py
+++ b/pyqtgraph/widgets/MultiPlotWidget.py
@@ -10,7 +10,8 @@
 
 __all__ = ['MultiPlotWidget']
 class MultiPlotWidget(GraphicsView):
-    """Widget implementing a graphicsView with a single MultiPlotItem inside."""
+    """Widget implementing a :class:`~pyqtgraph.GraphicsView` with a single
+    :class:`~pyqtgraph.MultiPlotItem` inside."""
     def __init__(self, parent=None):
         self.minPlotHeight = 50
         self.mPlotItem = MultiPlotItem.MultiPlotItem()


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
Add fontSize kwarg to DockLabel constructor
Allows the font size of Dock title bars to be adjusted.

I need this for a project I'm writing -- the default font is quite small for what are significant graphical elements in a GUI.



Discussion:

Resolving patch:
diff --git a/pyqtgraph/dockarea/Dock.py b/pyqtgraph/dockarea/Dock.py
--- a/pyqtgraph/dockarea/Dock.py
+++ b/pyqtgraph/dockarea/Dock.py
@@ -10,13 +10,13 @@ class Dock(QtGui.QWidget, DockDrop):
     sigStretchChanged = QtCore.Signal()
     sigClosed = QtCore.Signal(object)
 
-    def __init__(self, name, area=None, size=(10, 10), widget=None, hideTitle=False, autoOrientation=True, closable=False):
+    def __init__(self, name, area=None, size=(10, 10), widget=None, hideTitle=False, autoOrientation=True, closable=False, fontSize="12px"):
         QtGui.QWidget.__init__(self)
         DockDrop.__init__(self)
         self._container = None
         self._name = name
         self.area = area
-        self.label = DockLabel(name, self, closable)
+        self.label = DockLabel(name, self, closable, fontSize)
         if closable:
             self.label.sigCloseClicked.connect(self.close)
         self.labelHidden = False
@@ -259,9 +259,10 @@ class DockLabel(VerticalLabel):
     sigClicked = QtCore.Signal(object, object)
     sigCloseClicked = QtCore.Signal()
 
-    def __init__(self, text, dock, showCloseButton):
+    def __init__(self, text, dock, showCloseButton, fontSize):
         self.dim = False
         self.fixedWidth = False
+        self.fontSize = fontSize
         VerticalLabel.__init__(self, text, orientation='horizontal', forceWidth=False)
         self.setAlignment(QtCore.Qt.AlignTop|QtCore.Qt.AlignHCenter)
         self.dock = dock
@@ -298,7 +299,8 @@ def updateStyle(self):
                 border-right: 2px solid %s;
                 padding-top: 3px;
                 padding-bottom: 3px;
-            }""" % (bg, fg, r, r, border)
+                font-size: %s;
+            }""" % (bg, fg, r, r, border, self.fontSize)
             self.setStyleSheet(self.vStyle)
         else:
             self.hStyle = """DockLabel {
@@ -312,7 +314,8 @@ def updateStyle(self):
                 border-bottom: 2px solid %s;
                 padding-left: 3px;
                 padding-right: 3px;
-            }""" % (bg, fg, r, r, border)
+                font-size: %s;
+            }""" % (bg, fg, r, r, border, self.fontSize)
             self.setStyleSheet(self.hStyle)
 
     def setDim(self, d):


Test patch:
Repository: pyqtgraph/pyqtgraph

Issue:
ExampleApp Syntax Highlighter broken in PyQt5
### Short description
Since merge of #1302, the syntax highlighter in the ExampleApp is broken  (CC @j9ac9k ).

### Code to reproduce
```bash
cd pyqtgraph\examples
python3 .
```

### Expected behavior
Syntax highlighter should work

### Real behavior
Following error:

```
Traceback (most recent call last):
  File "/home/b2/Documents/synced/pyqtgraph/examples/ExampleApp.py", line 298, in highlightBlock
    format = self.styles[format]
AttributeError: 'PythonHighlighter' object has no attribute 'styles'
```

### Tested environment(s)

 * PyQtGraph version: 7e57e07068fc8a62e9ae3b68e5556b11b6ef1841 and newer
 * Qt Python binding: yQt5 5.15.1 Qt 5.15.1
 * Python version: Python 3.8.5
 * NumPy version: 1.19.2
 * Operating system: Linux 5.8.16-2-MANJARO
 * Installation method: Run in folder (see above)


Discussion:
Hey @2xB,

Thanks for the issue.  We can launch the example app a variety of ways, but I didn't think that way was tested (although I don't see why it shouldn't work)...

if you go to the root project folder, can you launch the example app with 


```bash
python examples
```

or from python

```python
import pyqtgraph.examples
pyqtgraph.examples.run()
```

(also FYI running `python -m pyqtgraph.examples` does not work when pyqtgraph is installed via editable mode.
Hey ^^ The same error occurs when run via `python3 examples`.
Can you run it from the interpreter?


this is so odd...on macOS I can't replicate at all... it's going to be a little while before I have decent access to a linux machine.
Glanced over it - this looks weird, so I'm curious now. I try to investigate.

Resolving patch:
diff --git a/examples/__main__.py b/examples/__main__.py
--- a/examples/__main__.py
+++ b/examples/__main__.py
@@ -1,15 +1,16 @@
 import sys, os
+
+# Set up path to contain pyqtgraph module when run without installation
+if __name__ == "__main__" and (__package__ is None or __package__==''):
+    parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+    sys.path.insert(0, parent_dir)
+    import examples
+    __package__ = "examples"
+
 import pyqtgraph as pg
 from pyqtgraph.Qt import QtCore, QtGui
 
 
-
 if __name__ == '__main__':
-    if __package__ is None or __package__ == "":
-        parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-        sys.path.insert(0, parent_dir)
-        import examples
-        __package__ = "examples"
-
     from .ExampleApp import main as run
     run()


Test patch: