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

Issue:
Errors not showing in runner window (Windows 10)
When I start PsychoPy (2020.2.5) using the standard shortcut, errors in my experiment are not being printed to the runner view, but rather things fail silently.

However, if I start the same PsychoPy copy in PowerShell using `& "C:\Program Files\PsychoPy3\pythonw.exe" "C:\Program Files\PsychoPy3\Lib\site-packages\psychopy\app\psychopyApp.py"` then errors are visible in the runner view, as expected.


Discussion:
I found that error reporting (or actually stdout redirection) works if I close and reopen the runner window before starting the experiment.

Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -1105,7 +1105,7 @@ def runFile(self, event=None):
             ok = self.fileSave(self.filename)
             if not ok:
                 return  # save file before compiling script
-
+        self.app.showRunner()
         self.stdoutFrame.addTask(fileName=self.filename)
         self.app.runner.Raise()
         if event:
@@ -1238,7 +1238,7 @@ def stdoutFrame(self):
         Gets Experiment Runner stdout.
         """
         if not self.app.runner:
-            self.app.runner = self.app.newRunnerFrame()
+            self.app.runner = self.app.showRunner()
         return self.app.runner
 
     def _getHtmlPath(self, filename):
diff --git a/psychopy/app/coder/coder.py b/psychopy/app/coder/coder.py
--- a/psychopy/app/coder/coder.py
+++ b/psychopy/app/coder/coder.py
@@ -1339,7 +1339,7 @@ def __init__(self, parent, ID, title, files=(), app=None):
 
         # Link to Runner output
         if self.app.runner is None:
-            self.app.newRunnerFrame()
+            self.app.showRunner()
         self.outputWindow = self.app.runner.stdOut
         self.outputWindow.write(_translate('Welcome to PsychoPy3!') + '\n')
         self.outputWindow.write("v%s\n" % self.app.version)


Test patch:
Repository: psychopy/psychopy

Issue:
Scroll wheel doesn't register in Routine panel in Builder
https://discourse.psychopy.org/t/builder-interface-bug-scrolling-doesnt-work/17743


Discussion:

Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -1561,6 +1561,7 @@ def __init__(self, notebook, id=wx.ID_ANY, routine=None):
         self.Bind(wx.EVT_PAINT, self.OnPaint)
         self.Bind(wx.EVT_ERASE_BACKGROUND, lambda x: None)
         self.Bind(wx.EVT_MOUSE_EVENTS, self.OnMouse)
+        self.Bind(wx.EVT_MOUSEWHEEL, self.OnScroll)
         self.Bind(wx.EVT_SIZE, self.onResize)
         # crashes if drop on OSX:
         # self.SetDropTarget(FileDropTarget(builder = self.frame))
@@ -1621,6 +1622,11 @@ def OnMouse(self, event):
             except IndexError:
                 self.frame.SetStatusText("")
 
+    def OnScroll(self, event):
+        xy = self.GetViewStart()
+        multiplier = self.dpi / 1600
+        self.Scroll(xy[0], xy[1] - event.WheelRotation*multiplier)
+
     def showContextMenu(self, component, xy):
         menu = wx.Menu()
         for item in self.contextMenuItems:


Test patch:
Repository: psychopy/psychopy

Issue:
psychopy.visual.Aperture does not work with centimeter units
Reproduce this with minimal changes to the example code at `psychopy/demos/coder/stimuli/aperture.py`:

Add a `monitor='MyMonitor'` argument to `visual.Window()`, using a monitor that was calibrated for size.

Add `units='cm'` to the call to `visual.Aperture()`.

Observation: The stimulus looks exactly the same as without the change, even though we went from normalized to centimeter coordinates.


Discussion:

Resolving patch:
diff --git a/psychopy/visual/aperture.py b/psychopy/visual/aperture.py
--- a/psychopy/visual/aperture.py
+++ b/psychopy/visual/aperture.py
@@ -123,11 +123,11 @@ def __init__(self, win, size=1, pos=(0, 0), ori=0, nVert=120,
         if self.__dict__['filename']:
             self._shape = ImageStim(
                 win=self.win, image=self.__dict__['filename'],
-                pos=pos, size=size, autoLog=False)
+                pos=pos, size=size, autoLog=False, units=self.units)
         else:
             self._shape = BaseShapeStim(
                 win=self.win, vertices=vertices, fillColor=1, lineColor=None,
-                interpolate=False, pos=pos, size=size, autoLog=False)
+                interpolate=False, pos=pos, size=size, autoLog=False, units=self.units)
             self.vertices = self._shape.vertices
             self._needVertexUpdate = True
 


Test patch:
Repository: psychopy/psychopy

Issue:
Form component position not working when not centered
While forms are correctly sized at (0,0), when the position changes the only region visible is the space the form would occupy if it were the same size but at position (0,0)


Discussion:

Resolving patch:
diff --git a/psychopy/visual/form.py b/psychopy/visual/form.py
--- a/psychopy/visual/form.py
+++ b/psychopy/visual/form.py
@@ -474,10 +474,7 @@ def _sliderLabelWidths():
             style = kind
 
         # Create x position of response object
-        xPos = (self.rightEdge
-                - ((item['responseWidth'] * self.size[0]) / 2)
-                - self._scrollBarSize[0]
-                - self.itemPadding)
+        x = self.pos[0]
         # Set radio button layout
         if item['layout'] == 'horiz':
             w = (item['responseWidth'] * self.size[0]
@@ -490,7 +487,6 @@ def _sliderLabelWidths():
             item['options'].reverse()
 
         # Create Slider
-        x = xPos - self._scrollBarSize[0] - self.itemPadding
         resp = psychopy.visual.Slider(
                 self.win,
                 pos=(x, 0),  # NB y pos is irrelevant here - handled later
@@ -636,7 +632,7 @@ def _setAperture(self):
                                             units=self.units,
                                             shape='square',
                                             size=self.size,
-                                            pos=(0, 0),
+                                            pos=self.pos,
                                             autoLog=False)
         aperture.disable()  # Disable on creation. Only enable on draw.
         return aperture
@@ -913,3 +909,26 @@ def style(self, style):
                 'bg': [-0.19,-0.19,-0.14],  # background
                 'fg': [0.89,0.89,0.89],  # foreground
             }
+
+    @property
+    def values(self):
+        # Iterate through each control and append its value to a dict
+        out = {}
+        for item in self.getData():
+            out.update(
+                {item['index']: item['response']}
+            )
+        return out
+
+    @values.setter
+    def values(self, values):
+        for item in self.items:
+            if item['index'] in values:
+                ctrl = item['responseCtrl']
+                # set response if available
+                if hasattr(ctrl, "rating"):
+                    ctrl.rating = values[item['index']]
+                elif hasattr(ctrl, "value"):
+                    ctrl.value = values[item['index']]
+                else:
+                    ctrl.text = values[item['index']]
\ No newline at end of file


Test patch:
Repository: psychopy/psychopy

Issue:
quotation marks in a text box cause a syntax error
We handled this one before but it's back. A string needs to be represented to the script using repr(val) so that quotes get handled correctly. The attached compiles to a syntax error

[syntaxErrQuote.psyexp.zip](https://github.com/psychopy/psychopy/files/5784052/syntaxErrQuote.psyexp.zip)



Discussion:

Resolving patch:
diff --git a/psychopy/experiment/params.py b/psychopy/experiment/params.py
--- a/psychopy/experiment/params.py
+++ b/psychopy/experiment/params.py
@@ -199,7 +199,7 @@ def __str__(self):
                         # If param is a file of any kind, escape any \
                         val = re.sub(r"\\", r"\\\\", val)
                     val=re.sub("\n", "\\\\n", val) # Replace line breaks with escaped line break character
-                    return f"\"{val}\""
+                    return repr(val)
             return repr(self.val)
         elif self.valType in ['code', 'extendedCode']:
             isStr = isinstance(self.val, basestring)


Test patch:
diff --git a/psychopy/tests/test_alerts/test_alerttools.py b/psychopy/tests/test_alerts/test_alerttools.py
--- a/psychopy/tests/test_alerts/test_alerttools.py
+++ b/psychopy/tests/test_alerts/test_alerttools.py
@@ -101,7 +101,7 @@ def test_4115_frames_as_int(self):
         self.polygonComp.params['startVal'].val = .5
         self.polygonComp.params['startType'].val = "duration (frames)"
         self.exp.integrityCheck()
-        assert ("Your stimulus start type \"duration (frames)\" must be expressed as a whole number" in self.error.alerts[0].msg)
+        assert ("Your stimulus start type \'duration (frames)\' must be expressed as a whole number" in self.error.alerts[0].msg)
 
     def test_python_syntax(self):
         alerttools.checkPythonSyntax(self.codeComp, 'Begin Experiment')
Repository: psychopy/psychopy

Issue:
App crashes on saving new Coder file
When a new file is created in Coder, the first time it is saved, the app crashes. The file still saves, so the error is after the writing happens.


Discussion:
Misdiagnosed this one - turns out it's actually a problem with Runner, line 903 where it raises a FileNotFoundError. It's only being picked up by the error dlg when Send To Runner was clicked, when it's just Run the app crashes instead.

Resolving patch:
diff --git a/psychopy/app/coder/coder.py b/psychopy/app/coder/coder.py
--- a/psychopy/app/coder/coder.py
+++ b/psychopy/app/coder/coder.py
@@ -9,6 +9,8 @@
 
 # from future import standard_library
 # standard_library.install_aliases()
+from pathlib import Path
+
 from past.builtins import unicode
 from builtins import chr
 from builtins import range
@@ -33,6 +35,7 @@
 from .. import stdOutRich, dialogs
 from .. import pavlovia_ui
 from psychopy import logging, prefs
+from psychopy.alerts._alerts import alert
 from psychopy.localization import _translate
 from ..utils import FileDropTarget, PsychopyToolbar, FrameSwitcher
 from psychopy.projects import pavlovia
@@ -2590,12 +2593,11 @@ def fileCloseAll(self, event, checkSave=True):
     def runFile(self, event=None):
         """Open Runner for running the script."""
 
-        fullPath = self.currentDoc.filename
-        filename = os.path.split(fullPath)[1]
+        fullPath = Path(self.currentDoc.filename)
         # does the file need saving before running?
-        if self.currentDoc.UNSAVED:
+        if self.currentDoc.UNSAVED or not fullPath.is_file():
             sys.stdout.flush()
-            msg = _translate('Save changes to %s before running?') % filename
+            msg = _translate('Save changes to %s before running?') % fullPath.name
             dlg = dialogs.MessageDialog(self, message=msg, type='Warning')
             resp = dlg.ShowModal()
             sys.stdout.flush()
@@ -2606,9 +2608,13 @@ def runFile(self, event=None):
                 self.fileSave(None)  # save then run
             elif resp == wx.ID_NO:
                 pass  # just run
+        fullPath = Path(self.currentDoc.filename) # Get full path again in case it has changed
         if self.app.runner == None:
             self.app.showRunner()
-        self.app.runner.addTask(fileName=fullPath)
+        if fullPath.is_file():
+            self.app.runner.addTask(fileName=fullPath)
+        else:
+            alert(code=6105, strFields={'path': str(fullPath)})
         self.app.runner.Raise()
         if event:
             if event.Id in [self.cdrBtnRun.Id, self.IDs.cdrRun]:


Test patch:
Repository: psychopy/psychopy

Issue:
Windows seg fault when defaultView set to Runner



Discussion:

Resolving patch:
diff --git a/psychopy/app/pavlovia_ui/menu.py b/psychopy/app/pavlovia_ui/menu.py
--- a/psychopy/app/pavlovia_ui/menu.py
+++ b/psychopy/app/pavlovia_ui/menu.py
@@ -82,9 +82,9 @@ def onSetUser(self, event):
         self.setUser(user)
 
     def setUser(self, user=None):
-
-        if user is None and PavloviaMenu.appData['pavloviaUser']:
-            user = PavloviaMenu.appData['pavloviaUser']
+        if PavloviaMenu.appData:
+            if user is None and PavloviaMenu.appData['pavloviaUser']:
+                user = PavloviaMenu.appData['pavloviaUser']
 
         if user in [PavloviaMenu.currentUser, None]:
             return  # nothing to do here. Move along please.


Test patch:
Repository: psychopy/psychopy

Issue:
Adding line breaks in Builder
at least on win10, Open the Builder Stroop demo and run it. The intro screen displays \n\n text instead of line breaks. Opening the text component shows spaces. Help. ;)


Discussion:

Resolving patch:
diff --git a/psychopy/experiment/params.py b/psychopy/experiment/params.py
--- a/psychopy/experiment/params.py
+++ b/psychopy/experiment/params.py
@@ -198,7 +198,7 @@ def __str__(self):
                     if self.valType in ['file', 'table']:
                         # If param is a file of any kind, escape any \
                         val = re.sub(r"\\", r"\\\\", val)
-                    val=re.sub("\n", "\\\\n", val) # Replace line breaks with escaped line break character
+                    val=re.sub("\n", "\\n", val) # Replace line breaks with escaped line break character
                     return repr(val)
             return repr(self.val)
         elif self.valType in ['code', 'extendedCode']:


Test patch:
Repository: psychopy/psychopy

Issue:
Setting 'opacity' in stim constuctor has no effect
For example,

```
circle = visual.Circle(
            win,
            pos=(0, 0),
            lineWidth=3.0,
            lineColor=[255,0,0],
            colorSpace='rgb255',
            fillColor=[255,0,0],
            radius=50,
            units='pix',
            opacity=0,
            interpolate=False)
circle.draw()
```

draws a solid red circle, even though `opacity` = 0. However setting opacity after stim is created works:

```
circle.setOpacity(0)
```

does hide the circle. Also occurs in Line stim, all should probably be checked.




Discussion:

Resolving patch:
diff --git a/psychopy/visual/shape.py b/psychopy/visual/shape.py
--- a/psychopy/visual/shape.py
+++ b/psychopy/visual/shape.py
@@ -126,7 +126,6 @@ def __init__(self,
         super(BaseShapeStim, self).__init__(win, units=units,
                                             name=name, autoLog=False)
 
-        self.opacity = opacity
         self.pos = numpy.array(pos, float)
         self.closeShape = closeShape
         self.lineWidth = lineWidth
@@ -161,6 +160,7 @@ def __init__(self,
                             " Please use color and colorSpace args instead")
             self.setFillColor(fillRGB, colorSpace='rgb', log=None)
         self.contrast = contrast
+        self.opacity = opacity
 
         # Other stuff
         self.depth = depth


Test patch:
Repository: psychopy/psychopy

Issue:
App crashes when Coder context dlg cannot find context
At least that's what I think it is - if you open any file in Coder, type a name which doesn't exist and then a full stop, it crashes.


Discussion:
@TEParsons have you had time to look into this? Seems like something I can handle.
I've not, so yes please do!
How do I replicate this? I might be missing how this works.
Okay I figured this one out. I'll put a patch out. 

Resolving patch:
diff --git a/psychopy/app/coder/coder.py b/psychopy/app/coder/coder.py
--- a/psychopy/app/coder/coder.py
+++ b/psychopy/app/coder/coder.py
@@ -52,7 +52,7 @@
 
 try:
     import jedi
-    if jedi.__version__ < "0.15":
+    if jedi.__version__ < "0.16":
         logging.error(
                 "Need a newer version of package `jedi`. Currently using {}"
                 .format(jedi.__version__)
@@ -869,11 +869,13 @@ def ShowAutoCompleteList(self):
         if _hasJedi and self.getFileType() == 'Python':
             self.coder.SetStatusText(
                 'Retrieving code completions, please wait ...', 0)
-            # todo - create Script() periodically
-            compList = [i.name for i in jedi.Script(
-                self.getTextUptoCaret(),
+            script = jedi.Script(
+                self.GetText(),
                 path=self.filename if os.path.isabs(self.filename) else
-                None).completions(fuzzy=False)]
+                None)
+            # todo - create Script() periodically
+            compList = [i.name for i in script.complete(
+                self.caretLine + 1, self.caretColumn, fuzzy=False)]
             # todo - check if have a perfect match and veto AC
             self.coder.SetStatusText('', 0)
             if compList:


Test patch:
Repository: psychopy/psychopy

Issue:
API docs for slider mention 'scrollbar' style. Should be 'radio' style?
The line below mentions the 'scrollbar' style. In the code I notice there isn't a scrollbar style available, but there is a 'radio' style that isn't mentioned in the API docs. https://github.com/psychopy/psychopy/blob/a00b1f634001331f6638f5c8eeabb54dd3689b70/psychopy/visual/slider.py#L574


Discussion:

Resolving patch:
diff --git a/psychopy/experiment/components/slider/__init__.py b/psychopy/experiment/components/slider/__init__.py
--- a/psychopy/experiment/components/slider/__init__.py
+++ b/psychopy/experiment/components/slider/__init__.py
@@ -65,7 +65,7 @@ def __init__(self, exp, parentName,
                  flip=False,
                  style=['rating'],
                  granularity=0,
-                 color="LightGray",
+                 color="LightGrey",
                  fillColor='Red',
                  borderColor='White',
                  font="Open Sans",
@@ -78,6 +78,7 @@ def __init__(self, exp, parentName,
         super(SliderComponent, self).__init__(
                 exp, parentName, name,
                 pos=pos, size=size,
+                color=color, fillColor=fillColor, borderColor=borderColor,
                 startType=startType, startVal=startVal,
                 stopType=stopType, stopVal=stopVal,
                 startEstim=startEstim, durationEstim=durationEstim)
diff --git a/psychopy/visual/slider.py b/psychopy/visual/slider.py
--- a/psychopy/visual/slider.py
+++ b/psychopy/visual/slider.py
@@ -554,8 +554,8 @@ def getMouseResponses(self):
 
         self._mouseStateXY = xy
 
-    knownStyles = ['slider', 'rating', 'radio', 'labels45', 'whiteOnBlack',
-                   'triangleMarker']
+    knownStyles = ['slider', 'rating', 'radio', 'labels45',
+                   'triangleMarker', 'scrollbar']
 
     @attributeSetter
     def style(self, style):
@@ -648,3 +648,22 @@ def style(self, style):
             # marker must be smalle than a "tick" circle
             self.marker.size = self._tickL * 0.7
             self.marker.fillColor = self._fillColor.copy()
+
+        if 'scrollbar' in style:
+            # Make marker the full height and 20% of the width of the slider
+            markerWidth = self.size[0]*0.2
+            w, h = self.size
+            self.marker = Rect(self.win, units=self.units,
+                               size=[markerWidth, h],
+                               fillColor=self._fillColor,
+                               lineColor=None,
+                               autoLog=False)
+            # Make the line a translucent box
+            self.line = Rect(self.win, units=self.units,
+                             pos=self.pos,
+                             size=[w+markerWidth, h],
+                             fillColor=self._borderColor.copy(),
+                             lineColor=None,
+                             autoLog=False)
+            self.line._fillColor.alpha *= 0.05
+            self.tickLines = Rect(self.win, size=(0,0), lineColor=None, fillColor=None)
\ No newline at end of file


Test patch:
Repository: psychopy/psychopy

Issue:
Readme.txt window appears to have lost Ctrl-I/Cmd-I shortcut key to hide
Toggling the readme page for a Builder experiment no longer works (at least on mac).

Cmd-I will bring up the page but pressing again no longer gets rid of it.

I guess a new class has been created for the new markdown-supported frame, and this doesn't have the shortcut keys attached?


Discussion:
Yep that's exactly it, I actually didn't know about this shortcut so I didn't add it back in... Can do now!

Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -763,6 +763,7 @@ def fileExport(self, event=None, htmlPath=None):
         self.app.coder.fileOpen(filename=htmlPath)
 
     def editREADME(self, event):
+        self.showReadme()
         folder = Path(self.filename).parent
         if folder == folder.parent:
             raise FileNotFoundError("Please save experiment before editing the README file")
@@ -2502,10 +2503,15 @@ def makeMenus(self):
         menu = self.fileMenu
         keys = self.parent.app.keys
         menu.Append(wx.ID_EDIT, _translate("Edit"))
+        self.Bind(wx.EVT_MENU, self.fileEdit, id=wx.ID_EDIT)
         menu.Append(wx.ID_CLOSE,
                     _translate("&Close readme\t%s") % keys['close'])
-        self.Bind(wx.EVT_MENU, self.fileEdit, id=wx.ID_EDIT)
-        self.Bind(wx.EVT_MENU, self.toggleVisible, id=wx.ID_CLOSE)
+        item = self.Bind(wx.EVT_MENU, self.toggleVisible, id=wx.ID_CLOSE)
+        item = menu.Append(-1,
+                           _translate("&Toggle readme\t%s") % keys[
+                               'toggleReadme'],
+                           _translate("Toggle Readme"))
+        self.Bind(wx.EVT_MENU, self.toggleVisible, item)
         self.SetMenuBar(menuBar)
 
     def setFile(self, filename):
@@ -2549,6 +2555,10 @@ def setFile(self, filename):
         self.ctrl.SetPage(renderedText)
         self.SetTitle("%s readme (%s)" % (self.expName, filename))
 
+    def refresh(self, evt=None):
+        if hasattr(self, 'filename'):
+            self.setFile(self.filename)
+
     def fileEdit(self, evt=None):
         self.parent.app.showCoder()
         coder = self.parent.app.coder


Test patch: