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

Issue:
Use the latest EDM version (3.0.1)
A new major version of EDM is available and it would be good to update to the latest version - https://assets.enthought.com/downloads/edm/. This should be as simple as updating the environment variables in travis and appveyor config files.

https://github.com/enthought/chaco/blob/3de7780561fa29e79c887432d3ce408ea82d1614/.travis.yml#L23
https://github.com/enthought/chaco/blob/3de7780561fa29e79c887432d3ce408ea82d1614/appveyor.yml#L8


Discussion:
Note that there is a major behavioral change with version 3.0.1 of EDM - the default platform tag used on unix is rh7, not rh6. Previously, users needed to explicitly pass the rh7 platform cmdline flag if they wanted to created an rh7 environment and rh6 was the default if no flag was set.

We weren't setting this flag earlier - https://github.com/enthought/chaco/blob/3de7780561fa29e79c887432d3ce408ea82d1614/ci/edmtool.py#L125

When we update edm to version 3.0.1, we will automatically switch to using the rh7 environments + rh7 packages in the environments instead of rh6. This should not break anything but we need to be aware of this change.

Resolving patch:
diff --git a/ci/edmtool.py b/ci/edmtool.py
--- a/ci/edmtool.py
+++ b/ci/edmtool.py
@@ -101,7 +101,7 @@
 github_url_fmt = "git+http://github.com/enthought/{0}.git#egg={0}"
 
 extra_dependencies = {
-    'pyside2': set(),  # pyside2 is pip-installed during the install step
+    'pyside2': {'pyside2'},
     'pyqt': {'pyqt'},
     'pyqt5': {'pyqt5'},
     'null': set()
@@ -139,19 +139,20 @@ def install(runtime, toolkit, environment, source):
     parameters = get_parameters(runtime, toolkit, environment)
     parameters['packages'] = ' '.join(
         dependencies | extra_dependencies.get(toolkit, set()))
+
+    if toolkit == "pyside2":
+        additional_repositories = "--add-repository enthought/lgpl"
+    else:
+        additional_repositories = ""
+
     # edm commands to setup the development environment
     commands = [
         "edm environments create {environment} --force --version={runtime}",
-        "edm install -y -e {environment} {packages}",
+        "edm install -y -e {environment} {packages} " + additional_repositories,
         ("edm run -e {environment} -- pip install -r ci/requirements.txt"
          " --no-dependencies"),
         "edm run -e {environment} -- pip install . --no-deps",
     ]
-    # pip install pyside2, because we don't have it in EDM yet
-    if toolkit == 'pyside2':
-        commands.append(
-            "edm run -e {environment} -- pip install pyside2==5.11"
-        )
     
     click.echo("Creating environment '{environment}'".format(**parameters))
     execute(commands, parameters)


Test patch:
Repository: enthought/chaco

Issue:
ScatterInspector does not deselect all on index == None
I've been playing around with the scattertoggle.py example. Maybe I'm missing something, but the ScatterInspector seems to fail to deselect all points when clicking on whitespace on the plot (that is, index == None). Something along the lines of this seems to fix it.

``` python
class PatchedScatterInspector(ScatterInspector):
        def _deselect(self, index=None):
            plot = self.component
            if index:
                super(PatchedScatterInspector, self)._deselect(index)
            else:
                for name in ('index', 'value'):
                    if not hasattr(plot, name):
                        continue
                    md = getattr(plot, name).metadata
                    md[self.selection_metadata_name] = []
                    getattr(plot, name).metadata_changed = True
            return
```

Cheers,

-A



Discussion:

Resolving patch:
diff --git a/chaco/tools/scatter_inspector.py b/chaco/tools/scatter_inspector.py
--- a/chaco/tools/scatter_inspector.py
+++ b/chaco/tools/scatter_inspector.py
@@ -125,6 +125,11 @@ def _deselect(self, index=None):
                 # Only issue 1 event:
                 if name == 'index':
                     self.inspector_event = insp_event
+            elif index is None:
+                md[self.selection_metadata_name] = []
+                # Only issue 1 event:
+                if name == 'index':
+                    self.inspector_event = insp_event
         return
 
     def _select(self, index, append=True):


Test patch:
Repository: enthought/chaco

Issue:
ArrayDataSource get_data() returns scalar 0.0 when _data is None
The `ArrayDataSource` is meant to represent a 1D data structure stored in an array.  For some reason, when no data value has been set, the `get_data()` method returns a scalar `0.0` value.

It would probably make most sense for the value to be `empty(shape=(0,))` (ie. a 1D array of length 0).

Changing this may break existing code which expects empty `ArrayDataSources` to return a scalar 0.  On the flip side, this will potentially simplify the logic for `get_bounds()` and similar.



Discussion:

Resolving patch:
diff --git a/chaco/array_data_source.py b/chaco/array_data_source.py
--- a/chaco/array_data_source.py
+++ b/chaco/array_data_source.py
@@ -1,7 +1,7 @@
 """ Defines the ArrayDataSource class."""
 
 # Major library imports
-from numpy import array, isfinite, ones, ndarray
+from numpy import array, empty, isfinite, ones, ndarray
 import numpy as np
 
 # Enthought library imports
@@ -147,7 +147,7 @@ def get_data(self):
         if self._data is not None:
             return self._data
         else:
-            return 0.0
+            return empty(shape=(0,))
 
     def get_data_mask(self):
         """get_data_mask() -> (data_array, mask_array)
@@ -238,17 +238,10 @@ def _compute_bounds(self, data=None):
         #       version of the dataset?
 
         if data is None:
-            # Several sources weren't setting the _data attribute, so we
-            # go through the interface.  This seems like the correct thing
-            # to do anyway... right?
-            # data = self._data
             data = self.get_data()
 
-        data_len = 0
-        try:
-            data_len = len(data)
-        except Exception:
-            pass
+        data_len = len(data)
+
         if data_len == 0:
             self._min_index = 0
             self._max_index = 0


Test patch:
Repository: enthought/chaco

Issue:
Use GitHub Actions instead of Travis and Appveyor  CI
We need to replace the use of Travis and Appveyor CI with GitHub Actions CI, similar to what we did in other ETS projects.


Discussion:

Resolving patch:
diff --git a/examples/demo/basic/minard_napoleon.py b/examples/demo/basic/minard_napoleon.py
--- a/examples/demo/basic/minard_napoleon.py
+++ b/examples/demo/basic/minard_napoleon.py
@@ -120,8 +120,12 @@
 
 
 def _create_plot_component():
-    army_lat = np.column_stack([army["start_lat"], army["end_lat"]]).reshape(-1)
-    army_lon = np.column_stack([army["start_lon"], army["end_lon"]]).reshape(-1)
+    army_lat = np.column_stack(
+        [army["start_lat"], army["end_lat"]]
+    ).reshape(-1)
+    army_lon = np.column_stack(
+        [army["start_lon"], army["end_lon"]]
+    ).reshape(-1)
 
     plot_data = ArrayPlotData(
         army_lon=army_lon,


Test patch:
diff --git a/chaco/tests/test_plot.py b/chaco/tests/test_plot.py
--- a/chaco/tests/test_plot.py
+++ b/chaco/tests/test_plot.py
@@ -68,7 +68,9 @@ def test_segment_plot_color_width(self):
         w = arange(3, 8)
         data = ArrayPlotData(x=x, y=y, c=c, w=w)
         plot = Plot(data)
-        plot.plot(("x", "y", "c", "w"), "cmap_segment", color_mapper=viridis)[0]
+        plot.plot(
+            ("x", "y", "c", "w"), "cmap_segment", color_mapper=viridis
+        )[0]
 
         plot.do_layout((250, 250))
         gc = PlotGraphicsContext((250, 250))
Repository: enthought/chaco

Issue:
Dont use traitsui.api as tui
https://github.com/enthought/chaco/blob/3de7780561fa29e79c887432d3ce408ea82d1614/chaco/plugin/plot_editor.py makes use of the odd `import traitsui.api as tui` alias which needs to be updated and removed.


Discussion:

Resolving patch:
diff --git a/chaco/plugin/plot_editor.py b/chaco/plugin/plot_editor.py
--- a/chaco/plugin/plot_editor.py
+++ b/chaco/plugin/plot_editor.py
@@ -2,7 +2,7 @@
 from enable.component_editor import ComponentEditor
 from pyface.workbench.api import TraitsUIEditor
 from traits.api import Any, Enum, HasTraits, Property, Str
-from traitsui import api as tui
+from traitsui.api import Item, View
 
 
 class PlotUI(HasTraits):
@@ -11,8 +11,8 @@ class PlotUI(HasTraits):
     # The plot.
     component = Any()
 
-    traits_view = tui.View(
-        tui.Item("component", editor=ComponentEditor(), show_label=False),
+    traits_view = View(
+        Item("component", editor=ComponentEditor(), show_label=False),
         resizable=True,
     )
 


Test patch:
Repository: enthought/chaco

Issue:
Remove unnecessary/debugging uses of print from the codebase and examples
There are a number of places in the codebase and in the examples where the `print` function is used, and in some cases a commented out `print` statement. These need to be evaluated and removed.


Discussion:

Resolving patch:
diff --git a/chaco/plotscrollbar.py b/chaco/plotscrollbar.py
--- a/chaco/plotscrollbar.py
+++ b/chaco/plotscrollbar.py
@@ -101,7 +101,7 @@ def _handle_dataspace_update(self):
         else:
             ticksize = 1
         foo = (totalmin, totalmax, view, ticksize)
-        print("scrollrange:", foo)
+
         self.trait_setq(
             range=foo,
             scroll_position=max(
diff --git a/examples/demo/nonlinear_color_mapping.py b/examples/demo/nonlinear_color_mapping.py
--- a/examples/demo/nonlinear_color_mapping.py
+++ b/examples/demo/nonlinear_color_mapping.py
@@ -278,6 +278,5 @@ def _colorbar_scale_changed(self):
         domain_bounds=(0.0, 0.0, 2.0, 2.0),
         grid_size=(200, 200),
     )
-    # print "data bounds: ", grid.data_min, grid.data_max
     demo = DataGridView(model=grid)
     demo.configure_traits()


Test patch:
diff --git a/chaco/tests/test_colormapper.py b/chaco/tests/test_colormapper.py
--- a/chaco/tests/test_colormapper.py
+++ b/chaco/tests/test_colormapper.py
@@ -5,7 +5,7 @@
 from chaco.api import ArrayDataSource, ColorMapper, DataRange1D
 
 
-class LinearSegmentedColormapTestCase(unittest.TestCase):
+class ColormapperTestCase(unittest.TestCase):
     def setUp(self):
         """ Set up called before each test case. """
 
@@ -130,36 +130,3 @@ def test_no_alpha(self):
             "red": [(0.0, 0.0, 0.0), (1.0, 1.0, 1.0)],
         }
         assert self.colormap._segmentdata == sd
-
-
-##     def test_no_interpolation(self):
-##         grayscale_colors = array([[0.0,0.0,0.0,1.0], [1.0, 1.0, 1.0, 1.0]])
-##         grayscale_bins = array([0.0, 1.0])
-##         grayscale_steps = array([1])
-
-##         colormap = LinearSegmentedColormap(
-##             grayscale_colors, grayscale_bins, grayscale_steps
-##         )
-
-##         a = array([0.0, 0.25, 0.75, 1.0])
-##         b = colormap.map_array(a)
-##         result = ravel(b[:,:1])
-##         expected = array([0.0, 0.0, 1.0, 1.0])
-
-##         close = allclose(result, expected, atol=0.02)
-##         self.assert_(close,
-##             "Map with no interpolation broken.  Expected %s.  Got %s" % (expected, result))
-
-##     def test_value_bands(self):
-
-##         grayscale_colors = array([[0.0,0.0,0.0,1.0], [1.0, 1.0, 1.0, 1.0]])
-##         grayscale_bins = array([0.0, 1.0])
-##         grayscale_steps = array([1])
-
-##         colormap = LinearSegmentedColormap(
-##             grayscale_colors, grayscale_bins, grayscale_steps
-##         )
-
-##         colormap._recalculate()
-
-##         print '**************', colormap._color_bands, colormap._value_bands
Repository: enthought/chaco

Issue:
Replace optparse with argparse in example
The chaco example https://github.com/enthought/chaco/blob/ef7227706642f7d26042717ad9b60648d7572068/examples/demo/advanced/scalar_image_function_inspector.py makes use of `optparse` which we should replace with `argparse` at the least, if not `click`.


Discussion:

Resolving patch:
diff --git a/examples/demo/advanced/scalar_image_function_inspector.py b/examples/demo/advanced/scalar_image_function_inspector.py
--- a/examples/demo/advanced/scalar_image_function_inspector.py
+++ b/examples/demo/advanced/scalar_image_function_inspector.py
@@ -12,8 +12,6 @@
 
 
 # Standard library imports
-from optparse import OptionParser
-import sys
 import random
 
 # Major library imports
@@ -450,8 +448,10 @@ def _colormap_changed(self):
 
     def _num_levels_changed(self):
         if self.num_levels > 3:
-            self.polyplot.levels = self.num_levels
-            self.lineplot.levels = self.num_levels
+            if self.polyplot is not None:
+                self.polyplot.levels = self.num_levels
+            if self.lineplot is not None:
+                self.lineplot.levels = self.num_levels
 
 
 # HasTraits class that supplies the callable for the timer event.
@@ -634,56 +634,5 @@ def show_plot(**kwargs):
     modelview.configure_traits()
 
 
-def main(argv=None):
-
-    if argv is None:
-        argv = sys.argv
-
-    usage = "usage: %prog [options]"
-    parser = OptionParser(usage=usage, version="%prog 1.0")
-
-    parser.add_option(
-        "-c",
-        "--colormap",
-        action="store",
-        type="string",
-        dest="colormap",
-        default="viridis",
-        metavar="CMAP",
-        help="choose a default colormapper",
-    )
-
-    parser.add_option(
-        "-n",
-        "--nlevels",
-        action="store",
-        type="int",
-        dest="num_levels",
-        default=15,
-        help="number countour levels to plot [default: %default]",
-    )
-
-    parser.add_option(
-        "-f",
-        "--function",
-        action="store",
-        type="string",
-        dest="function",
-        default="tanh(x**2+y)*cos(y)*jn(0,x+y*2)",
-        help="function of x and y [default: %default]",
-    )
-
-    opts, args = parser.parse_args(argv[1:])
-
-    if len(args) > 0:
-        parser.error("Incorrect number of arguments")
-
-    show_plot(
-        colormap=opts.colormap,
-        num_levels=opts.num_levels,
-        function=opts.function,
-    )
-
-
 if __name__ == "__main__":
-    sys.exit(main())
+    show_plot()


Test patch:
Repository: enthought/chaco

Issue:
Remove chaco.chaco_version file
https://github.com/enthought/chaco/blob/fdd858aa6dbc76addb50d011fb81e879ce8e0355/chaco/chaco_version.py

We now create `chaco._version` file when installing the package (in `setup.py`) so we don't need this additional `chaco.chaco_version` file anymore.


Discussion:

Resolving patch:
diff --git a/chaco/chaco_version.py b/chaco/chaco_version.py
deleted file mode 100644
--- a/chaco/chaco_version.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# ------------------------------------------------------------------------------
-# Copyright (c) 2005, Enthought, Inc.
-# All rights reserved.
-#
-# This software is provided without warranty under the terms of the BSD
-# license included in LICENSE.txt and may be redistributed only
-# under the conditions described in the aforementioned license.  The license
-# is also available online at http://www.enthought.com/licenses/BSD.txt
-# Thanks for using Enthought open source!
-#
-# Author: Enthought, Inc.
-# Description: <Enthought library component>
-# ------------------------------------------------------------------------------
-""" Defines version numbering for the Chaco package.
-"""
-major = 2
-minor = 0
-micro = 9
-
-version = "%s.%s.%s" % (major, minor, micro)
-
-
-release_level = "beta"
-branch = ""
-revision = version


Test patch:
Repository: enthought/chaco

Issue:
Remove backwards compatibility imports from chaco.chaco_traits
https://github.com/enthought/chaco/blob/fdd858aa6dbc76addb50d011fb81e879ce8e0355/chaco/chaco_traits.py#L18-L20

Similar to #628 


Discussion:

Resolving patch:
diff --git a/chaco/api.py b/chaco/api.py
--- a/chaco/api.py
+++ b/chaco/api.py
@@ -481,8 +481,3 @@
     Set3,
 )
 from .default_colors import cbrewer, palette11, palette14, PALETTES
-
-# Importing various symbols into the Chaco namespace for backwards
-# compatibility.  New code should directly import from Enable.
-from enable.base_tool import BaseTool, KeySpec
-from enable.markers import marker_trait
diff --git a/chaco/chaco_traits.py b/chaco/chaco_traits.py
--- a/chaco/chaco_traits.py
+++ b/chaco/chaco_traits.py
@@ -14,7 +14,3 @@
 #: Values correspond to: top, bottom, left, right, top left, top right, bottom
 #: left, bottom right
 box_position_enum = Enum("T", "B", "L", "R", "TL", "TR", "BL", "BR")
-
-# For backwards compatibility, import LineStyle & LineStyleEditor from enable.
-# (They used to be defined here.)
-from enable.api import LineStyle, LineStyleEditor


Test patch:
Repository: enthought/chaco

Issue:
Remove "PopupablePlot"
`PopupablePlot` was introduced in the commit https://github.com/enthought/chaco/commit/4af154cec6f678862ba7e695ae62d681312b50e8#diff-c93657842da48caff25acdb9de9f919f9c04b5301d0fafc28598c9fdeee829f8 but it is not clear why it exists or who uses it.


Discussion:
I don't find any users of this class on GitHub - https://github.com/enthought/chaco/search?q=PopupablePlot+extension%3Apy
I even dug around to find the commits before and after the commit that introduced this into the codebase - which doesn't help. Ref https://github.com/enthought/chaco/commits/3.0.0?after=57f3b83331c065c0d6f3d30234ababfbc461353e+139&branch=3.0.0
The design is intended to create a dialog window containing pre-specified plots from a given dataset - you give it a list of plot types and data that you want plotted and it populates.  The design is odd, since it really wants to be a Tool not a Plot.

It is using old constructs, and I have never seen it used.

It can be removed.

Resolving patch:
diff --git a/chaco/ui/popupable_plot.py b/chaco/ui/popupable_plot.py
deleted file mode 100644
--- a/chaco/ui/popupable_plot.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# Enthought library imports
-from traits.api import List
-from chaco.plot import Plot
-from chaco.plot_containers import VPlotContainer
-from chaco.tools.pan_tool import PanTool
-from chaco.tools.zoom_tool import ZoomTool
-from chaco.ui.plot_window import PlotWindow
-
-from traitsui.wx.constants import WindowColor
-
-
-class PopupablePlot(Plot):
-    """A Plot class that pops up in a new window on double click"""
-
-    # FIXME: It would be nice to queue up other types of commands and settings
-    command_queue = List()
-
-    def normal_left_dclick(self, event):
-        plot = Plot(self.data)
-        for data, kw in self.command_queue:
-            plot.plot(data, **kw)
-            plot.title = self.title
-
-        plot.title = self.title
-        container = VPlotContainer(bgcolor=WindowColor)
-        container.add(plot)
-        plot.tools.append(PanTool(plot))
-        plot.overlays.append(ZoomTool(plot))
-        window = PlotWindow(plot=container)
-        window.edit_traits(kind="live", parent=event.window.control)
-
-    def plot(self, data, **kw):
-        """Queue up the plot commands"""
-        self.command_queue.append((data, kw))
-        super().plot(data, **kw)


Test patch:
Repository: enthought/chaco

Issue:
TypeError when running stock prices examples
This error was discovered when running the `examples/demo/financial/stock_prices.py` example.

In order to reproduce, simply load the example and start zooming out. This was observed on python 3.6 with wx toolkit.

```
>python stock_prices.py
c:\users\rporuri\work\github\ets\enable\kiva\agg\plat_support.py:188: wxPyDeprecationWarning: Call to deprecated item. Use GetHandle instead.
  self.draw(window_dc.GetHDC(), x, y, width, height)
Exception occurred in traits notification handler for event object: TraitChangeEvent(object=<chaco.data_range_1d.DataRange1D object at 0x000001C06339C518>, name='updated', old=<undefined>, new=(1614674109.0105073, 1657874109.0105073))
Traceback (most recent call last):
  File "C:\Users\rporuri\.edm\envs\enable-test-3.6-wx\lib\site-packages\traits\observation\_trait_event_notifier.py", line 122, in __call__
    self.dispatcher(handler, event)
  File "C:\Users\rporuri\.edm\envs\enable-test-3.6-wx\lib\site-packages\traits\observation\observe.py", line 26, in dispatch_same
    handler(event)
  File "stock_prices.py", line 147, in _plot_range_handler
    low, high = event
TypeError: 'TraitChangeEvent' object is not iterable
Exception occurred in traits notification handler for event object: TraitChangeEvent(object=<chaco.data_range_1d.DataRange1D object at 0x000001C06339C518>, name='updated', old=<undefined>, new=(1593074109.0105073, 1679474109.0105073))
Traceback (most recent call last):
  File "C:\Users\rporuri\.edm\envs\enable-test-3.6-wx\lib\site-packages\traits\observation\_trait_event_notifier.py", line 122, in __call__
    self.dispatcher(handler, event)
  File "C:\Users\rporuri\.edm\envs\enable-test-3.6-wx\lib\site-packages\traits\observation\observe.py", line 26, in dispatch_same
    handler(event)
  File "stock_prices.py", line 147, in _plot_range_handler
    low, high = event
TypeError: 'TraitChangeEvent' object is not iterable
```


Discussion:

Resolving patch:
diff --git a/examples/demo/financial/stock_prices.py b/examples/demo/financial/stock_prices.py
--- a/examples/demo/financial/stock_prices.py
+++ b/examples/demo/financial/stock_prices.py
@@ -144,7 +144,7 @@ def _range_selection_handler(self, event):
     def _plot_range_handler(self, event):
         plot_range_event = event.new
         if plot_range_event is not None:
-            low, high = event
+            low, high = plot_range_event
             if "auto" not in (low, high):
                 self.range_tool.selection = (low, high)
 


Test patch: