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

Issue:
Bug with realtime_signals example
```
cyrille@Cyrille-ASUS:~/git/vispy/examples/demo/gloo$ python realtime_signals.py ERROR: Could not set variable 'a_position' with value [-0.0093575   0.1638512   0.15590386 ...,  0.07139178 -0.14649338
  0.06221156]
Traceback (most recent call last):
  File "realtime_signals.py", line 162, in <module>
    c = Canvas()
  File "realtime_signals.py", line 123, in __init__
    self.program['a_position'] = y.ravel()
  File "/home/cyrille/git/vispy/vispy/gloo/program.py", line 353, in __setitem__
    self._attributes[name].set_data(data)
  File "/home/cyrille/git/vispy/vispy/gloo/variable.py", line 326, in set_data
    assert count == data.shape[1]
IndexError: tuple index out of range
```



Discussion:
idem with spacy


Resolving patch:
diff --git a/examples/basics/gloo/post_processing.py b/examples/basics/gloo/post_processing.py
--- a/examples/basics/gloo/post_processing.py
+++ b/examples/basics/gloo/post_processing.py
@@ -131,13 +131,14 @@ def on_draw(self, event):
         set_state(depth_test=True)
         self.cube.draw('triangles', self.indices)
         self.framebuffer.deactivate()
+        set_viewport(0, 0, *self.size)
         clear(color=True)
         set_state(depth_test=False)
         self.quad.draw('triangle_strip')
 
     def on_resize(self, event):
         self._set_projection(event.size)
-
+    
     def _set_projection(self, size):
         width, height = size
         set_viewport(0, 0, width, height)
diff --git a/examples/demo/gloo/realtime_signals.py b/examples/demo/gloo/realtime_signals.py
--- a/examples/demo/gloo/realtime_signals.py
+++ b/examples/demo/gloo/realtime_signals.py
@@ -120,7 +120,7 @@ def __init__(self):
         app.Canvas.__init__(self, title='Use your wheel to zoom!', 
                             keys='interactive')
         self.program = gloo.Program(VERT_SHADER, FRAG_SHADER)
-        self.program['a_position'] = y.ravel()
+        self.program['a_position'] = y.reshape(-1, 1)
         self.program['a_color'] = color
         self.program['a_index'] = index
         self.program['u_scale'] = (1., 1.)
diff --git a/examples/demo/gloo/spacy.py b/examples/demo/gloo/spacy.py
--- a/examples/demo/gloo/spacy.py
+++ b/examples/demo/gloo/spacy.py
@@ -85,7 +85,7 @@ def __init__(self):
         
         # Set attributes
         self.program['a_position'] = np.zeros((N, 3), np.float32)
-        self.program['a_offset'] = np.zeros((N,), np.float32)
+        self.program['a_offset'] = np.zeros((N, 1), np.float32)
         
         # Init
         self._timeout = 0


Test patch:
Repository: vispy/vispy

Issue:
Bug when pressing a weird button on the keyboard
```
WARNING: Traceback (most recent call last):
  File ".\examples\demo\gloo\brain.py", line 156, in <module>
    app.run()
  File "D:\Git\vispy\vispy\app\_default_app.py", line 54, in run
    return default_app.run()
  File "D:\Git\vispy\vispy\app\application.py", line 88, in run
    return self._backend._vispy_run()
  File "D:\Git\vispy\vispy\app\backends\_qt.py", line 175, in _vispy_run
    return app.exec_()
  File "D:\Git\vispy\vispy\app\backends\_qt.py", line 391, in keyPressEvent
    self._keyEvent(self._vispy_canvas.events.key_press, ev)
  File "D:\Git\vispy\vispy\app\backends\_qt.py", line 406, in _keyEvent
    func(native=ev, key=key, text=text_type(ev.text()), modifiers=mod)
  File "D:\Git\vispy\vispy\util\event.py", line 418, in __call__
    self._invoke_callback(cb, event)
  File "D:\Git\vispy\vispy\util\event.py", line 446, in _invoke_callback
    self, cb_event=(cb, event))
  << caught exception here: >>
  File "D:\Git\vispy\vispy\util\event.py", line 435, in _invoke_callback
    cb(event)
  File "D:\Git\vispy\vispy\app\canvas.py", line 220, in keys_check
    use_name = event.key.name.lower()
AttributeError: 'NoneType' object has no attribute 'name'
WARNING: Error invoking callback <function keys_check at 0x00000000067C73C8> for
 event: <KeyEvent blocked=False handled=False key=None modifiers=() native=<PyQt
4.QtGui.QKeyEvent object at 0x0000000007230BF8> source=<Vispy canvas (PyQt4 (qt)
 backend) at 0x72a10f0L> sources=[<Vispy canvas (PyQt4 (qt) backend) at 0x72a10f
0L>] text=² type=key_press>
```



Discussion:
Yep, I've seen that before, too. Haven't gotten around to fixing it, feel free if you have time.

Yep, I've seen that before, too. Haven't gotten around to fixing it, feel free if you have time.


Resolving patch:
diff --git a/vispy/app/canvas.py b/vispy/app/canvas.py
--- a/vispy/app/canvas.py
+++ b/vispy/app/canvas.py
@@ -217,9 +217,10 @@ def toggle_fs():
             self._keys_check = keys
 
             def keys_check(event):
-                use_name = event.key.name.lower()
-                if use_name in self._keys_check:
-                    self._keys_check[use_name]()
+                if event.key is not None:
+                    use_name = event.key.name.lower()
+                    if use_name in self._keys_check:
+                        self._keys_check[use_name]()
             self.events.key_press.connect(keys_check, ref=True)
 
     @property


Test patch:
Repository: vispy/vispy

Issue:
GLFW Switches Directories on Initialization
Other backends preserve the current working directory, but GLFW switches it (to the root of Python.app on OSX).  This is a feature apparently:
https://github.com/glfw/glfw/issues/174

Since we can't control how users compile GLFW, I propose saving the directory and restoring it after init to make sure this backend is consistent with others.  (IMHO, working directories should not be changed.)

Thoughts?



Discussion:
+1


Resolving patch:
diff --git a/vispy/app/backends/_glfw.py b/vispy/app/backends/_glfw.py
--- a/vispy/app/backends/_glfw.py
+++ b/vispy/app/backends/_glfw.py
@@ -21,6 +21,7 @@
 import atexit
 from time import sleep
 import gc
+import os
 
 from ..base import (BaseApplicationBackend, BaseCanvasBackend,
                     BaseTimerBackend)
@@ -198,8 +199,12 @@ def _vispy_quit(self):
     def _vispy_get_native_app(self):
         global _GLFW_INITIALIZED
         if not _GLFW_INITIALIZED:
-            if not glfw.glfwInit():  # only ever call once
-                raise OSError('Could not init glfw')
+            cwd = os.getcwd()
+            try:
+                if not glfw.glfwInit():  # only ever call once
+                    raise OSError('Could not init glfw')
+            finally:
+                os.chdir(cwd)
             atexit.register(glfw.glfwTerminate)
             _GLFW_INITIALIZED = True
         return glfw


Test patch:
Repository: vispy/vispy

Issue:
Implement reusable GLSL functions for color space transformations
At least RGB <-> HSV. Put them in `vispy.visuals.glsl`.



Discussion:
See http://www.chilliant.com/rgb2hsv.html


