internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: django-cms/django-filer

Issue:
Field verbose_name should use gettext_lazy
Hi, 
model field verbose_names should use gettext_lazy, because it creates migrations based on user language settings. 

https://github.com/django-cms/django-filer/blob/master/filer/models/foldermodels.py#L9

This is migration generated after upgrade to django-filer 3.0
![image](https://github.com/django-cms/django-filer/assets/10236315/f3cdd97e-dcfe-449b-a928-a574976417da)

Thanks.


Discussion:
Or maybe I am just wrong and it doesn't help, just a guess.
@mihalikv No, you're right.

As a general rule;

`gettext_lazy()` should be used for anything loaded at runtime:
* `models.py` (fields, `verbose_name`, `help_text`, function `short_description`);
* `forms.py` (`labels`, `help_text`, `empty_label`);
* `apps.py` (`verbose_name`).

`gettext()`should be used for any modules that are executed during the request process, such as `views.py`

Resolving patch:
diff --git a/filer/admin/folderadmin.py b/filer/admin/folderadmin.py
--- a/filer/admin/folderadmin.py
+++ b/filer/admin/folderadmin.py
@@ -13,7 +13,7 @@
 from django.core.exceptions import PermissionDenied, ValidationError
 from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
 from django.db import models, router
-from django.db.models import F, OuterRef, Subquery, Case, When
+from django.db.models import Case, F, OuterRef, Subquery, When
 from django.db.models.functions import Coalesce, Lower
 from django.http import HttpResponse, HttpResponseRedirect
 from django.shortcuts import get_object_or_404, render
diff --git a/filer/models/filemodels.py b/filer/models/filemodels.py
--- a/filer/models/filemodels.py
+++ b/filer/models/filemodels.py
@@ -229,9 +229,9 @@ def _move_file(self):
         self.is_public = not self.is_public
         self.file.delete_thumbnails()
         self.is_public = not self.is_public
+        src_file = src_storage.open(src_file_name)
         # This is needed because most of the remote File Storage backend do not
         # open the file.
-        src_file = src_storage.open(src_file_name)
         # Context manager closes file after reading contents
         with src_file.open() as f:
             content_file = ContentFile(f.read())
@@ -254,10 +254,14 @@ def _copy_file(self, destination, overwrite=False):
         src_file_name = self.file.name
         storage = self.file.storages['public' if self.is_public else 'private']
 
-        # This is needed because most of the remote File Storage backend do not
-        # open the file.
         src_file = storage.open(src_file_name)
-        src_file.open()
+        try:
+            # This is needed because most of the remote File Storage backend do not
+            # open the file. Re-opening would create a value error.
+            src_file.open()
+        except ValueError:  # pragma: no cover
+            # If a validation error is raised, the file is already open.
+            pass
         return storage.save(destination, ContentFile(src_file.read()))
 
     def generate_sha1(self):


Test patch:
Repository: django-cms/django-filer

Issue:
Field verbose_name should use gettext_lazy
Hi, 
model field verbose_names should use gettext_lazy, because it creates migrations based on user language settings. 

https://github.com/django-cms/django-filer/blob/master/filer/models/foldermodels.py#L9

This is migration generated after upgrade to django-filer 3.0
![image](https://github.com/django-cms/django-filer/assets/10236315/f3cdd97e-dcfe-449b-a928-a574976417da)

Thanks.


Discussion:
Or maybe I am just wrong and it doesn't help, just a guess.
@mihalikv No, you're right.

As a general rule;

`gettext_lazy()` should be used for anything loaded at runtime:
* `models.py` (fields, `verbose_name`, `help_text`, function `short_description`);
* `forms.py` (`labels`, `help_text`, `empty_label`);
* `apps.py` (`verbose_name`).

`gettext()`should be used for any modules that are executed during the request process, such as `views.py`

Resolving patch:
diff --git a/filer/admin/fileadmin.py b/filer/admin/fileadmin.py
--- a/filer/admin/fileadmin.py
+++ b/filer/admin/fileadmin.py
@@ -167,7 +167,7 @@ def get_urls(self):
         return super().get_urls() + [
             path("icon/<int:file_id>/<int:size>",
                  self.admin_site.admin_view(self.icon_view),
-                 name="filer_file_fileicon")
+                 name=f"filer_{self.model._meta.model_name}_fileicon")
         ]
 
     def icon_view(self, request, file_id: int, size: int) -> HttpResponse:


Test patch:
Repository: vega/altair

Issue:
to_dict() not in Chart.__dir__
All in title.



Discussion:

Resolving patch:
diff --git a/altair/schema/baseobject.py b/altair/schema/baseobject.py
--- a/altair/schema/baseobject.py
+++ b/altair/schema/baseobject.py
@@ -115,7 +115,7 @@ def __contains__(self, key):
 
     def __dir__(self):
         """Customize tab completed attributes."""
-        return list(self.traits())
+        return list(self.traits())+['to_dict', 'from_dict']
 
     @classmethod
     def from_dict(cls, dct):


Test patch:
Repository: vega/altair

Issue:
FutureWarning in Pandas 0.20.1
Since upgrading to Pandas 0.20.1 I get this warning when first using altair in a notebook.

```
site-packages\altair\utils\core.py:110: FutureWarning: pandas.lib is deprecated and will be removed in a future version.
You can access infer_dtype as pandas.api.types.infer_dtype
  typ = pd.lib.infer_dtype(data)
```


Discussion:

Resolving patch:
diff --git a/altair/utils/core.py b/altair/utils/core.py
--- a/altair/utils/core.py
+++ b/altair/utils/core.py
@@ -7,6 +7,10 @@
 import pandas as pd
 import numpy as np
 
+try:
+    from pandas.api.types import infer_dtype
+except ImportError: # Pandas before 0.20.0
+    from pandas.lib import infer_dtype
 
 TYPECODE_MAP = {'ordinal': 'O',
                 'nominal': 'N',
@@ -107,7 +111,7 @@ def infer_vegalite_type(data, field=None):
             return parsed['type']
 
     # Otherwise, infer based on the dtype of the input
-    typ = pd.lib.infer_dtype(data)
+    typ = infer_dtype(data)
 
     # TODO: Once this returns 'O', please update test_select_x and test_select_y in test_api.py
 


Test patch:
Repository: vega/altair

Issue:
Default Mark Property
I came accross a problem with the display of altair plots in Jupyter notebooks.
Take the following code, where df is any dataset:
    
    from altair import Chart
    Chart(df).to_dict().get('mark')
    
This would return 'point' in altair 1.0.0. In altair 1.2.0 this returns None, which results in a javascript error of the jupyter-vega extension and no display of the plot.

If the latter behavior is anticipated (i.e. the mark property of vega-lite plots may be undefined) the jupyter-vega extension would need a fix.

Niels


Discussion:
Thanks! Yes, I'd noticed that changed, but hadn't appreciated the consequences. We'll make sure to fix this in the upcoming 2.0 release.
I marked this as 1.3 as it should be easy to fix.

Resolving patch:
diff --git a/altair/api.py b/altair/api.py
--- a/altair/api.py
+++ b/altair/api.py
@@ -369,6 +369,7 @@ class Chart(schema.ExtendedUnitSpec, TopLevelMixin):
                           help=schema.ExtendedUnitSpec.encoding.help)
     transform = T.Instance(Transform, allow_none=True, default_value=None,
                            help=schema.ExtendedUnitSpec.transform.help)
+    mark = schema.Mark(allow_none=True, default_value='point', help="""The mark type.""")
 
     @property
     def data(self):
diff --git a/altair/expr/core.py b/altair/expr/core.py
--- a/altair/expr/core.py
+++ b/altair/expr/core.py
@@ -224,6 +224,7 @@ class DataFrame(object):
       "data": {
         "url": "url/to/my/data.json"
       },
+      "mark": "point",
       "transform": {
         "calculate": [
           {


Test patch:
diff --git a/altair/tests/test_api.py b/altair/tests/test_api.py
--- a/altair/tests/test_api.py
+++ b/altair/tests/test_api.py
@@ -20,6 +20,12 @@ def make_chart():
     return Chart(data).mark_point().encode(x='x', y='y')
 
 
+def test_default_mark():
+    """Make sure the default mark is a point."""
+    c = Chart()
+    assert c.mark=='point'
+
+
 def test_mark_methods():
     """Make sure the Chart's mark_*() methods all exist"""
     from ..schema import Mark
Repository: vega/altair

Issue:
Pin vega version in requirements
To make sure things still work when ipyvega is updated (as it already has been)


Discussion:

Resolving patch:
diff --git a/altair/__init__.py b/altair/__init__.py
--- a/altair/__init__.py
+++ b/altair/__init__.py
@@ -1,3 +1,3 @@
-__version__ = '1.3.0.dev0'
+__version__ = '1.2.1.dev0'
 
 from .v1 import *
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -59,7 +59,7 @@
 URL                 = 'http://altair-viz.github.io'
 DOWNLOAD_URL        = 'http://github.com/altair-viz/altair/'
 LICENSE             = 'BSD 3-clause'
-INSTALL_REQUIRES    = ['traitlets>=4.3.1','ipython','pandas','vega>=0.4.4']
+INSTALL_REQUIRES    = ['traitlets>=4.3.1','ipython','pandas','vega==0.4.4']
 
 
 import io


Test patch:
Repository: vega/altair

Issue:
Logo for Website
It would be nice to have a logo for the website. I'm personally horribly unskilled at such things...



Discussion:
I'm not great at this but here's a rough version of what I created:
<img width="145" alt="screen shot 2016-11-01 at 10 43 24 pm" src="https://cloud.githubusercontent.com/assets/1320475/19916061/a616a8f6-a084-11e6-82c7-f4e35fc53a91.png">
- This is a (flat) image of a space telescope observing some stars. The telescope corresponds to the data visualization tool.
- The stars are colored by constellations. This corresponds to the data visualization tool pulling out previously unseen relationships.
- It shows the big dipper, cancer and the summer triangle (of which stars vega and altair are members)

I like the astronomy theme, but then again I would :smile: 🌠 

I think the final logo should be a bit less busy but this is a great start! 
I am having a new designer start right now and will have them look at this.
Two options for logos. Trying to evoke "Alt" visually while also communicating visualization. 

First with overlapping bars:

![frame 5](https://user-images.githubusercontent.com/27600/31855392-3eaa5d42-b65f-11e7-9980-2b3da45185a7.png)

And a flatter version:

![frame 4](https://user-images.githubusercontent.com/27600/31855390-36914238-b65f-11e7-8f7e-d0e44d028283.png)


@domoritz this visual language could be adapted for Vega-Lite too:

![frame 6](https://user-images.githubusercontent.com/27600/31855431-16f2af9c-b660-11e7-9b58-08da6d226240.png)

I would do some color variation though.
That's really nice! I think I prefer the overlapping one

Resolving patch:
diff --git a/doc/conf.py b/doc/conf.py
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -143,7 +143,7 @@
 
 # The name of an image file (relative to this directory) to place at the top
 # of the sidebar.
-#html_logo = None
+html_logo = '_images/altair-logo-light.png'
 
 # The name of an image file (relative to this directory) to use as a favicon of
 # the docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32


Test patch:
Repository: vega/altair

Issue:
Two renderers with same name
Working with a fresh Anaconda installation of Jupyter 3.6.  Followed Altair Notebook installation instructions.  Basic example (flower petals scatter plot) rendered but with JSON underneath graph (issue #634).  I thought this might be due to having selected the wrong renderer., so I went to list the available renderers. 

`alt.renderers.names()`
returns
`['default', 'json', 'notebook', 'notebook']`

Secretly hoping the second `notebook` renderer solves  #634.  In any case, I think you shouldn't be able to have two renderers with the same name.  

(hs teacher, maybe I'm missing something)


Discussion:
Strange... I'll look into it, but it doesn't solve #634. Still waiting for advice from @ellisonbg on that one.
In the meantime, I'd suggest using JupyerLab... that bug doesn't come up, and there's no need to think about renderers at all.
Yup.  JupyterLab solves all the problems including #634 and #687.  Thanks for getting me to move on to Python 3 and JupyterLab.

BTW: Having trouble getting this all working in Azure (which is a safer place for my students), but that's an Azure issue.  
We should try to get it working with Azure... it might take a little tweaking, depending on how they've set things up. A week ago I implemented a Colab renderer. That might actually work out-of-the-box with Azure.
I can't reproduce this duplicate renderer. What environment are you in?

Resolving patch:
diff --git a/altair/utils/plugin_registry.py b/altair/utils/plugin_registry.py
--- a/altair/utils/plugin_registry.py
+++ b/altair/utils/plugin_registry.py
@@ -75,7 +75,7 @@ def names(self) -> List[str]:
         exts = list(self._plugins.keys())
         more_exts = [ep.name for ep in entrypoints.get_group_all(self.entry_point_group)]
         exts.extend(more_exts)
-        return exts
+        return sorted(set(exts))
 
 
     def enable(self, name: str) -> None:


Test patch:
Repository: vega/altair

Issue:
Fix vega-embed version for Altair 1
For example in https://github.com/altair-viz/altair/blob/d4d29ca06e920f71073766c6456d387e682cee17/altair/vegalite/v1/html.py#L7


Discussion:
What version of vega-embed should we use with vega-lite 1.X and vega 2.X?
I think embed@2. I'm surprised that embed@3 works.
It probably doesn't... we don't actually test this anywhere :smile:

Resolving patch:
diff --git a/altair/vegalite/v1/html.py b/altair/vegalite/v1/html.py
--- a/altair/vegalite/v1/html.py
+++ b/altair/vegalite/v1/html.py
@@ -4,7 +4,7 @@
 <head>
   <script src="https://cdn.jsdelivr.net/npm/vega@2"></script>
   <script src="https://cdn.jsdelivr.net/npm/vega-lite@1"></script>
-  <script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script>
+  <script src="https://cdn.jsdelivr.net/npm/vega-embed@2"></script>
 </head>
 <body>
   <div id="vis"></div>


Test patch:
Repository: vega/altair

Issue:
BUG: if selenium is installed but not properly configured, Altair cannot be imported
Fix is to use a more robust lazy import of selenium.

The main issue is that ``import altair`` ends up trying to import selenium. It would be better if selenium weren't imported until it is actually needed. Same for other optional imports.


Discussion:
Bokeh has an interesting lazy import mechanism that we might think about adopting.

Resolving patch:
diff --git a/altair/utils/headless.py b/altair/utils/headless.py
--- a/altair/utils/headless.py
+++ b/altair/utils/headless.py
@@ -6,11 +6,6 @@
 import os
 import tempfile
 
-try:
-    import selenium.webdriver
-except ImportError:
-    selenium = None
-
 
 @contextlib.contextmanager
 def temporary_filename(**kwargs):
@@ -110,9 +105,15 @@ def temporary_filename(**kwargs):
 def compile_spec(spec, format, mode,
                  vega_version, vegaembed_version, vegalite_version,
                  scale_factor=1, driver_timeout=20, webdriver='chrome'):
-  
     # TODO: detect & use local Jupyter caches of JS packages?
 
+    # selenium is an optional dependency, so import it here
+    try:
+        import selenium.webdriver
+    except ImportError:
+        raise ImportError("selenium package is required "
+                          "for saving chart as {0}".format(format))
+
     if format not in ['png', 'svg', 'vega']:
         raise NotImplementedError("format must be 'svg', 'png' or 'vega'")
 
@@ -128,9 +129,6 @@ def compile_spec(spec, format, mode,
     if mode == 'vega-lite' and vegalite_version is None:
         raise ValueError("must specify vega-lite version")
 
-    if selenium is None:
-        raise ImportError("selenium package is required "
-                          "for saving chart as {0}".format(format))
     if webdriver == 'chrome':
         webdriver_class = selenium.webdriver.Chrome
         webdriver_options_class = selenium.webdriver.chrome.options.Options


Test patch:
Repository: vega/altair

Issue:
scatter-matrix example don't fit into screen
https://altair-viz.github.io/gallery/scatter_matrix.html#scatter-matrix
![image](https://user-images.githubusercontent.com/11561581/42128898-7df8a956-7cbe-11e8-8aa7-65e8621259c0.png)
```python
#...
).properties(
    width=150, # suggested instead of 250
    height=150 # suggested instead of 250
).repeat(
#...
```


Discussion:

Resolving patch:
diff --git a/altair/vegalite/v2/examples/scatter_matrix.py b/altair/vegalite/v2/examples/scatter_matrix.py
--- a/altair/vegalite/v2/examples/scatter_matrix.py
+++ b/altair/vegalite/v2/examples/scatter_matrix.py
@@ -13,8 +13,8 @@
     alt.Y(alt.repeat("row"), type='quantitative'),
     color='Origin:N'
 ).properties(
-    width=250,
-    height=250
+    width=150,
+    height=150
 ).repeat(
     row=['Horsepower', 'Acceleration', 'Miles_per_Gallon'],
     column=['Miles_per_Gallon', 'Acceleration', 'Horsepower']


Test patch:
Repository: vega/altair

Issue:
SelectionNot is not appropriately serialized
See https://github.com/altair-viz/altair/issues/695#issuecomment-411506890 and https://github.com/altair-viz/altair/issues/695#issuecomment-411536841


Discussion:
Issue is that ``SelectionNot`` returns ``{'not': 'selection_name'}`` which is valid within a conditional, but not within a filter.

Alternatives are ``{'selection': {'not': 'selection_name'}}`` or ``{'not': {'selection': 'selection_name'}}``.  Difference is whether the ``not`` comes from ``definitions.SelectionNot`` or from ``LogicalNot<Predicate>`` definitions.
Currently ``transform_filter`` special-cases selections here:
https://github.com/altair-viz/altair/blob/e744f1b343ee7ecb92846bb2db24c63f7ef66ea5/altair/vegalite/v2/api.py#L833-L834
 it should also special-case selection operands.

Resolving patch:
diff --git a/altair/vegalite/v2/api.py b/altair/vegalite/v2/api.py
--- a/altair/vegalite/v2/api.py
+++ b/altair/vegalite/v2/api.py
@@ -830,8 +830,12 @@ def transform_filter(self, filter, **kwargs):
         alt.FilterTransform : underlying transform object
 
         """
+        selection_predicates = (core.SelectionNot, core.SelectionOr,
+                                core.SelectionAnd, core.SelectionOperand)
         if isinstance(filter, NamedSelection):
-            filter = filter.ref()
+            filter = {'selection': filter._get_name()}
+        elif isinstance(filter, selection_predicates):
+            filter = {'selection': filter}
         return self._add_transform(core.FilterTransform(filter=filter, **kwargs))
 
     def transform_lookup(self, as_=Undefined, from_=Undefined, lookup=Undefined, default=Undefined, **kwargs):


Test patch:
diff --git a/altair/vegalite/v2/tests/test_api.py b/altair/vegalite/v2/tests/test_api.py
--- a/altair/vegalite/v2/tests/test_api.py
+++ b/altair/vegalite/v2/tests/test_api.py
@@ -336,6 +336,24 @@ def test_transforms():
                                                        window=window[::-1])])
 
 
+def test_filter_transform_selection_predicates():
+    selector1 = alt.selection_interval(name='s1')
+    selector2 = alt.selection_interval(name='s2')
+    base = alt.Chart('data.txt').mark_point()
+
+    chart = base.transform_filter(selector1)
+    assert chart.to_dict()['transform'] == [{'filter': {'selection': 's1'}}]
+
+    chart = base.transform_filter(~selector1)
+    assert chart.to_dict()['transform'] == [{'filter': {'selection': {'not': 's1'}}}]
+
+    chart = base.transform_filter(selector1 & selector2)
+    assert chart.to_dict()['transform'] == [{'filter': {'selection': {'and': ['s1', 's2']}}}]
+
+    chart = base.transform_filter(selector1 | selector2)
+    assert chart.to_dict()['transform'] == [{'filter': {'selection': {'or': ['s1', 's2']}}}]
+
+
 
 def test_resolve_methods():
     chart = alt.LayerChart().resolve_axis(x='shared', y='independent')
Repository: vega/altair

Issue:
Incorrect description of an example
https://altair-viz.github.io/gallery/scatter_linked_brush.html

The title of the page says "Faceted Scatter Plot with Linked Brushing".
But the example is a concatenated view, not a faceted view. 
(The data points are shown twice in the visualization, not split by a category.) 


Discussion:

Resolving patch:
diff --git a/altair/vegalite/v2/examples/scatter_linked_brush.py b/altair/vegalite/v2/examples/scatter_linked_brush.py
--- a/altair/vegalite/v2/examples/scatter_linked_brush.py
+++ b/altair/vegalite/v2/examples/scatter_linked_brush.py
@@ -1,8 +1,8 @@
 """
-Faceted Scatter Plot with Linked Brushing
------------------------------------------
+Multi-panel Scatter Plot with Linked Brushing
+---------------------------------------------
 This is an example of using an interval selection to control the color of
-points across multiple facets.
+points across multiple panels.
 """
 # category: interactive charts
 import altair as alt


Test patch:
Repository: vega/altair

Issue:
line_percent.py does not work offline
We need all examples to work offline. Currently ``line_percent.py`` uses ``pd.read_json`` from a URL.

The example should probably use a URL plus a filter.


Discussion:
Same issue with ``boxplot_max_min.py``.

Resolving patch:
diff --git a/altair/examples/boxplot_max_min.py b/altair/examples/boxplot_max_min.py
--- a/altair/examples/boxplot_max_min.py
+++ b/altair/examples/boxplot_max_min.py
@@ -7,7 +7,7 @@
 import altair as alt
 from vega_datasets import data
 
-source = data.population()
+source = data.population.url
 
 base = alt.Chart(source)
 
diff --git a/altair/examples/line_percent.py b/altair/examples/line_percent.py
--- a/altair/examples/line_percent.py
+++ b/altair/examples/line_percent.py
@@ -5,14 +5,14 @@
 """
 # category: line charts
 import altair as alt
-import pandas as pd
 from vega_datasets import data
 
-source = pd.read_json(data.jobs.url)
-welders = source[source.job == 'Welder']
+source = data.jobs.url
 
-alt.Chart(welders).mark_line().encode(
+alt.Chart(source).mark_line().encode(
     alt.X('year:O'),
     alt.Y('perc:Q', axis=alt.Axis(format='%')),
     color='sex:N'
+).transform_filter(
+    alt.datum.job == 'Welder'
 )


Test patch: