prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Demo functionplotter.py range editor error
  **Problem Description**
  functionplotter.py break when `auto` is chosen from enum editor.
  **Reproduction Steps:**
  Run the file and change the enum to `auto`.
  **Expected behavior:**
  Plot disappear and raise the error
  ```
  functionplotter.py:47: RuntimeWarning: invalid value encountered in double_scalars
    real_high = ceil(high/dx) * dx
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:124: RuntimeWarning: invalid value encountered in greater_equal
    return ((data.view(ndarray) >= self._low_value) &
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:125: RuntimeWarning: invalid value encountered in less_equal
    (data.view(ndarray) <= self._high_value))
  functionplotter.py:46: RuntimeWarning: invalid value encountered in double_scalars
    real_low = ceil(low/dx) * dx
  functionplotter.py:52: RuntimeWarning: divide by zero encountered in divide
    return sin(1.0/x)
  functionplotter.py:52: RuntimeWarning: invalid value encountered in sin
    return sin(1.0/x)
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:148: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    if low == 'track':
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:232: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    if self._low_setting != val:
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:239: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    if val == 'auto':
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:245: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    elif val == 'track':
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:285: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    if self._high_setting != val:
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:292: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    if val == 'auto':
  /Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:298: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
    elif val == 'track':
  ```
  
  **OS, Python version:** 
  OSX, Python 2.7
  
  splits from #385 
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `examples/demo/functionplotter.py`
  Content:
  ```
  1 #!/usr/bin/env python
  2 """
  3 Demonstrates use of the FunctionDataSource that depends on an external range
  4 and returns different data depending on that range.
  5 """
  6 
  7 # Major library imports
  8 from numpy import linspace, sin, ceil
  9 
  10 # Enthought library imports
  11 from enable.api import Component, ComponentEditor
  12 from traits.api import HasTraits, Instance, Int
  13 from traitsui.api import Item, Group, HGroup, View
  14 
  15 # Chaco imports
  16 from chaco.api import ScatterPlot, DataView, LinePlot
  17 from chaco.tools.api import PanTool, ZoomTool
  18 from chaco.function_data_source import FunctionDataSource
  19 
  20 
  21 class PlotExample(HasTraits):
  22     plot = Instance(Component)
  23     numpoints = Int(500)
  24 
  25     traits_view = View(
  26         Group(
  27             Item('plot', editor=ComponentEditor(), show_label=False),
  28             HGroup(
  29                 HGroup(
  30                     Item('object.plot.x_mapper.range.low_setting', label='Low'),
  31                     Item('object.plot.x_mapper.range.high_setting', label='High'),
  32                     label='X', show_border=True
  33                 ),
  34                 HGroup(
  35                     Item('object.plot.y_mapper.range.low_setting', label='Low'),
  36                     Item('object.plot.y_mapper.range.high_setting', label='High'),
  37                     label='Y', show_border=True
  38                 ),
  39             ),
  40             orientation = "vertical"), resizable=True, title="Function Plot",
  41             width=900, height=600
  42         )
  43 
  44     def xfunc(self, low, high):
  45         dx = (high - low) / self.numpoints
  46         real_low = ceil(low/dx) * dx
  47         real_high = ceil(high/dx) * dx
  48         return linspace(real_low, real_high, self.numpoints)
  49 
  50     def yfunc(self, low, high):
  51         x = self.xfunc(low, high)
  52         return sin(1.0/x)
  53 
  54     def _plot_default(self):
  55         container = DataView()
  56 
  57         xds = FunctionDataSource(func = self.xfunc)
  58         yds = FunctionDataSource(func = self.yfunc)
  59 
  60         xmapper = container.x_mapper
  61         ymapper = container.y_mapper
  62 
  63         xds.data_range = xmapper.range
  64         yds.data_range = xmapper.range
  65 
  66         xmapper.range.set_bounds(-5, 10)
  67         ymapper.range.set_bounds(-1, 1.2)
  68 
  69         plot = ScatterPlot(index = xds, value = yds, index_mapper = xmapper,
  70                            value_mapper = ymapper,
  71                            color = "green",
  72                            marker = "circle",
  73                            marker_size = 3,
  74                            line_width = 0)
  75 
  76         plot2 = LinePlot(index = xds, value = yds, index_mapper = xmapper,
  77                         value_mapper = ymapper,
  78                         color = "lightgray")
  79 
  80         container.add(plot2, plot)
  81         plot.tools.append(PanTool(plot, constrain_direction="x", constrain=True))
  82         plot.tools.append(ZoomTool(plot, axis="index", tool_mode="range"))
  83 
  84         return container
  85 
  86 
  87 demo = PlotExample()
  88 
  89 if __name__ == "__main__":
  90     demo.configure_traits()
  91 
  92
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/examples/demo/functionplotter.py b/examples/demo/functionplotter.py
  --- a/examples/demo/functionplotter.py
  +++ b/examples/demo/functionplotter.py
  @@ -9,8 +9,8 @@
   
   # Enthought library imports
   from enable.api import Component, ComponentEditor
  -from traits.api import HasTraits, Instance, Int
  -from traitsui.api import Item, Group, HGroup, View
  +from traits.api import HasTraits, Instance, Int, Enum
  +from traitsui.api import Item, Group, HGroup, View, TextEditor
   
   # Chaco imports
   from chaco.api import ScatterPlot, DataView, LinePlot
  @@ -22,18 +22,35 @@
       plot = Instance(Component)
       numpoints = Int(500)
   
  +    low_mode = Enum("value", "track")
  +    high_mode = Enum("value", "track")
  +
  +
       traits_view = View(
           Group(
               Item('plot', editor=ComponentEditor(), show_label=False),
               HGroup(
                   HGroup(
  -                    Item('object.plot.x_mapper.range.low_setting', label='Low'),
  -                    Item('object.plot.x_mapper.range.high_setting', label='High'),
  +                    Item('object.plot.x_mapper.range.low_setting', label='Low',
  +                         editor=TextEditor(),
  +                         visible_when='object.low_mode == "value" ', ),
  +                    Item('low_mode', label='Low Mode'),
  +                    Item('object.plot.x_mapper.range.high_setting',
  +                         label='High', editor=TextEditor(),
  +                         visible_when='object.high_mode == "value" '),
  +                    Item('high_mode', label='High Mode'),
  +                    Item('object.plot.x_mapper.range.tracking_amount',
  +                         label='Tracking Amount',
  +                         editor=TextEditor(read_only=True),
  +                         visible_when='object.high_mode == "track" or '
  +                                      'object.low_mode == "track"'),
                       label='X', show_border=True
                   ),
                   HGroup(
  -                    Item('object.plot.y_mapper.range.low_setting', label='Low'),
  -                    Item('object.plot.y_mapper.range.high_setting', label='High'),
  +                    Item('object.plot.y_mapper.range.low_setting',
  +                         label='Low', editor=TextEditor()),
  +                    Item('object.plot.y_mapper.range.high_setting',
  +                         label='High', editor=TextEditor()),
                       label='Y', show_border=True
                   ),
               ),
  @@ -51,6 +68,14 @@
           x = self.xfunc(low, high)
           return sin(1.0/x)
   
  +    def _low_mode_changed(self, newvalue):
  +        if newvalue != "value":
  +            self.plot.x_mapper.range.low_setting = newvalue
  +
  +    def _high_mode_changed(self, newvalue):
  +        if newvalue != "value":
  +            self.plot.x_mapper.range.high_setting = newvalue
  +
       def _plot_default(self):
           container = DataView()
   
  @@ -78,7 +103,8 @@
                           color = "lightgray")
   
           container.add(plot2, plot)
  -        plot.tools.append(PanTool(plot, constrain_direction="x", constrain=True))
  +        plot.tools.append(PanTool(plot, constrain_direction="x",
  +                                  constrain=True))
           plot.tools.append(ZoomTool(plot, axis="index", tool_mode="range"))
   
           return container
  
verification_info: {"golden_diff": "diff --git a/examples/demo/functionplotter.py b/examples/demo/functionplotter.py\n--- a/examples/demo/functionplotter.py\n+++ b/examples/demo/functionplotter.py\n@@ -9,8 +9,8 @@\n \n # Enthought library imports\n from enable.api import Component, ComponentEditor\n-from traits.api import HasTraits, Instance, Int\n-from traitsui.api import Item, Group, HGroup, View\n+from traits.api import HasTraits, Instance, Int, Enum\n+from traitsui.api import Item, Group, HGroup, View, TextEditor\n \n # Chaco imports\n from chaco.api import ScatterPlot, DataView, LinePlot\n@@ -22,18 +22,35 @@\n     plot = Instance(Component)\n     numpoints = Int(500)\n \n+    low_mode = Enum(\"value\", \"track\")\n+    high_mode = Enum(\"value\", \"track\")\n+\n+\n     traits_view = View(\n         Group(\n             Item('plot', editor=ComponentEditor(), show_label=False),\n             HGroup(\n                 HGroup(\n-                    Item('object.plot.x_mapper.range.low_setting', label='Low'),\n-                    Item('object.plot.x_mapper.range.high_setting', label='High'),\n+                    Item('object.plot.x_mapper.range.low_setting', label='Low',\n+                         editor=TextEditor(),\n+                         visible_when='object.low_mode == \"value\" ', ),\n+                    Item('low_mode', label='Low Mode'),\n+                    Item('object.plot.x_mapper.range.high_setting',\n+                         label='High', editor=TextEditor(),\n+                         visible_when='object.high_mode == \"value\" '),\n+                    Item('high_mode', label='High Mode'),\n+                    Item('object.plot.x_mapper.range.tracking_amount',\n+                         label='Tracking Amount',\n+                         editor=TextEditor(read_only=True),\n+                         visible_when='object.high_mode == \"track\" or '\n+                                      'object.low_mode == \"track\"'),\n                     label='X', show_border=True\n                 ),\n                 HGroup(\n-                    Item('object.plot.y_mapper.range.low_setting', label='Low'),\n-                    Item('object.plot.y_mapper.range.high_setting', label='High'),\n+                    Item('object.plot.y_mapper.range.low_setting',\n+                         label='Low', editor=TextEditor()),\n+                    Item('object.plot.y_mapper.range.high_setting',\n+                         label='High', editor=TextEditor()),\n                     label='Y', show_border=True\n                 ),\n             ),\n@@ -51,6 +68,14 @@\n         x = self.xfunc(low, high)\n         return sin(1.0/x)\n \n+    def _low_mode_changed(self, newvalue):\n+        if newvalue != \"value\":\n+            self.plot.x_mapper.range.low_setting = newvalue\n+\n+    def _high_mode_changed(self, newvalue):\n+        if newvalue != \"value\":\n+            self.plot.x_mapper.range.high_setting = newvalue\n+\n     def _plot_default(self):\n         container = DataView()\n \n@@ -78,7 +103,8 @@\n                         color = \"lightgray\")\n \n         container.add(plot2, plot)\n-        plot.tools.append(PanTool(plot, constrain_direction=\"x\", constrain=True))\n+        plot.tools.append(PanTool(plot, constrain_direction=\"x\",\n+                                  constrain=True))\n         plot.tools.append(ZoomTool(plot, axis=\"index\", tool_mode=\"range\"))\n \n         return container\n", "issue": "Demo functionplotter.py range editor error\n**Problem Description**\r\nfunctionplotter.py break when `auto` is chosen from enum editor.\r\n**Reproduction Steps:**\r\nRun the file and change the enum to `auto`.\r\n**Expected behavior:**\r\nPlot disappear and raise the error\r\n```\r\nfunctionplotter.py:47: RuntimeWarning: invalid value encountered in double_scalars\r\n  real_high = ceil(high/dx) * dx\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:124: RuntimeWarning: invalid value encountered in greater_equal\r\n  return ((data.view(ndarray) >= self._low_value) &\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:125: RuntimeWarning: invalid value encountered in less_equal\r\n  (data.view(ndarray) <= self._high_value))\r\nfunctionplotter.py:46: RuntimeWarning: invalid value encountered in double_scalars\r\n  real_low = ceil(low/dx) * dx\r\nfunctionplotter.py:52: RuntimeWarning: divide by zero encountered in divide\r\n  return sin(1.0/x)\r\nfunctionplotter.py:52: RuntimeWarning: invalid value encountered in sin\r\n  return sin(1.0/x)\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:148: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  if low == 'track':\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:232: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  if self._low_setting != val:\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:239: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  if val == 'auto':\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:245: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  elif val == 'track':\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:285: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  if self._high_setting != val:\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:292: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  if val == 'auto':\r\n/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/data_range_1d.py:298: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison\r\n  elif val == 'track':\r\n```\r\n\r\n**OS, Python version:** \r\nOSX, Python 2.7\r\n\r\nsplits from #385 \n", "before_files": [{"content": "#!/usr/bin/env python\n\"\"\"\nDemonstrates use of the FunctionDataSource that depends on an external range\nand returns different data depending on that range.\n\"\"\"\n\n# Major library imports\nfrom numpy import linspace, sin, ceil\n\n# Enthought library imports\nfrom enable.api import Component, ComponentEditor\nfrom traits.api import HasTraits, Instance, Int\nfrom traitsui.api import Item, Group, HGroup, View\n\n# Chaco imports\nfrom chaco.api import ScatterPlot, DataView, LinePlot\nfrom chaco.tools.api import PanTool, ZoomTool\nfrom chaco.function_data_source import FunctionDataSource\n\n\nclass PlotExample(HasTraits):\n    plot = Instance(Component)\n    numpoints = Int(500)\n\n    traits_view = View(\n        Group(\n            Item('plot', editor=ComponentEditor(), show_label=False),\n            HGroup(\n                HGroup(\n                    Item('object.plot.x_mapper.range.low_setting', label='Low'),\n                    Item('object.plot.x_mapper.range.high_setting', label='High'),\n                    label='X', show_border=True\n                ),\n                HGroup(\n                    Item('object.plot.y_mapper.range.low_setting', label='Low'),\n                    Item('object.plot.y_mapper.range.high_setting', label='High'),\n                    label='Y', show_border=True\n                ),\n            ),\n            orientation = \"vertical\"), resizable=True, title=\"Function Plot\",\n            width=900, height=600\n        )\n\n    def xfunc(self, low, high):\n        dx = (high - low) / self.numpoints\n        real_low = ceil(low/dx) * dx\n        real_high = ceil(high/dx) * dx\n        return linspace(real_low, real_high, self.numpoints)\n\n    def yfunc(self, low, high):\n        x = self.xfunc(low, high)\n        return sin(1.0/x)\n\n    def _plot_default(self):\n        container = DataView()\n\n        xds = FunctionDataSource(func = self.xfunc)\n        yds = FunctionDataSource(func = self.yfunc)\n\n        xmapper = container.x_mapper\n        ymapper = container.y_mapper\n\n        xds.data_range = xmapper.range\n        yds.data_range = xmapper.range\n\n        xmapper.range.set_bounds(-5, 10)\n        ymapper.range.set_bounds(-1, 1.2)\n\n        plot = ScatterPlot(index = xds, value = yds, index_mapper = xmapper,\n                           value_mapper = ymapper,\n                           color = \"green\",\n                           marker = \"circle\",\n                           marker_size = 3,\n                           line_width = 0)\n\n        plot2 = LinePlot(index = xds, value = yds, index_mapper = xmapper,\n                        value_mapper = ymapper,\n                        color = \"lightgray\")\n\n        container.add(plot2, plot)\n        plot.tools.append(PanTool(plot, constrain_direction=\"x\", constrain=True))\n        plot.tools.append(ZoomTool(plot, axis=\"index\", tool_mode=\"range\"))\n\n        return container\n\n\ndemo = PlotExample()\n\nif __name__ == \"__main__\":\n    demo.configure_traits()\n\n", "path": "examples/demo/functionplotter.py"}], "after_files": [{"content": "#!/usr/bin/env python\n\"\"\"\nDemonstrates use of the FunctionDataSource that depends on an external range\nand returns different data depending on that range.\n\"\"\"\n\n# Major library imports\nfrom numpy import linspace, sin, ceil\n\n# Enthought library imports\nfrom enable.api import Component, ComponentEditor\nfrom traits.api import HasTraits, Instance, Int, Enum\nfrom traitsui.api import Item, Group, HGroup, View, TextEditor\n\n# Chaco imports\nfrom chaco.api import ScatterPlot, DataView, LinePlot\nfrom chaco.tools.api import PanTool, ZoomTool\nfrom chaco.function_data_source import FunctionDataSource\n\n\nclass PlotExample(HasTraits):\n    plot = Instance(Component)\n    numpoints = Int(500)\n\n    low_mode = Enum(\"value\", \"track\")\n    high_mode = Enum(\"value\", \"track\")\n\n\n    traits_view = View(\n        Group(\n            Item('plot', editor=ComponentEditor(), show_label=False),\n            HGroup(\n                HGroup(\n                    Item('object.plot.x_mapper.range.low_setting', label='Low',\n                         editor=TextEditor(),\n                         visible_when='object.low_mode == \"value\" ', ),\n                    Item('low_mode', label='Low Mode'),\n                    Item('object.plot.x_mapper.range.high_setting',\n                         label='High', editor=TextEditor(),\n                         visible_when='object.high_mode == \"value\" '),\n                    Item('high_mode', label='High Mode'),\n                    Item('object.plot.x_mapper.range.tracking_amount',\n                         label='Tracking Amount',\n                         editor=TextEditor(read_only=True),\n                         visible_when='object.high_mode == \"track\" or '\n                                      'object.low_mode == \"track\"'),\n                    label='X', show_border=True\n                ),\n                HGroup(\n                    Item('object.plot.y_mapper.range.low_setting',\n                         label='Low', editor=TextEditor()),\n                    Item('object.plot.y_mapper.range.high_setting',\n                         label='High', editor=TextEditor()),\n                    label='Y', show_border=True\n                ),\n            ),\n            orientation = \"vertical\"), resizable=True, title=\"Function Plot\",\n            width=900, height=600\n        )\n\n    def xfunc(self, low, high):\n        dx = (high - low) / self.numpoints\n        real_low = ceil(low/dx) * dx\n        real_high = ceil(high/dx) * dx\n        return linspace(real_low, real_high, self.numpoints)\n\n    def yfunc(self, low, high):\n        x = self.xfunc(low, high)\n        return sin(1.0/x)\n\n    def _low_mode_changed(self, newvalue):\n        if newvalue != \"value\":\n            self.plot.x_mapper.range.low_setting = newvalue\n\n    def _high_mode_changed(self, newvalue):\n        if newvalue != \"value\":\n            self.plot.x_mapper.range.high_setting = newvalue\n\n    def _plot_default(self):\n        container = DataView()\n\n        xds = FunctionDataSource(func = self.xfunc)\n        yds = FunctionDataSource(func = self.yfunc)\n\n        xmapper = container.x_mapper\n        ymapper = container.y_mapper\n\n        xds.data_range = xmapper.range\n        yds.data_range = xmapper.range\n\n        xmapper.range.set_bounds(-5, 10)\n        ymapper.range.set_bounds(-1, 1.2)\n\n        plot = ScatterPlot(index = xds, value = yds, index_mapper = xmapper,\n                           value_mapper = ymapper,\n                           color = \"green\",\n                           marker = \"circle\",\n                           marker_size = 3,\n                           line_width = 0)\n\n        plot2 = LinePlot(index = xds, value = yds, index_mapper = xmapper,\n                        value_mapper = ymapper,\n                        color = \"lightgray\")\n\n        container.add(plot2, plot)\n        plot.tools.append(PanTool(plot, constrain_direction=\"x\",\n                                  constrain=True))\n        plot.tools.append(ZoomTool(plot, axis=\"index\", tool_mode=\"range\"))\n\n        return container\n\n\ndemo = PlotExample()\n\nif __name__ == \"__main__\":\n    demo.configure_traits()\n\n", "path": "examples/demo/functionplotter.py"}]}