Resolving patch:
diff --git a/vispy/visuals/glsl/color.py b/vispy/visuals/glsl/color.py
--- a/vispy/visuals/glsl/color.py
+++ b/vispy/visuals/glsl/color.py
@@ -38,3 +38,33 @@
     return texture2D($colormap, vec2(x, .5)).rgb;
 }
 """
+
+
+# -----------------------------------------------------------------------------
+# Color space transformations
+# -----------------------------------------------------------------------------
+
+# From http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl
+# TODO: unit tests
+HSV_TO_RGB = """
+vec3 hsv_to_rgb(vec3 c)
+{
+    vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+"""
+
+
+RGB_TO_HSV = """
+vec3 rgb_to_hsv(vec3 c)
+{
+    vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
+    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
+    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
+
+    float d = q.x - min(q.w, q.y);
+    float e = 1.0e-10;
+    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
+}
+"""


Test patch:
Repository: vispy/vispy

Issue:
vispy.plot.image fails on float64 textures



Discussion:

Resolving patch:
diff --git a/vispy/visuals/image.py b/vispy/visuals/image.py
--- a/vispy/visuals/image.py
+++ b/vispy/visuals/image.py
@@ -28,8 +28,8 @@ class ImageVisual(ModularMesh):
 
             * 'subdivide': ImageVisual is represented as a grid of triangles
               with texture coordinates linearly mapped.
-            * 'impostor': ImageVisual is represented as a quad covering the 
-              entire view, with texture coordinates determined by the 
+            * 'impostor': ImageVisual is represented as a quad covering the
+              entire view, with texture coordinates determined by the
               transform. This produces the best transformation results, but may
               be slow.
 
@@ -55,6 +55,9 @@ def __init__(self, data, method='subdivide', grid=(10, 10), **kwargs):
 
     def set_data(self, image=None, **kwds):
         if image is not None:
+            image = np.array(image, copy=False)
+            if image.dtype == np.float64:
+                image = image.astype(np.float32)
             self._data = image
             self._texture = None
         super(ImageVisual, self).set_data(**kwds)


Test patch:
Repository: vispy/vispy

Issue:
Text is misplaced in scene/console example
![cdg3](https://cloud.githubusercontent.com/assets/940580/6873155/a27d28da-d4ae-11e4-9a79-b638389294e5.jpg)



Discussion:
Possibly related problems in scene/markers and scene/grid_large

`git bisect` says @almarklein should check this commit:

https://github.com/vispy/vispy/commit/597698ad0c8054a02adf8280b5a4780d180ae210

As @nippoo just said, "commit a little, commit often"...


Resolving patch:
diff --git a/examples/basics/scene/console.py b/examples/basics/scene/console.py
--- a/examples/basics/scene/console.py
+++ b/examples/basics/scene/console.py
@@ -18,6 +18,7 @@
 grid = canvas.central_widget.add_grid()
 
 vb = scene.widgets.ViewBox(border_color='b')
+vb.camera = 'panzoom'
 vb.camera.rect = -1, -1, 2, 2
 grid.add_widget(vb, row=0, col=0)
 text = Text('Starting timer...', color='w', font_size=24, parent=vb.scene)
diff --git a/examples/basics/scene/grid.py b/examples/basics/scene/grid.py
--- a/examples/basics/scene/grid.py
+++ b/examples/basics/scene/grid.py
@@ -23,16 +23,19 @@
 
 # Add 3 ViewBoxes to the grid
 b1 = grid.add_view(row=0, col=0, col_span=2)
+b1.camera = 'panzoom'
 b1.border_color = (0.5, 0.5, 0.5, 1)
 b1.camera = scene.PanZoomCamera(rect=(-0.5, -5, 11, 10))
 b1.border = (1, 0, 0, 1)
 
 b2 = grid.add_view(row=1, col=0)
+b2.camera = 'panzoom'
 b2.border_color = (0.5, 0.5, 0.5, 1)
 b2.camera = scene.PanZoomCamera(rect=(-10, -5, 15, 10))
 b2.border = (1, 0, 0, 1)
 
 b3 = grid.add_view(row=1, col=1)
+b3.camera = 'panzoom'
 b3.border_color = (0.5, 0.5, 0.5, 1)
 b3.camera = scene.PanZoomCamera(rect=(-5, -5, 10, 10))
 b3.border = (1, 0, 0, 1)
diff --git a/examples/basics/scene/grid_large.py b/examples/basics/scene/grid_large.py
--- a/examples/basics/scene/grid_large.py
+++ b/examples/basics/scene/grid_large.py
@@ -26,6 +26,7 @@
     lines.append([])
     for j in range(10):
         vb = grid.add_view(row=i, col=j)
+        vb.camera = 'panzoom'
         vb.camera.rect = (0, -5), (100, 10)
         vb.border = (1, 1, 1, 0.4)
 


Test patch:
Repository: vispy/vispy

Issue:
Vispy Windows XP Compatibility
When trying to run a Vispy Application in windows xp project will not start due to fault "Attribute Error: function 'SetProcessDPIAware' not found".  First instance traced back to "vispy\ext\gdi32plus.py line 165"  this line was commented out and program ran again and produced the same fault but pointed at "vispy\util\dpi_win32.py line 13" this line was also commented out and the program finally loaded.  Exhaustive testing is not yet complete but program is basically functional.

It appears the "SetProcessDPIAware" API is not supported in windows XP and only partially supported in windows vista and later, see....  https://msdn.microsoft.com/en-us/library/dn469266(v=vs.85).aspx and .... https://msdn.microsoft.com/en-us/library/dn302122(v=vs.85).aspx.

Further testing needs to be done to see whether Vispy is obtaining proper DPI settings.  
reference: http://www.experts-exchange.com/Programming/Languages/Scripting/Python/Q_21794611.html



Discussion:
Thanks for the report! Seems like you have a decent handle on the issues -- are you up for submitting a fix?

The easiest (and crappiest) solution would just be to detect XP's presence, and not use the selected functions in that case, returning some sensible default (e.g. 92 or 96). We could start there, and later add more complete support, or just add more complete/better support from the start, depending on your willingness to pursue this. I'm happy to help or even fix it myself if you're not up for it.

FWIW Vispy is able to get the DPI from my machine running Windows 8.1. I haven't tested it on other operating systems, since that's all I have easy access to right now. Perhaps @rossant has?

No I just have a Windows 8.1 machine (and Windows 10 preview in a VM).

You'll see on gitter some pointers on how to possibly update the code so that it also work with XP (but this requires more testing on XP).


Resolving patch:
diff --git a/vispy/ext/gdi32plus.py b/vispy/ext/gdi32plus.py
--- a/vispy/ext/gdi32plus.py
+++ b/vispy/ext/gdi32plus.py
@@ -162,7 +162,10 @@ class LOGFONT(Structure):
 
 user32.ReleaseDC.argtypes = [c_void_p, HDC]
 
-user32.SetProcessDPIAware.argtypes = []
+try:
+    user32.SetProcessDPIAware.argtypes = []
+except AttributeError:
+    pass  # not present on XP
 
 
 # gdiplus
diff --git a/vispy/util/dpi/_win32.py b/vispy/util/dpi/_win32.py
--- a/vispy/util/dpi/_win32.py
+++ b/vispy/util/dpi/_win32.py
@@ -10,7 +10,10 @@
 
 def get_dpi():
     """Get screen DPI from the OS"""
-    user32.SetProcessDPIAware()
+    try:
+        user32.SetProcessDPIAware()
+    except AttributeError:
+        pass  # not present on XP
     dc = user32.GetDC(0)
     h_size = gdi32.GetDeviceCaps(dc, HORZSIZE)
     v_size = gdi32.GetDeviceCaps(dc, VERTSIZE)


Test patch:
Repository: vispy/vispy

Issue:
Focus problem in Qt
When embedding a VisPy canvas in a QMainWindow dock widget, the keyboard events are not received by VisPy. It might be a focus problem. You can test this in the primitive_qt_viewer example, by implement an `on_key_press` event in the canvas. Any ideas?



Discussion:

Resolving patch:
diff --git a/vispy/app/backends/_qt.py b/vispy/app/backends/_qt.py
--- a/vispy/app/backends/_qt.py
+++ b/vispy/app/backends/_qt.py
@@ -579,6 +579,7 @@ def _init_specific(self, p, kwargs):
         if not self.isValid():
             raise RuntimeError('context could not be created')
         self.setAutoBufferSwap(False)  # to make consistent with other backends
+        self.setFocusPolicy(QtCore.Qt.WheelFocus)
 
     def _vispy_close(self):
         # Force the window or widget to shut down


Test patch:
Repository: vispy/vispy

Issue:
Importing gloo should not automatically load the OpenGL library
I'm trying to run vispy on a headless server with docker, to use the ipynb webgl backend exclusively. I cannot `import vispy.gloo`:

```
  File "/opt/conda/lib/python3.4/site-packages/vispy/gloo/__init__.py", line 47, in <module>
    from . import gl  # noqa
  File "/opt/conda/lib/python3.4/site-packages/vispy/gloo/gl/__init__.py", line 213, in <module>
    from . import gl2 as default_backend  # noqa
  File "/opt/conda/lib/python3.4/site-packages/vispy/gloo/gl/gl2.py", line 46, in <module>
    raise RuntimeError('Could not load OpenGL library.')
RuntimeError: Could not load OpenGL library.
```

I should not need to have the OpenGL library on a headless server when using a remote backend.



Discussion:
I think it should be fine to not have this happen. It will probably mean nesting some `from . import gl` calls. Do you have time to fix it?

Not sure i'll have time in the near future.. for now i just install the libs and it works, but it would be nice to have it fixed eventually!


Resolving patch:
diff --git a/vispy/gloo/gl/gl2.py b/vispy/gloo/gl/gl2.py
--- a/vispy/gloo/gl/gl2.py
+++ b/vispy/gloo/gl/gl2.py
@@ -11,6 +11,7 @@
 
 from . import _copy_gl_functions
 from ._constants import *  # noqa
+from ...util import logger
 
 # Ctypes stuff
 
@@ -43,9 +44,11 @@
     else:
         _fname = ctypes.util.find_library('GL')
     if not _fname:
-        raise RuntimeError('Could not load OpenGL library.')
-    # Load lib
-    _lib = ctypes.cdll.LoadLibrary(_fname)
+        logger.warning('Could not load OpenGL library.')
+        _lib = None
+    else:
+        # Load lib
+        _lib = ctypes.cdll.LoadLibrary(_fname)
 
 
 def _have_context():
@@ -62,6 +65,8 @@ def _get_gl_version(_lib):
 
 def _get_gl_func(name, restype, argtypes):
     # Based on a function in Pyglet
+    if _lib is None:
+        raise RuntimeError('Could not load OpenGL library, gl cannot be used')
     try:
         # Try using normal ctypes stuff
         func = getattr(_lib, name)


Test patch:
Repository: vispy/vispy

Issue:
Problem with turn ans shift key event
In a Canvas with a turnable Camera, if you try to make a left click to turn the mesh and if you maintain the left click and after you press shift key you are an error message.

Problem with turn ans shift key event
In a Canvas with a turnable Camera, if you try to make a left click to turn the mesh and if you maintain the left click and after you press shift key you are an error message.



Discussion:

Resolving patch:
diff --git a/vispy/scene/cameras/cameras.py b/vispy/scene/cameras/cameras.py
--- a/vispy/scene/cameras/cameras.py
+++ b/vispy/scene/cameras/cameras.py
@@ -1003,7 +1003,7 @@ def viewbox_mouse_event(self, event):
             elif 1 in event.buttons and keys.SHIFT in modifiers:
                 # Translate
                 norm = np.mean(self._viewbox.size)
-                if self._event_value is None:
+                if self._event_value is None or len(self._event_value) == 2:
                     self._event_value = self.center
                 dist = (p1 - p2) / norm * self._scale_factor
                 dist[1] *= -1


Test patch:
Repository: vispy/vispy

Issue:
mpl_plot example no longer works
This example currently shows the background and axes, but nothing within.
![screenshot from 2015-06-02 23-12-15](https://cloud.githubusercontent.com/assets/302469/7952015/e9301e06-097c-11e5-9a8b-acc3f6a40a44.png)



Discussion:
If you aren't sick of debugging and contributing to `vispy`, you can use [git bisect](http://webchick.net/node/99) to figure out whose fault it is :) Otherwise I can try to get to it in the next few days.

```
a3da64aff000a857c94cc5e93fd83bdb8a24a9c2 is the first bad commit
commit a3da64aff000a857c94cc5e93fd83bdb8a24a9c2
Author: Eric Larson
Date:   Tue May 19 14:17:09 2015 -0700

    FIX: Fix background colors

:040000 040000 6f29bdb23d600a8aa29cee399b7f6a5a73133b30 626fe043168886ed882b07614db468b60f21311d M  examples
:040000 040000 edc6f6888b53f0cdaf862bcba5edcb347b53fd08 02e8b446164ede9c232fa4910fe7d04591bc2322 M  vispy
```

Oh great :) That was a commit that should have fixed how ViewBox backgrounds got drawn. Somehow it must be getting drawn out of order. I'll try to look soon.


Resolving patch:
diff --git a/vispy/mpl_plot/_mpl_to_vispy.py b/vispy/mpl_plot/_mpl_to_vispy.py
--- a/vispy/mpl_plot/_mpl_to_vispy.py
+++ b/vispy/mpl_plot/_mpl_to_vispy.py
@@ -65,7 +65,6 @@ def open_axes(self, ax, props):
         #    a['position']  # add borders
         vb = ViewBox(parent=self.canvas.scene, border_color='black',
                      bgcolor=props['axesbg'])
-        vb.clip_method = 'fbo'  # necessary for bgcolor
         vb.camera = PanZoomCamera()
         vb.camera.set_range(xlim, ylim, margin=0)
         ax_dict = dict(ax=ax, bounds=bounds, vb=vb, lims=xlim+ylim)


Test patch:
Repository: vispy/vispy

Issue:
docs error - should be PyQt5
was reading [config.py ](https://github.com/vispy/vispy/blob/75b683ed080440e881a2d0066b9ce182f4217569/vispy/util/config.py#L97), and I think it should be `pyqt4|pyqt5|...` rather that `pyt5` 

line no. 97 



Discussion:
yes indeed, please fix in your next PR :)


Resolving patch:
diff --git a/vispy/util/config.py b/vispy/util/config.py
--- a/vispy/util/config.py
+++ b/vispy/util/config.py
@@ -94,7 +94,7 @@ def _init():
 VISPY_HELP = """
 VisPy command line arguments:
 
-  --vispy-backend=(qt|pyqt4|pyt5|pyside|glfw|pyglet|sdl2|wx)
+  --vispy-backend=(qt|pyqt4|pyqt5|pyside|glfw|pyglet|sdl2|wx)
     Selects the backend system for VisPy to use. This will override the default
     backend selection in your configuration file.
 


Test patch:
Repository: vispy/vispy

Issue:
IPython WebGL Examples not working.
The IPython notebook examples are not working with the latest IPython(Jupyter) 4.0 release.



Discussion:
I', trying the vispy notebook widget running locally on my latop (python3, latest jupyter+ipthon from git) . The `webgl_example_1.ipynb` shows a black empty canvas and  the following log is printed in the output sell :  

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: events_received() takes 3 positional arguments but 4 were given

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: events_received() takes 3 positional arguments but 4 were given

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: events_received() takes 3 positional arguments but 4 were given
```

while in `webgl_example_2.ipynb`  i got the cloud of points visualized correctly, the start/stop timer commands also works fine, but it still print out the same error log in the output cell : 

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: events_received() takes 3 positional arguments but 4 were given

---------------------------------------------------------------------------

...
...
...
...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
TypeError: events_received() takes 3 positional arguments but 4 were given

---------------------------------------------------------------------------
```

**note**: this is running locally on a laptop (osx)

The same settings (software version) on  a remote server running debian i got this log :  

```
WARNING: could not determine DPI
WARNING:vispy:could not determine DPI

xdpyinfo:  unable to open display "".


Can't open display 
```

there is an issue for this [here](https://github.com/vispy/vispy/issues/1047)


Resolving patch:
diff --git a/vispy/app/backends/ipython/_widget.py b/vispy/app/backends/ipython/_widget.py
--- a/vispy/app/backends/ipython/_widget.py
+++ b/vispy/app/backends/ipython/_widget.py
@@ -57,7 +57,10 @@ def set_canvas(self, canvas):
         self.gen_event = self.canvas_backend._gen_event
         #setup the backend widget then.
 
-    def events_received(self, _, msg):
+    # In IPython < 4, these callbacks are given two arguments; in
+    # IPython/jupyter 4, they take 3. events_received is variadic to
+    # accommodate both cases.
+    def events_received(self, _, msg, *args):
         if msg['msg_type'] == 'init':
             self.canvas_backend._reinit_widget()
         elif msg['msg_type'] == 'events':


Test patch: