prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  The first emitted Timer event has `None` as `dt` property
  ``` python
  def on_timer(self, event):
      print event.dt
  ```
  
  displays `None` the first time, and the correct dt then (a float). The first dt should probably be `0.0`.
  
  
  </issue>
  <code>
  [start of vispy/app/timer.py]
  1 # -*- coding: utf-8 -*-
  2 # Copyright (c) 2014, Vispy Development Team.
  3 # Distributed under the (new) BSD License. See LICENSE.txt for more info.
  4 
  5 from __future__ import division
  6 
  7 from ..util.event import Event, EmitterGroup
  8 from ..util.ptime import time as precision_time
  9 from ..ext.six import string_types
  10 from .base import BaseTimerBackend as TimerBackend  # noqa
  11 from . import use_app, Application
  12 
  13 
  14 class Timer(object):
  15 
  16     """Timer used to schedule events in the future or on a repeating schedule
  17 
  18     Parameters
  19     ----------
  20     interval : float
  21         Time between events.
  22     connect : function | None
  23         The function to call.
  24     iterations : int
  25         Number of iterations. Can be -1 for infinite.
  26     start : bool
  27         Whether to start the timer.
  28     app : instance of vispy.app.Application
  29         The application to attach the timer to.
  30     """
  31 
  32     def __init__(self, interval=0.0, connect=None, iterations=-1, start=False,
  33                  app=None):
  34         self.events = EmitterGroup(source=self,
  35                                    start=Event,
  36                                    stop=Event,
  37                                    timeout=Event)
  38         #self.connect = self.events.timeout.connect
  39         #self.disconnect = self.events.timeout.disconnect
  40 
  41         # Get app instance
  42         if app is None:
  43             self._app = use_app()
  44         elif isinstance(app, Application):
  45             self._app = app
  46         elif isinstance(app, string_types):
  47             self._app = Application(app)
  48         else:
  49             raise ValueError('Invalid value for app %r' % app)
  50         
  51         # Ensure app has backend app object
  52         self._app.native
  53         
  54         # Instantiate the backed with the right class
  55         self._backend = self._app.backend_module.TimerBackend(self)
  56 
  57         self._interval = interval
  58         self._running = False
  59         self._last_emit_time = None
  60         self.iter_count = 0
  61         self.max_iterations = iterations
  62         if connect is not None:
  63             self.connect(connect)
  64         if start:
  65             self.start()
  66 
  67     @property
  68     def app(self):
  69         """ The vispy Application instance on which this Timer is based.
  70         """
  71         return self._app
  72 
  73     @property
  74     def interval(self):
  75         return self._interval
  76 
  77     @interval.setter
  78     def interval(self, val):
  79         self._interval = val
  80         if self.running:
  81             self.stop()
  82             self.start()
  83 
  84     @property
  85     def running(self):
  86         return self._running
  87 
  88     def start(self, interval=None, iterations=None):
  89         """Start the timer.
  90 
  91         A timeout event will be generated every *interval* seconds.
  92         If *interval* is None, then self.interval will be used.
  93 
  94         If *iterations* is specified, the timer will stop after
  95         emitting that number of events. If unspecified, then
  96         the previous value of self.iterations will be used. If the value is
  97         negative, then the timer will continue running until stop() is called.
  98         """
  99         self.iter_count = 0
  100         if interval is not None:
  101             self.interval = interval
  102         if iterations is not None:
  103             self.max_iterations = iterations
  104         self._backend._vispy_start(self.interval)
  105         self._running = True
  106         self._last_emit_time = None
  107         self.events.start(type='timer_start')
  108 
  109     def stop(self):
  110         """Stop the timer."""
  111         self._backend._vispy_stop()
  112         self._running = False
  113         self.events.stop(type='timer_stop')
  114 
  115     # use timer.app.run() and .quit() instead.
  116     # def run_event_loop(self):
  117         #"""Execute the event loop for this Timer's backend.
  118         #"""
  119         # return self._backend._vispy_run()
  120 
  121     # def quit_event_loop(self):
  122         #"""Exit the event loop for this Timer's backend.
  123         #"""
  124         # return self._backend._vispy_quit()
  125 
  126     @property
  127     def native(self):
  128         """ The native timer on which this Timer is based.
  129         """
  130         return self._backend._vispy_get_native_timer()
  131 
  132     def _timeout(self, *args):
  133         # called when the backend timer has triggered.
  134         if not self.running:
  135             return
  136         if self.max_iterations >= 0 and self.iter_count >= self.max_iterations:
  137             self.stop()
  138             return
  139 
  140         # compute dt since last event
  141         now = precision_time()
  142         if self._last_emit_time is None:
  143             dt = None
  144         else:
  145             dt = now - self._last_emit_time
  146         self._last_emit_time = now
  147 
  148         self.events.timeout(
  149             type='timer_timeout',
  150             iteration=self.iter_count,
  151             dt=dt)
  152         self.iter_count += 1
  153 
  154     def connect(self, callback):
  155         """ Alias for self.events.timeout.connect() """
  156         return self.events.timeout.connect(callback)
  157 
  158     def disconnect(self, callback=None):
  159         """ Alias for self.events.timeout.disconnect() """
  160         return self.events.timeout.disconnect(callback)
  161
  [end of vispy/app/timer.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/vispy/app/timer.py b/vispy/app/timer.py
  --- a/vispy/app/timer.py
  +++ b/vispy/app/timer.py
  @@ -103,7 +103,7 @@
               self.max_iterations = iterations
           self._backend._vispy_start(self.interval)
           self._running = True
  -        self._last_emit_time = None
  +        self._last_emit_time = precision_time()
           self.events.start(type='timer_start')
   
       def stop(self):
  @@ -139,10 +139,7 @@
   
           # compute dt since last event
           now = precision_time()
  -        if self._last_emit_time is None:
  -            dt = None
  -        else:
  -            dt = now - self._last_emit_time
  +        dt = now - self._last_emit_time
           self._last_emit_time = now
   
           self.events.timeout(
  
verification_info: {"golden_diff": "diff --git a/vispy/app/timer.py b/vispy/app/timer.py\n--- a/vispy/app/timer.py\n+++ b/vispy/app/timer.py\n@@ -103,7 +103,7 @@\n             self.max_iterations = iterations\n         self._backend._vispy_start(self.interval)\n         self._running = True\n-        self._last_emit_time = None\n+        self._last_emit_time = precision_time()\n         self.events.start(type='timer_start')\n \n     def stop(self):\n@@ -139,10 +139,7 @@\n \n         # compute dt since last event\n         now = precision_time()\n-        if self._last_emit_time is None:\n-            dt = None\n-        else:\n-            dt = now - self._last_emit_time\n+        dt = now - self._last_emit_time\n         self._last_emit_time = now\n \n         self.events.timeout(\n", "issue": "The first emitted Timer event has `None` as `dt` property\n``` python\ndef on_timer(self, event):\n    print event.dt\n```\n\ndisplays `None` the first time, and the correct dt then (a float). The first dt should probably be `0.0`.\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2014, Vispy Development Team.\n# Distributed under the (new) BSD License. See LICENSE.txt for more info.\n\nfrom __future__ import division\n\nfrom ..util.event import Event, EmitterGroup\nfrom ..util.ptime import time as precision_time\nfrom ..ext.six import string_types\nfrom .base import BaseTimerBackend as TimerBackend  # noqa\nfrom . import use_app, Application\n\n\nclass Timer(object):\n\n    \"\"\"Timer used to schedule events in the future or on a repeating schedule\n\n    Parameters\n    ----------\n    interval : float\n        Time between events.\n    connect : function | None\n        The function to call.\n    iterations : int\n        Number of iterations. Can be -1 for infinite.\n    start : bool\n        Whether to start the timer.\n    app : instance of vispy.app.Application\n        The application to attach the timer to.\n    \"\"\"\n\n    def __init__(self, interval=0.0, connect=None, iterations=-1, start=False,\n                 app=None):\n        self.events = EmitterGroup(source=self,\n                                   start=Event,\n                                   stop=Event,\n                                   timeout=Event)\n        #self.connect = self.events.timeout.connect\n        #self.disconnect = self.events.timeout.disconnect\n\n        # Get app instance\n        if app is None:\n            self._app = use_app()\n        elif isinstance(app, Application):\n            self._app = app\n        elif isinstance(app, string_types):\n            self._app = Application(app)\n        else:\n            raise ValueError('Invalid value for app %r' % app)\n        \n        # Ensure app has backend app object\n        self._app.native\n        \n        # Instantiate the backed with the right class\n        self._backend = self._app.backend_module.TimerBackend(self)\n\n        self._interval = interval\n        self._running = False\n        self._last_emit_time = None\n        self.iter_count = 0\n        self.max_iterations = iterations\n        if connect is not None:\n            self.connect(connect)\n        if start:\n            self.start()\n\n    @property\n    def app(self):\n        \"\"\" The vispy Application instance on which this Timer is based.\n        \"\"\"\n        return self._app\n\n    @property\n    def interval(self):\n        return self._interval\n\n    @interval.setter\n    def interval(self, val):\n        self._interval = val\n        if self.running:\n            self.stop()\n            self.start()\n\n    @property\n    def running(self):\n        return self._running\n\n    def start(self, interval=None, iterations=None):\n        \"\"\"Start the timer.\n\n        A timeout event will be generated every *interval* seconds.\n        If *interval* is None, then self.interval will be used.\n\n        If *iterations* is specified, the timer will stop after\n        emitting that number of events. If unspecified, then\n        the previous value of self.iterations will be used. If the value is\n        negative, then the timer will continue running until stop() is called.\n        \"\"\"\n        self.iter_count = 0\n        if interval is not None:\n            self.interval = interval\n        if iterations is not None:\n            self.max_iterations = iterations\n        self._backend._vispy_start(self.interval)\n        self._running = True\n        self._last_emit_time = None\n        self.events.start(type='timer_start')\n\n    def stop(self):\n        \"\"\"Stop the timer.\"\"\"\n        self._backend._vispy_stop()\n        self._running = False\n        self.events.stop(type='timer_stop')\n\n    # use timer.app.run() and .quit() instead.\n    # def run_event_loop(self):\n        #\"\"\"Execute the event loop for this Timer's backend.\n        #\"\"\"\n        # return self._backend._vispy_run()\n\n    # def quit_event_loop(self):\n        #\"\"\"Exit the event loop for this Timer's backend.\n        #\"\"\"\n        # return self._backend._vispy_quit()\n\n    @property\n    def native(self):\n        \"\"\" The native timer on which this Timer is based.\n        \"\"\"\n        return self._backend._vispy_get_native_timer()\n\n    def _timeout(self, *args):\n        # called when the backend timer has triggered.\n        if not self.running:\n            return\n        if self.max_iterations >= 0 and self.iter_count >= self.max_iterations:\n            self.stop()\n            return\n\n        # compute dt since last event\n        now = precision_time()\n        if self._last_emit_time is None:\n            dt = None\n        else:\n            dt = now - self._last_emit_time\n        self._last_emit_time = now\n\n        self.events.timeout(\n            type='timer_timeout',\n            iteration=self.iter_count,\n            dt=dt)\n        self.iter_count += 1\n\n    def connect(self, callback):\n        \"\"\" Alias for self.events.timeout.connect() \"\"\"\n        return self.events.timeout.connect(callback)\n\n    def disconnect(self, callback=None):\n        \"\"\" Alias for self.events.timeout.disconnect() \"\"\"\n        return self.events.timeout.disconnect(callback)\n", "path": "vispy/app/timer.py"}]}