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

Issue:
Add new overlap parameter in search filter
A user wants to be able to search for SpatialEntries that have x% overlap with the search geometry. We should add this as an additional field on the `SpatialEntryFilter`.

Perhaps call it `percent_overlap` and accept a number between 0 an 1.


Discussion:

Resolving patch:
diff --git a/django-rgd/rgd/filters.py b/django-rgd/rgd/filters.py
--- a/django-rgd/rgd/filters.py
+++ b/django-rgd/rgd/filters.py
@@ -1,8 +1,9 @@
 from django.contrib.gis import forms
-from django.contrib.gis.db.models.functions import GeometryDistance
+from django.contrib.gis.db.models.functions import Area, GeometryDistance, Intersection
 from django.contrib.gis.measure import D
 from django.core.validators import RegexValidator
-from django.db.models import F, Q
+from django.db.models import F, FloatField, Q
+from django.db.models.functions import Cast
 from django_filters import rest_framework as filters
 from rgd.models import ChecksumFile, Collection, SpatialEntry
 from rgd.permissions import get_paths
@@ -79,6 +80,11 @@ class SpatialEntryFilter(filters.FilterSet):
         method='filter_collection',
         queryset=Collection.objects.all(),
     )
+    percent_overlap = filters.NumberFilter(
+        help_text='The minute percent overlap with search geometry (between 0 and 1).',
+        label='Percent overlap',
+        method='filter_percent_overlap',
+    )
 
     @property
     def _geometry(self):
@@ -152,6 +158,18 @@ def filter_collection(self, queryset, name, value):
             return queryset.filter(conditions).distinct()
         return queryset
 
+    def filter_percent_overlap(self, queryset, name, value: float):
+        """Filter the queryset by percent overlap with the queried geometry."""
+        if value is not None and value > 0 and value <= 1 and self._has_geom:
+            geom = self._geometry
+            queryset = queryset.filter(footprint__overlaps=geom).annotate(
+                overlap_percentage=(
+                    Cast(Area(Intersection(F('footprint'), geom)) / Area(geom), FloatField())
+                )
+            )
+            queryset = queryset.filter(overlap_percentage__gte=value)
+        return queryset
+
     class Meta:
         model = SpatialEntry
         fields = [
@@ -160,6 +178,7 @@ class Meta:
             'relates',
             'distance',
             'acquired',
+            'percent_overlap',
             'instrumentation',
             'time_of_day',
             'collections',


Test patch:
Repository: enthought/chaco

Issue:
Marker "v" in chaco.shell does not work
```
import chaco.shell as csh
from numpy import linspace, pi, sin, cos
x = linspace(-2 * pi, 2 * pi, 100)
y = sin(x)
csh.plot(x, y, 'bv')
```

raises this:

```
/.../lib/python2.7/site-packages/traits/trait_handlers.pyc in error(self, object, name, value)
    168         """
    169         raise TraitError( object, name, self.full_info( object, name, value ),
--> 170                           value )
    171 
    172     def arg_error ( self, method, arg_num, object, name, value ):

TraitError: The 'marker' trait of a ScatterPlot instance must be
'circle' or 'cross' or 'custom' or 'diamond' or 'dot' or
'inverted_triangle' or 'pixel' or 'plus' or 'square' or 'triangle',
but a value of 'down triangle' <type 'str'> was specified.
```

I am using Chaco 4.2.0.



Discussion:

Resolving patch:
diff --git a/chaco/shell/plot_maker.py b/chaco/shell/plot_maker.py
--- a/chaco/shell/plot_maker.py
+++ b/chaco/shell/plot_maker.py
@@ -157,7 +157,7 @@ def make_data_sources(session, index_sort="none", *args):
     '+': 'plus',
     's': 'square',
     '^': 'triangle',
-    'v': 'down triangle'
+    'v': 'inverted_triangle'
 }
 
 line_re = re.compile('--|-\.|[-:]')


Test patch:
Repository: enthought/chaco

Issue:
ZoomTool "zoom history" keys are not working
From the examples/data_labels.py docstring:

> Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular region to
>  zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow and
> alt-right-arrow moves you forwards and backwards through the "zoom history".

but the alt-right-arrow and alt-left-arrow keys don't seem to have any effect.



Discussion:
same for me.
System: Mac OSX Lion, EPD 7.1-2 32-bit


Resolving patch:
diff --git a/examples/demo/data_labels.py b/examples/demo/data_labels.py
--- a/examples/demo/data_labels.py
+++ b/examples/demo/data_labels.py
@@ -8,9 +8,9 @@
 Mousewheel up and down zooms the plot in and out.
 
 Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular
-region to zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow
-and alt-right-arrow moves you forwards and backwards through the
-"zoom history".
+region to zoom.  If you use a sequence of zoom boxes, pressing control-y
+and control-z (Meta-y and Meta-z on Mac) moves you forwards and backwards
+through the "zoom history".
 
 Right-drag is enabled on some of the labels.
 """
diff --git a/examples/demo/edit_line.py b/examples/demo/edit_line.py
--- a/examples/demo/edit_line.py
+++ b/examples/demo/edit_line.py
@@ -8,9 +8,10 @@
 
 Mousewheel up and down zooms the plot in and out.
 
-Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular region to
-zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow and
-alt-right-arrow moves you forwards and backwards through the "zoom history".
+Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular
+region to zoom.  If you use a sequence of zoom boxes, pressing control-y and
+control-z  (use Meta-y and Meta-z on Mac) moves you forwards and backwards
+through the "zoom history".
 """
 
 # Major library imports
@@ -160,7 +161,7 @@ def _create_plot_component():
 
     # The ZoomTool tool is stateful and allows drawing a zoom
     # box to select a zoom region.
-    zoom = ZoomTool(scatter, tool_mode="box", always_on=False, drag_button=None)
+    zoom = ZoomTool(scatter, tool_mode="box", always_on=False)
     scatter.overlays.append(zoom)
 
     scatter.tools.append(PointDraggingTool(scatter))


Test patch:
diff --git a/examples/demo/scales_test.py b/examples/demo/scales_test.py
--- a/examples/demo/scales_test.py
+++ b/examples/demo/scales_test.py
@@ -6,9 +6,10 @@
 
 Mousewheel up and down zooms the plot in and out.
 
-Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular region to
-zoom.  If you use a sequence of zoom boxes, pressing alt-left-arrow and
-alt-right-arrow moves you forwards and backwards through the "zoom history".
+Pressing "z" brings up the Zoom Box, and you can click-drag a rectangular
+region to zoom. If you use a sequence of zoom boxes, pressing control-y and
+control-z (Meta-y and Meta-z on Mac) moves you forwards and backwards
+through the "zoom history".
 
 Right-click and dragging on the legend allows you to reposition the legend.
Repository: enthought/chaco

Issue:
Image plots have white gap between image and border
See the screenshot below, which displays the issue with the 'qt4.image' backend. This is also visible with the 'qt4.qpatiner' and 'wx.image' backends.

