prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Consider not writing in user home
  All the images (starting from base notebook) write part of the configuration inside the user home folder, and assume that `/home/$NB_USER/work` will be mounted. This has a practical limitation that it is not easy to setup a hub such that useful folders like `.ssh`, or e.g. `.bash_history` persist across container restarts.
  
  I might be missing underlying assumptions and use cases, but I suggest to assume that home itself would be mounted, and instead modify the global configuration options.
  
  </issue>
  <code>
  [start of scipy-notebook/mplimporthook.py]
  1 """Startup script for IPython kernel.
  2 
  3 Installs an import hook to configure the matplotlib backend on the fly.
  4 
  5 Originally from @minrk at 
  6 https://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py
  7 Repurposed for docker-stacks to address repeat bugs like
  8 https://github.com/jupyter/docker-stacks/issues/235.
  9 """
  10 import sys
  11 from IPython import get_ipython
  12 
  13 class MatplotlibFinder(object):
  14     """Import hook that notices when matplotlib.pyplot or pylab is imported
  15     and tries to configure the matplotlib backend appropriately for the
  16     environment.
  17     """
  18     _called = False
  19     
  20     def find_module(self, fullname, path=None):
  21         if self._called:
  22             # already handled
  23             return
  24         
  25         if fullname not in ('pylab', 'matplotlib.pyplot'):
  26             # not matplotlib
  27             return
  28         
  29         # don't call me again
  30         self._called = True
  31         
  32         try:
  33             # remove myself from the import hooks
  34             sys.meta_path = [loader for loader in sys.meta_path if loader is not self]
  35         except ValueError:
  36             pass
  37         
  38         ip = get_ipython()
  39         if ip is None:
  40             # not in an interactive environment
  41             return
  42             
  43         if ip.pylab_gui_select:
  44             # backend already selected
  45             return
  46             
  47         if hasattr(ip, 'kernel'):
  48             # default to inline in kernel environments
  49             ip.enable_matplotlib('inline')
  50         else:
  51             print('enabling matplotlib')
  52             ip.enable_matplotlib()
  53 
  54 # install the finder immediately
  55 sys.meta_path.insert(0, MatplotlibFinder())
  [end of scipy-notebook/mplimporthook.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/scipy-notebook/mplimporthook.py b/scipy-notebook/mplimporthook.py
  deleted file mode 100644
  --- a/scipy-notebook/mplimporthook.py
  +++ /dev/null
  @@ -1,55 +0,0 @@
  -"""Startup script for IPython kernel.
  -
  -Installs an import hook to configure the matplotlib backend on the fly.
  -
  -Originally from @minrk at 
  -https://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py
  -Repurposed for docker-stacks to address repeat bugs like
  -https://github.com/jupyter/docker-stacks/issues/235.
  -"""
  -import sys
  -from IPython import get_ipython
  -
  -class MatplotlibFinder(object):
  -    """Import hook that notices when matplotlib.pyplot or pylab is imported
  -    and tries to configure the matplotlib backend appropriately for the
  -    environment.
  -    """
  -    _called = False
  -    
  -    def find_module(self, fullname, path=None):
  -        if self._called:
  -            # already handled
  -            return
  -        
  -        if fullname not in ('pylab', 'matplotlib.pyplot'):
  -            # not matplotlib
  -            return
  -        
  -        # don't call me again
  -        self._called = True
  -        
  -        try:
  -            # remove myself from the import hooks
  -            sys.meta_path = [loader for loader in sys.meta_path if loader is not self]
  -        except ValueError:
  -            pass
  -        
  -        ip = get_ipython()
  -        if ip is None:
  -            # not in an interactive environment
  -            return
  -            
  -        if ip.pylab_gui_select:
  -            # backend already selected
  -            return
  -            
  -        if hasattr(ip, 'kernel'):
  -            # default to inline in kernel environments
  -            ip.enable_matplotlib('inline')
  -        else:
  -            print('enabling matplotlib')
  -            ip.enable_matplotlib()
  -
  -# install the finder immediately
  -sys.meta_path.insert(0, MatplotlibFinder())
  \ No newline at end of file
  
verification_info: {"golden_diff": "diff --git a/scipy-notebook/mplimporthook.py b/scipy-notebook/mplimporthook.py\ndeleted file mode 100644\n--- a/scipy-notebook/mplimporthook.py\n+++ /dev/null\n@@ -1,55 +0,0 @@\n-\"\"\"Startup script for IPython kernel.\n-\n-Installs an import hook to configure the matplotlib backend on the fly.\n-\n-Originally from @minrk at \n-https://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py\n-Repurposed for docker-stacks to address repeat bugs like\n-https://github.com/jupyter/docker-stacks/issues/235.\n-\"\"\"\n-import sys\n-from IPython import get_ipython\n-\n-class MatplotlibFinder(object):\n-    \"\"\"Import hook that notices when matplotlib.pyplot or pylab is imported\n-    and tries to configure the matplotlib backend appropriately for the\n-    environment.\n-    \"\"\"\n-    _called = False\n-    \n-    def find_module(self, fullname, path=None):\n-        if self._called:\n-            # already handled\n-            return\n-        \n-        if fullname not in ('pylab', 'matplotlib.pyplot'):\n-            # not matplotlib\n-            return\n-        \n-        # don't call me again\n-        self._called = True\n-        \n-        try:\n-            # remove myself from the import hooks\n-            sys.meta_path = [loader for loader in sys.meta_path if loader is not self]\n-        except ValueError:\n-            pass\n-        \n-        ip = get_ipython()\n-        if ip is None:\n-            # not in an interactive environment\n-            return\n-            \n-        if ip.pylab_gui_select:\n-            # backend already selected\n-            return\n-            \n-        if hasattr(ip, 'kernel'):\n-            # default to inline in kernel environments\n-            ip.enable_matplotlib('inline')\n-        else:\n-            print('enabling matplotlib')\n-            ip.enable_matplotlib()\n-\n-# install the finder immediately\n-sys.meta_path.insert(0, MatplotlibFinder())\n\\ No newline at end of file\n", "issue": "Consider not writing in user home\nAll the images (starting from base notebook) write part of the configuration inside the user home folder, and assume that `/home/$NB_USER/work` will be mounted. This has a practical limitation that it is not easy to setup a hub such that useful folders like `.ssh`, or e.g. `.bash_history` persist across container restarts.\r\n\r\nI might be missing underlying assumptions and use cases, but I suggest to assume that home itself would be mounted, and instead modify the global configuration options.\n", "before_files": [{"content": "\"\"\"Startup script for IPython kernel.\n\nInstalls an import hook to configure the matplotlib backend on the fly.\n\nOriginally from @minrk at \nhttps://github.com/minrk/profile_default/blob/master/startup/mplimporthook.py\nRepurposed for docker-stacks to address repeat bugs like\nhttps://github.com/jupyter/docker-stacks/issues/235.\n\"\"\"\nimport sys\nfrom IPython import get_ipython\n\nclass MatplotlibFinder(object):\n    \"\"\"Import hook that notices when matplotlib.pyplot or pylab is imported\n    and tries to configure the matplotlib backend appropriately for the\n    environment.\n    \"\"\"\n    _called = False\n    \n    def find_module(self, fullname, path=None):\n        if self._called:\n            # already handled\n            return\n        \n        if fullname not in ('pylab', 'matplotlib.pyplot'):\n            # not matplotlib\n            return\n        \n        # don't call me again\n        self._called = True\n        \n        try:\n            # remove myself from the import hooks\n            sys.meta_path = [loader for loader in sys.meta_path if loader is not self]\n        except ValueError:\n            pass\n        \n        ip = get_ipython()\n        if ip is None:\n            # not in an interactive environment\n            return\n            \n        if ip.pylab_gui_select:\n            # backend already selected\n            return\n            \n        if hasattr(ip, 'kernel'):\n            # default to inline in kernel environments\n            ip.enable_matplotlib('inline')\n        else:\n            print('enabling matplotlib')\n            ip.enable_matplotlib()\n\n# install the finder immediately\nsys.meta_path.insert(0, MatplotlibFinder())", "path": "scipy-notebook/mplimporthook.py"}]}