![screen shot 2014-09-30 at 12 24 12 pm](https://cloud.githubusercontent.com/assets/842366/4462948/62cd406c-48c7-11e4-8e30-564970ddbc29.png)



Discussion:

Resolving patch:
diff --git a/chaco/image_plot.py b/chaco/image_plot.py
--- a/chaco/image_plot.py
+++ b/chaco/image_plot.py
@@ -36,7 +36,7 @@ class ImagePlot(Base2DPlot):
 
     # The interpolation method to use when rendering an image onto the GC.
     interpolation = Enum("nearest", "bilinear", "bicubic")
-    
+
     #------------------------------------------------------------------------
     # Private traits
     #------------------------------------------------------------------------
@@ -129,7 +129,7 @@ def _compute_cached_image(self, data=None, mapper=None):
 
         The parameter *data* is for subclasses that might not store an RGB(A)
         image as the value, but need to compute one to display (colormaps, etc.).
-        
+
         The parameter *mapper* is also for subclasses that might not store an
         RGB(A) image as their value, and gives an opportunity to produce the
         values only for the visible region, rather than for the whole plot,
@@ -149,6 +149,11 @@ def _compute_cached_image(self, data=None, mapper=None):
         virtual_width = ur_x - ll_x
         virtual_height = ur_y - ll_y
 
+        # Convert to the coordinates of the graphics context, which expects
+        # origin to be at the center of a pixel.
+        ll_x += 0.5
+        ll_y += 0.5
+
         args = self.position \
              + self.bounds \
              + [ll_x, ll_y, virtual_width, virtual_height]
@@ -172,7 +177,7 @@ def _compute_cached_image(self, data=None, mapper=None):
 
             # Since data is row-major, j1 and j2 go first
             data = data[j1:j2, i1:i2]
-        
+
         if mapper is not None:
             data = mapper(data)
 
@@ -327,4 +332,4 @@ def _index_mapper_changed_fired(self):
     def _value_data_changed_fired(self):
         self._image_cache_valid = False
         self.request_redraw()
-        
+


Test patch:
Repository: enthought/chaco

Issue:
Demo world_map.py does not work on python 2
**Problem Description**
urllib.request deprecated in Python 2
**Reproduction Steps:**
Run world_map.py

**Expected behavior:**

Traceback (most recent call last):
  File "world_map.py", line 15, in <module>
    import urllib.request, urllib.parse, urllib.error
ImportError: No module named request

**OS, Python version:** [Enter OS name and Python version]
OSX, Python 2.7

xref: #385


Discussion:

Resolving patch:
diff --git a/examples/demo/world_map.py b/examples/demo/world_map.py
--- a/examples/demo/world_map.py
+++ b/examples/demo/world_map.py
@@ -12,7 +12,7 @@
 
 # Standard library imports
 import os.path
-import urllib.request, urllib.parse, urllib.error
+from six.moves.urllib import request
 
 # Major library imports
 import numpy
@@ -109,7 +109,7 @@ def _download_map_image(self):
 
         if not os.path.exists(self.image_path):
             print("Downloading map image")
-            urllib.request.urlretrieve(self.image_url, self.image_path)
+            request.urlretrieve(self.image_url, self.image_path)
 
 #===============================================================================
 # demo object that is used by the demo.py application.


Test patch:
Repository: enthought/chaco

Issue:
Demo quiver.py not working
**Problem Description**
Zooming in will ends with the following and blank plot.

**Reproduction Steps:**

Run the file and zoom in until the plot breaks.

**Expected behavior:**

Plot disappear if keep zooming in and ends with following trace.

```
Traceback (most recent call last):
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/qt4/base_window.py", line 202, in paintEvent
    self.handler.paintEvent(event)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/qt4/base_window.py", line 54, in paintEvent
    self._enable_window._paint(event)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/abstract_window.py", line 468, in _paint
    self.component.draw(gc, view_bounds=(0, 0, size[0], size[1]))
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/component.py", line 427, in draw
    self._draw(gc, view_bounds, mode)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/component.py", line 779, in _draw
    self._dispatch_draw(layer, gc, view_bounds, mode)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/container.py", line 272, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/container.py", line 272, in _dispatch_draw
    component._dispatch_draw(layer, gc, new_bounds, mode)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/enable/component.py", line 799, in _dispatch_draw
    handler(gc, view_bounds, mode)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/base_xy_plot.py", line 466, in _draw_plot
    self._draw_component(gc, view_bounds, mode)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/base_xy_plot.py", line 474, in _draw_component
    self._render(gc, pts)
  File "/Users/ktakami/.edm/envs/chaco-dev/lib/python2.7/site-packages/chaco/quiverplot.py", line 80, in _render
    ends = points + self._cached_vector_data
ValueError: operands could not be broadcast together with shapes (0,) (0,2)
```

**OS, Python version:** 
OSX, Python 2.7

splits from #385 


Discussion:

Resolving patch:
diff --git a/chaco/quiverplot.py b/chaco/quiverplot.py
--- a/chaco/quiverplot.py
+++ b/chaco/quiverplot.py
@@ -69,6 +69,9 @@ def _gather_points_old(self):
 
 
     def _render(self, gc, points, icon_mode=False):
+        if len(points) < 1:
+            return
+
         with gc:
             gc.clip_to_rect(self.x, self.y, self.width, self.height)
 


Test patch:
Repository: enthought/chaco

Issue:
Demo application doesn't show all demos in tree view
**Problem Description**

`examples/demo/demo.py` script doesn't show contents of `examples/demo` directory, only subfolders.

**Reproduction Steps:**

With Chaco installed, cd to `examples/demo` and run `python demo.py`

**Expected behavior:**

Files directly in the `examples/demo` subfolder should be shown in the tree view.

**OS, Python version:** All, all.

Note that this may require fixing in TraitsUI, which is where the core of the `demo.py` script is defined.



Discussion:

Resolving patch:
diff --git a/examples/demo/__init__.py b/examples/demo/__init__.py
new file mode 100644
diff --git a/examples/demo/demo.py b/examples/demo/demo.py
--- a/examples/demo/demo.py
+++ b/examples/demo/demo.py
@@ -21,6 +21,7 @@
 from traitsui.extras.demo import demo
 
 demo(
+    use_files=True,
     title='Chaco Demos'
 )
 


Test patch:
Repository: enthought/chaco

Issue:
bar_plot_stacked example unfinished?
**Problem Description**
The example in https://github.com/enthought/chaco/blob/master/examples/demo/basic/bar_plot_stacked.py
doesn't do any stacking.

**Expected behavior:**
I the bars were really stacked, I would expect the sum of all bars to reach (10+5+2) * array([1,2,3,4,5]) (the sum of all values) respectively. Instead, I am getting the following:
![Screen Shot 2019-05-31 at 10 19 28 AM](https://user-images.githubusercontent.com/593945/58716239-31772f80-838e-11e9-84a8-9a2588263a15.png)

Looking at the code, it doesn't use the bar plot's `starting_value` as expected, so the demo doesn't even seem to try to do the right thing.



Discussion:

Resolving patch:
diff --git a/examples/demo/basic/bar_plot_stacked.py b/examples/demo/basic/bar_plot_stacked.py
--- a/examples/demo/basic/bar_plot_stacked.py
+++ b/examples/demo/basic/bar_plot_stacked.py
@@ -11,7 +11,7 @@
 from traitsui.api import UItem, View
 
 # Chaco imports
-from chaco.api import LabelAxis, Plot, ArrayPlotData
+from chaco.api import LabelAxis, Plot, ArrayPlotData, ArrayDataSource
 
 class PlotExample(HasTraits):
     plot = Instance(Plot)
@@ -22,14 +22,18 @@ class PlotExample(HasTraits):
     def __init__(self, index, series_a, series_b, series_c, **kw):
         super(PlotExample, self).__init__(**kw)
 
+        # Stack them up
+        series_c = series_c + series_b + series_a
+        series_b = series_b + series_a
+
         plot_data = ArrayPlotData(index=index)
         plot_data.set_data('series_a', series_a)
         plot_data.set_data('series_b', series_b)
         plot_data.set_data('series_c', series_c)
         self.plot = Plot(plot_data)
         self.plot.plot(('index', 'series_a'), type='bar', bar_width=0.8, color='auto')
-        self.plot.plot(('index', 'series_b'), type='bar', bar_width=0.8, color='auto')
-        self.plot.plot(('index', 'series_c'), type='bar', bar_width=0.8, color='auto')
+        self.plot.plot(('index', 'series_b'), type='bar', bar_width=0.8, color='auto', starting_value=ArrayDataSource(series_a))
+        self.plot.plot(('index', 'series_c'), type='bar', bar_width=0.8, color='auto', starting_value=ArrayDataSource(series_b))
 
         # set the plot's value range to 0, otherwise it may pad too much
         self.plot.value_range.low = 0


Test patch:
Repository: enthought/chaco

Issue:
Demo noninteractive.py, Errors after <ENTER>
**Problem Description**
Errors after <ENTER>
**Reproduction Steps:**

Run noninteractive.py and hit ENTER

**Expected behavior:**
```
 Please enter a path in which to place generated plots.
Press <ENTER> to generate in the current directory.
Path:
Traceback (most recent call last):
  File "noninteractive.py", line 113, in <module>
    draw_plot(get_directory('noninteractive.png'), size=(800, 600))
  File "noninteractive.py", line 90, in get_directory
    path = input('Path: ').strip()
  File "<string>", line 0

    ^
SyntaxError: unexpected EOF while parsing
```
**OS, Python version:**
OSX, Python 2.7

xref: #385 


Discussion:

Resolving patch:
diff --git a/examples/demo/noninteractive.py b/examples/demo/noninteractive.py
--- a/examples/demo/noninteractive.py
+++ b/examples/demo/noninteractive.py
@@ -87,7 +87,14 @@ def draw_pdf(filename, size=(800, 600)):
 def get_directory(filename):
     print('Please enter a path in which to place generated plots.')
     print('Press <ENTER> to generate in the current directory.')
-    path = input('Path: ').strip()
+
+    # If python 2.7, use raw_input to parse empty string correctly
+    try:
+        get_input = raw_input
+    except NameError:
+        get_input = input
+
+    path = get_input('Path: ').strip()
 
     if len(path) > 0 and not os.path.exists(path):
         print('The given path does not exist.')


Test patch:
Repository: enthought/chaco

Issue:
Don't put Cythonized .c files in source control, but do ship in sdist
Currently we check-in .c files produced by Cython to the source tree alongside the .pyx files so that people building the source don't need to have Cython installed.  This is awkward from the developer's perspective, however, and can result in noisy deltas.

Following discussion in #325 the the proposal is that we will only check in the .pyx files into source control, but we will ship the .c files as part of the sdist source distributions.  This change will mean that people wishing to work from non-released versions will need to have Cython installed (as will the CI environment), but people wanting to build a release from source won't need it.  Having Cython available is not as unreasonable a requirement as it was several years ago.


Discussion:
> c files as part of the sdist source distributions.

to clarify, I think we should ship `only the c files`  in the source distribution not the `pyx`




I think we should ship the `.pyx` files as well and make sure they go into the installed package. Cython adds the appropriate line information to tracebacks, so we can see the code involved in the traceback if the `.pyx` files are installed.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -6,6 +6,7 @@
 
 from numpy import get_include
 from setuptools import setup, Extension, find_packages
+from Cython.Build import cythonize
 
 MAJOR = 4
 MINOR = 8
@@ -143,16 +144,19 @@ def write_version_py(filename=_VERSION_FILENAME):
 
     cython_speedups = Extension(
         'chaco._cython_speedups',
-        sources=['chaco/_cython_speedups.c'],
+        sources=['chaco/_cython_speedups.pyx'],
         include_dirs=[numpy_include_dir],
     )
 
     downsampling_lttb = Extension(
         'chaco.downsample._lttb',
-        sources=['chaco/downsample/_lttb.c'],
+        sources=['chaco/downsample/_lttb.pyx'],
         include_dirs=[numpy_include_dir],
     )
 
+    cython_extensions = cythonize([cython_speedups, downsampling_lttb])
+    extensions = [contour] + cython_extensions
+
     setup(
         name = 'chaco',
         version = __version__,
@@ -185,7 +189,7 @@ def write_version_py(filename=_VERSION_FILENAME):
         },
         description = 'interactive 2-dimensional plotting',
         long_description = open('README.rst').read(),
-        ext_modules = [contour, cython_speedups, downsampling_lttb],
+        ext_modules = extensions,
         include_package_data = True,
         install_requires = __requires__,
         license = 'BSD',


Test patch:
Repository: enthought/chaco

Issue:
Zoom broken in some demos
**Problem Description**
This bug affects the following demos:
* `shell/contour.py`
* `shell/contourf.py`
* `basic/contour_plot.py`

Mouse-scroll doesn't zoom the plot until the user pans the plot. After panning, the plot is really zoomed out.

**Reproduction Steps:**
Mouse-scroll, then left-drag.

```python
python shell/contour.py
```

**Expected behavior:**
Plot should zoom immediately on mouse-scroll.

**OS, Python version:**
MacOSX 10.14
Python3.6


Discussion:

Resolving patch:
diff --git a/chaco/base_contour_plot.py b/chaco/base_contour_plot.py
--- a/chaco/base_contour_plot.py
+++ b/chaco/base_contour_plot.py
@@ -142,33 +142,32 @@ def _index_data_changed_fired(self):
         # If the index data has changed, the reset the levels cache (which
         # also triggers all the other caches to reset).
         self._level_cache_valid = False
-        self.invalidate_draw()
+        self.invalidate_and_redraw()
 
     def _value_data_changed_fired(self):
         # If the index data has changed, the reset the levels cache (which
         # also triggers all the other caches to reset).
         self._level_cache_valid = False
-        self.invalidate_draw()
+        self.invalidate_and_redraw()
 
     def _index_mapper_changed_fired(self):
         # If the index mapper has changed, then we need to redraw
-        self.invalidate_draw()
+        self.invalidate_and_redraw()
 
     def _update_color_mapper(self):
         # If the color mapper has changed, then we need to recompute the
         # levels and cached data associated with that.
         self._level_cache_valid = False
-        self.invalidate_draw()
+        self.invalidate_and_redraw()
 
     def _levels_changed(self):
         self._update_levels()
-        self.invalidate_draw()
-        self.request_redraw()
+        self.invalidate_and_redraw()
 
     def _colors_changed(self):
         if self._level_cache_valid:
             self._update_colors()
-            self.invalidate_draw()
+            self.invalidate_and_redraw()
 
     #------------------------------------------------------------------------
     # Trait properties


Test patch:
Repository: enthought/chaco

Issue:
Switch on the default warning flag when running testsuite
See related https://github.com/enthought/envisage/issues/311

Deprecation warnings triggered during test runs are visible, but deprecation warnings triggered prior to when a unittest test case is loaded are by default hidden from the console.

With that, deprecation warnings from trait types definition do not show up from running the current test command, because the warnings occur at import time.


Discussion:

Resolving patch:
diff --git a/ci/edmtool.py b/ci/edmtool.py
--- a/ci/edmtool.py
+++ b/ci/edmtool.py
@@ -190,7 +190,8 @@ def test(runtime, toolkit, environment):
 
     environ['PYTHONUNBUFFERED'] = "1"
     commands = [
-        "edm run -e {environment} -- coverage run -m unittest discover -v chaco"
+        "edm run -e {environment} -- python -W default -m "
+        "coverage run -m unittest discover -v chaco"
     ]
 
     cwd = os.getcwd()


Test patch: