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

Issue:
FutureWarning in Pandas 0.24.0
Pandas 0.24.0 throws a `FutureWarning` when used with Altair 2.3.0 [here][1], which prevents the chart being rendered correctly. The message:

```
[my_virtualenv]/lib/python3.6/site-packages/altair/utils/core.py:294: FutureWarning: A future version of pandas will default to `skipna=True`. To silence this warning, pass `skipna=True|False` explicitly.
```

I notice that Altair's `requirements.txt` doesn't specify version. Would it be worth doing so?

[1]: https://github.com/altair-viz/altair/blob/v2.3.0/altair/utils/core.py#L294


Discussion:
@iaindillingham I just upgraded to pandas 0.24.0 and am using altair 2.3.0.
I am not getting the error you are seeing, my plots are showing up fine.

What platform are you on?
To confirm from what you said, did you get the error upon import of altair or after import and when plotting data?


Python 3.6 on Ubuntu 18.04. The error was raised when plotting data, not upon import. I'll try and reproduce.
I have now gotten the error.  
Interesting - it is happening on some of my plots and not on others.  I am trying to narrow it down.
@iaindillingham 
So far I can get it to come up if I am not declaring types for the fields.

For example:

x='actual'
vs
x='actual:Q'

Is that the case for you - that if you declare the type you don't get the error?
It looks like the warning is in pandas [infer_dtype](https://github.com/pandas-dev/pandas/blob/95f8dca47723192ddeed5a2f198d0521c687c9aa/pandas/_libs/lib.pyx#L1101) function, which we use in automatically determining the data type when not specified by the user [here](https://github.com/altair-viz/altair/blob/c4495f965db621e8bd0c2b3dd0390ef30ad33456/altair/utils/core.py#L72).
Yes, @afonit that's correct. Although only when I use the shorthand syntax, not when I supply a `type` kwarg.
Fix is to explicitly pass ``skipna=False`` in this line: https://github.com/altair-viz/altair/blob/c4495f965db621e8bd0c2b3dd0390ef30ad33456/altair/utils/core.py#L72

We'll have to do it carefully, though, because prior to pandas 0.20.0, ``infer_dtype`` takes no keyword arguments.

Resolving patch:
diff --git a/altair/utils/core.py b/altair/utils/core.py
--- a/altair/utils/core.py
+++ b/altair/utils/core.py
@@ -15,8 +15,12 @@
 
 try:
     from pandas.api.types import infer_dtype
-except ImportError: # Pandas before 0.20.0
+    # keywords required; see https://github.com/altair-viz/altair/issues/1314
+    _infer_dtype_kwds = {'skipna': False}
+except ImportError:
+    # This is the appropriate import for pandas < 0.20.0
     from pandas.lib import infer_dtype
+    _infer_dtype_kwds = {}  # no keywords allowed in pandas < 0.20
 
 from .schemapi import SchemaBase, Undefined
 
@@ -69,7 +73,7 @@ def infer_vegalite_type(data):
     data: Numpy array or Pandas Series
     """
     # Otherwise, infer based on the dtype of the input
-    typ = infer_dtype(data)
+    typ = infer_dtype(data, **_infer_dtype_kwds)
 
     # TODO: Once this returns 'O', please update test_select_x and test_select_y in test_api.py
 


Test patch:
Repository: vega/altair

Issue:
Calling add_selection() on a layered chart results in an invalid spec
Example:
```python
import altair as alt
import pandas as pd

df = pd.DataFrame({
    'x': range(5),
    'y1': [1, 3, 2, 4, 5],
    'y2': [2, 1, 4, 5, 3]
})

alt.layer(
  alt.Chart(df).mark_line().encode(x='x', y='y1'),
  alt.Chart(df).mark_line().encode(x='x', y='y2')
).add_selection(
    alt.selection_interval()
)
```
```err
JavaScript Error: Duplicate signal name: "selector012_x_1"

This usually means there's a typo in your chart specification. See the javascript console for the full traceback.
Calling add_selection() on a layered chart results in an invalid spec
Example:
```python
import altair as alt
import pandas as pd

df = pd.DataFrame({
    'x': range(5),
    'y1': [1, 3, 2, 4, 5],
    'y2': [2, 1, 4, 5, 3]
})

alt.layer(
  alt.Chart(df).mark_line().encode(x='x', y='y1'),
  alt.Chart(df).mark_line().encode(x='x', y='y2')
).add_selection(
    alt.selection_interval()
)
```
```err
JavaScript Error: Duplicate signal name: "selector012_x_1"

This usually means there's a typo in your chart specification. See the javascript console for the full traceback.


Discussion:
In the case of a layered chart, ``add_selection()`` should only add to the first chart, not all charts.
In the case of a layered chart, ``add_selection()`` should only add to the first chart, not all charts.

Resolving patch:
diff --git a/altair/vegalite/v3/api.py b/altair/vegalite/v3/api.py
--- a/altair/vegalite/v3/api.py
+++ b/altair/vegalite/v3/api.py
@@ -1882,8 +1882,7 @@ def add_selection(self, *selections):
         if not selections or not self.layer:
             return self
         copy = self.copy()
-        copy.layer = [chart.add_selection(*selections)
-                        for chart in copy.layer]
+        copy.layer[0] = copy.layer[0].add_selection(*selections)
         return copy
 
 


Test patch:
diff --git a/altair/vegalite/v3/tests/test_api.py b/altair/vegalite/v3/tests/test_api.py
--- a/altair/vegalite/v3/tests/test_api.py
+++ b/altair/vegalite/v3/tests/test_api.py
@@ -535,7 +535,15 @@ def test_facet_add_selections():
     assert chart1.to_dict() == chart2.to_dict()
 
 
-@pytest.mark.parametrize('charttype', [alt.layer, alt.concat, alt.hconcat, alt.vconcat])
+def test_layer_add_selection():
+    base = alt.Chart('data.csv').mark_point()
+    selection = alt.selection_single()
+    chart1 = alt.layer(base.add_selection(selection), base)
+    chart2 = alt.layer(base, base).add_selection(selection)
+    assert chart1.to_dict() == chart2.to_dict()
+
+
+@pytest.mark.parametrize('charttype', [alt.concat, alt.hconcat, alt.vconcat])
 def test_compound_add_selections(charttype):
     base = alt.Chart('data.csv').mark_point()
     selection = alt.selection_single()
Repository: vega/altair

Issue:
Fix simple typo: packge -> package
There is a small typo in setup.py.
Should read package rather than packge.




Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@ def get_install_requirements(path):
 
 
 def version(path):
-    """Obtain the packge version from a python file e.g. pkg/__init__.py
+    """Obtain the package version from a python file e.g. pkg/__init__.py
 
     See <https://packaging.python.org/en/latest/single_source_version.html>.
     """


Test patch:
Repository: vega/altair

Issue:
HTML renderer should use uuid in chart divs
Currently, divs are generated via chart counts. This means that if a kernel is restarted in the notebook, new charts may not display correctly.


Discussion:

Resolving patch:
diff --git a/altair/utils/display.py b/altair/utils/display.py
--- a/altair/utils/display.py
+++ b/altair/utils/display.py
@@ -2,6 +2,7 @@
 import pkgutil
 import textwrap
 from typing import Callable, Dict
+import uuid
 
 from jsonschema import validate
 
@@ -150,13 +151,11 @@ class HTMLRenderer(object):
     """Object to render charts as HTML, with a unique output div each time"""
     def __init__(self, output_div='altair-viz-{}', **kwargs):
         self._output_div = output_div
-        self._output_count = 0
         self.kwargs = kwargs
 
     @property
     def output_div(self):
-        self._output_count += 1
-        return self._output_div.format(self._output_count)
+        return self._output_div.format(uuid.uuid4().hex)
 
     def __call__(self, spec, **metadata):
         kwargs = self.kwargs.copy()


Test patch:
Repository: vega/altair

Issue:
Interval Selection Example Bug
I am having trouble with the the [Interval Selection Example](https://altair-viz.github.io/gallery/interval_selection.html). 
![interval-selection](https://user-images.githubusercontent.com/2041969/72012337-c813a500-3229-11ea-911c-d130c87ce01e.gif)

```python
import altair as alt
from vega_datasets import data

source = data.sp500.url

brush = alt.selection(type='interval', encodings=['x'])

upper = alt.Chart(source).mark_area().encode(
    alt.X('date:T', scale=alt.Scale(domain=brush)),
    y='price:Q'
).properties(
    width=600,
    height=200
)

lower = upper.properties(
    height=60
).add_selection(brush)

upper & lower
```

The example looks correct so I am unsure what is causing this behavior. 


Discussion:
Note the [Overview and Detail](https://vega.github.io/vega-lite/examples/interactive_overview_detail.html) example is working from the Vega-Lite examples.
I figured it out! In the upper chart we bind the domain to the brush and the lower chart is made from a copy of the upper chart with the same binding. 

I will refactor this example and submit a PR.

Resolving patch:
diff --git a/altair/examples/interval_selection.py b/altair/examples/interval_selection.py
--- a/altair/examples/interval_selection.py
+++ b/altair/examples/interval_selection.py
@@ -13,15 +13,19 @@
 
 brush = alt.selection(type='interval', encodings=['x'])
 
-upper = alt.Chart(source).mark_area().encode(
-    alt.X('date:T', scale=alt.Scale(domain=brush)),
-    y='price:Q'
+base = alt.Chart(source).mark_area().encode(
+    x = 'date:T',
+    y = 'price:Q'
 ).properties(
     width=600,
     height=200
 )
 
-lower = upper.properties(
+upper = base.encode(
+    alt.X('date:T', scale=alt.Scale(domain=brush))
+)
+
+lower = base.properties(
     height=60
 ).add_selection(brush)
 


Test patch:
Repository: vega/altair

Issue:
Schema validation error fails to print
```
$ cat test.py
import pandas, altair

d = [{'WijkenEnBuurten': 'Nederland', 'Codering_3': 'NL00', 'Mannen_6': 8475102, 'Vrouwen_7': 8606405, 'SoortRegio_2': 'Land      ', 'GeboorteRelatief_25': 9}, {'WijkenEnBuurten': 'Aa en Hunze', 'Codering_3': 'GM1680', 'Mannen_6': 12603, 'Vrouwen_7': 12683, 'SoortRegio_2': 'Gemeente  ', 'GeboorteRelatief_25': 6}]

df = pandas.DataFrame(d)
a = altair.Data(df)

$ python ./test.py
Traceback (most recent call last):
  File "./t_altair_schema.py", line 5, in <module>
    a = altair.Data(df)
  File "/home/paulm/.local/lib/python3.8/site-packages/altair/vegalite/v3/schema/core.py", line 3741, in __init__
    super(Data, self).__init__(*args, **kwds)
  File "/home/paulm/.local/lib/python3.8/site-packages/altair/utils/schemapi.py", line 154, in __init__
    self.to_dict(validate=True)
  File "/home/paulm/.local/lib/python3.8/site-packages/altair/utils/schemapi.py", line 302, in to_dict
    raise SchemaValidationError(self, err)
altair.utils.schemapi.SchemaValidationError: <exception str() failed>
```

Somehow the exception can't be turned into a string. I briefly looked at the relevant code in altair.utils.schemapi, but don't immediately see what is going wrong.

This is with Python 3.8.1, altair 3.2.0 on Arch Linux (64-bit)


Discussion:
Thanks for the report – this only appears to happen with Python 3.8, not with any other supported Py 3.X releases.

Resolving patch:
diff --git a/altair/utils/schemapi.py b/altair/utils/schemapi.py
--- a/altair/utils/schemapi.py
+++ b/altair/utils/schemapi.py
@@ -106,7 +106,7 @@ def __str__(self):
         cls = self.obj.__class__
         schema_path = ['{}.{}'.format(cls.__module__, cls.__name__)]
         schema_path.extend(self.schema_path)
-        schema_path = '->'.join(val for val in schema_path[:-1]
+        schema_path = '->'.join(str(val) for val in schema_path[:-1]
                                 if val not in ('properties',
                                                'additionalProperties',
                                                'patternProperties'))
diff --git a/tools/schemapi/schemapi.py b/tools/schemapi/schemapi.py
--- a/tools/schemapi/schemapi.py
+++ b/tools/schemapi/schemapi.py
@@ -102,7 +102,7 @@ def __str__(self):
         cls = self.obj.__class__
         schema_path = ['{}.{}'.format(cls.__module__, cls.__name__)]
         schema_path.extend(self.schema_path)
-        schema_path = '->'.join(val for val in schema_path[:-1]
+        schema_path = '->'.join(str(val) for val in schema_path[:-1]
                                 if val not in ('properties',
                                                'additionalProperties',
                                                'patternProperties'))


Test patch:
Repository: vega/altair

Issue:
Multiple views in JupyterLab blank with default html renderer
To reproduce:

1. Create an environment with JupyterLab 1.2.6 and altair 4.0.1:

```
conda create -c conda-forge -yn testenv jupyterlab altair pandas
conda activate testenv
```

2. Start JupyterLab:
```
jupyter lab
```
3. Create a new notebook with an example plot:

```
import altair as alt
import numpy as np
import pandas as pd

# Compute x^2 + y^2 across a 2D grid
x, y = np.meshgrid(range(-5, 5), range(-5, 5))
z = x ** 2 + y ** 2

# Convert this grid to columnar data expected by Altair
source = pd.DataFrame({'x': x.ravel(),
                     'y': y.ravel(),
                     'z': z.ravel()})

alt.Chart(source).mark_rect().encode(
    x='x:O',
    y='y:O',
    color='z:Q'
)
```
4. Right-click on the plot and choose "Create New view for output" to open a new jlab tab for the plot. The new tab is blank:
<img width="622" alt="Screen Shot 2020-02-24 at 11 22 23 AM" src="https://user-images.githubusercontent.com/192614/75183729-f70da980-56f7-11ea-8e25-bf11bfda8b9f.png">

I also see the same issue if opening a new view of the notebook (right-clicking on the file's tab, selecting "New View for Notebook"

I think at least part of the problem is that the plot div has a hard-coded id, and ids should be unique on a page, so viewing the same output multiple times can be a problem. There may be other issues with the js not knowing to redraw the plot in the new jlab tab, etc.



Discussion:
This is related to https://github.com/altair-viz/altair/pull/1888 - but I think #1888 didn't go far enough in making IDs unique on the client-side, at least for this case.

I think if there is a way to not use the html id attribute, but instead to search in the DOM for a specific nearby div with a given class or data attribute, that may be better.
Thanks!

Resolving patch:
diff --git a/altair/utils/html.py b/altair/utils/html.py
--- a/altair/utils/html.py
+++ b/altair/utils/html.py
@@ -85,7 +85,10 @@
 <div id="{{ output_div }}"></div>
 <script type="text/javascript">
   (function(spec, embedOpt){
-    const outputDiv = document.getElementById("{{ output_div }}");
+    let outputDiv = document.currentScript.previousElementSibling;
+    if (outputDiv.id !== "{{ output_div }}") {
+      outputDiv = document.getElementById("{{ output_div }}");
+    }
     const paths = {
       "vega": "{{ base_url }}/vega@{{ vega_version }}?noext",
       "vega-lib": "{{ base_url }}/vega-lib?noext",


Test patch:
Repository: vega/altair

Issue:
Options of `point` argument
Documentation of `point` argument in marks isn't very easily discoverable.

Recently I tried to create a chart with colored line and points. My first try was with `mark_line(color="red", point=True)`, similarly to [this example](https://altair-viz.github.io/gallery/line_chart_with_points.html), but it produced red line with blue points. This turned out to be current default behavior of Vega-lite (found in [this issue](https://github.com/vega/vega-lite/issues/6111)).

After some digging, I found that `point` can be "an object defining the properties of the overlayed points." (which seems to imply `OverlayMarkDef`, but simple dictionary showed to be enough). I think it would be really helpful to have this slightly easier to find. A "Line chart with points" example seems like a good place.

So, what do you think about adding some sort of variation of the following code snippet in that example?
```python
import altair as alt
import numpy as np
import pandas as pd

x = np.arange(100)
source = pd.DataFrame({"x": x, "f(x)": np.sin(x / 5)})

# Only this part will be added
alt.Chart(source).mark_line(
    color="red", point={"color": "red"}
).encode(
    x="x",
    y="f(x)"
)
```
![issue_altair_point-argument_example](https://user-images.githubusercontent.com/24854248/79694414-c5890880-8278-11ea-884b-ab9d4969b717.png)

If this is OK, I would like to help with PR. Thanks.


Discussion:
Sure, sounds good. I'd have a slight preference for using
```
point=alt.OverlayMarkDef(color='red')
```
because then people who are using editors with docstring/tab completion support can more easily see all the available options.

Resolving patch:
diff --git a/altair/examples/line_chart_with_points.py b/altair/examples/line_chart_with_points.py
--- a/altair/examples/line_chart_with_points.py
+++ b/altair/examples/line_chart_with_points.py
@@ -1,7 +1,9 @@
 """
 Line Chart with Points
 ----------------------
-This chart shows a simple line chart with points marking each value.
+This chart shows a simple line chart with points marking each value. Use
+``point=True`` for points with default appearance or customize it with
+``OverlayMarkDef()``.
 """
 # category: line charts
 import altair as alt
@@ -14,7 +16,9 @@
   'f(x)': np.sin(x / 5)
 })
 
-alt.Chart(source).mark_line(point=True).encode(
+alt.Chart(source).mark_line(
+    point=alt.OverlayMarkDef(color="red")
+).encode(
     x='x',
     y='f(x)'
 )


Test patch:
Repository: vega/altair

Issue:
Allow Paths in save()
Instead of allowing only string paths or file-likes, allow pathlib.Paths to be passed to `save()`.

Are these two the only places that would have to be changed?

https://github.com/altair-viz/altair/blob/54e03d403c1cec9ce2f2e8b14dc3d936c6686128/altair/utils/save.py#L8
https://github.com/altair-viz/altair/blob/54e03d403c1cec9ce2f2e8b14dc3d936c6686128/altair/utils/save.py#L72


Discussion:
I think these are the correct places to make the change. Additionally, I think similar changes would be required in [altair_saver](https://github.com/altair-viz/altair_saver), which altair delegates to for png & pdf saves.
In that case, let me try to take a crack at this!

Resolving patch:
diff --git a/altair/utils/save.py b/altair/utils/save.py
--- a/altair/utils/save.py
+++ b/altair/utils/save.py
@@ -1,11 +1,13 @@
 import json
+import pathlib
 
 from .mimebundle import spec_to_mimebundle
 
 
 def write_file_or_filename(fp, content, mode="w"):
-    """Write content to fp, whether fp is a string or a file-like object"""
-    if isinstance(fp, str):
+    """Write content to fp, whether fp is a string, a pathlib Path or a
+    file-like object"""
+    if isinstance(fp, str) or isinstance(fp, pathlib.PurePath):
         with open(fp, mode) as f:
             f.write(content)
     else:
@@ -34,8 +36,8 @@ def save(
     ----------
     chart : alt.Chart
         the chart instance to save
-    fp : string filename or file-like object
-        file in which to write the chart.
+    fp : string filename, pathlib.Path or file-like object
+        file to which to write the chart.
     format : string (optional)
         the format to write: one of ['json', 'html', 'png', 'svg'].
         If not specified, the format will be determined from the filename.
@@ -71,6 +73,8 @@ def save(
     if format is None:
         if isinstance(fp, str):
             format = fp.split(".")[-1]
+        elif isinstance(fp, pathlib.PurePath):
+            format = fp.suffix.lstrip(".")
         else:
             raise ValueError(
                 "must specify file format: " "['png', 'svg', 'pdf', 'html', 'json']"


Test patch:
diff --git a/altair/vegalite/v4/tests/test_api.py b/altair/vegalite/v4/tests/test_api.py
--- a/altair/vegalite/v4/tests/test_api.py
+++ b/altair/vegalite/v4/tests/test_api.py
@@ -4,6 +4,7 @@
 import json
 import operator
 import os
+import pathlib
 import tempfile
 
 import jsonschema
@@ -284,12 +285,14 @@ def test_save(format, basic_chart):
     fid, filename = tempfile.mkstemp(suffix="." + format)
     os.close(fid)
 
-    try:
-        basic_chart.save(filename)
-        with open(filename, mode) as f:
-            assert f.read()[:1000] == content[:1000]
-    finally:
-        os.remove(filename)
+    # test both string filenames and pathlib.Paths
+    for fp in [filename, pathlib.Path(filename)]:
+        try:
+            basic_chart.save(fp)
+            with open(fp, mode) as f:
+                assert f.read()[:1000] == content[:1000]
+        finally:
+            os.remove(fp)
 
 
 def test_facet_basic():
Repository: vega/altair

Issue:
Pandas dtype: Float64 is not supported
Hi,

I have installed: python 3.8.6, pandas 1.2.1 and altair 4.1.0.  In the pandas version 1.2.0 they introduced a new "experimental" data type for nullable floats. I know that this type is experimental but a proper handling for nullable data is really convenient. 

When I use this new type with altair I get a type error:

```python
df = pd.DataFrame({'a': [1, 2, 3, 4, 5], 'b': [1.1, 2.5, np.nan, 1, 3.3]})
df = df.convert_dtypes()  # convert b from float64 to Float64
chart = alt.Chart(df).mark_line().encode(
    x='a',
    y='b'
)
```

> TypeError: Cannot interpret 'Float64Dtype()' as a data type


Discussion:
Thanks - it looks like this arises from the fact that `np.issubdtype` does not understand pandas new dtypes, which is unfortunate. I suspect that breaks a lot of people's code.
Indeed, it seems to have broken dask as well: https://github.com/dask/dask/issues/7156

Resolving patch:
diff --git a/altair/utils/core.py b/altair/utils/core.py
--- a/altair/utils/core.py
+++ b/altair/utils/core.py
@@ -329,7 +329,9 @@ def to_list_if_array(val):
             "UInt16",
             "UInt32",
             "UInt64",
-        }:  # nullable integer datatypes (since 24.0)
+            "Float32",
+            "Float64",
+        }:  # nullable integer datatypes (since 24.0) and nullable float datatypes (since 1.2.0)
             # https://pandas.pydata.org/pandas-docs/version/0.25/whatsnew/v0.24.0.html#optional-integer-na-support
             col = df[col_name].astype(object)
             df[col_name] = col.where(col.notnull(), None)


Test patch:
Repository: vega/altair

Issue:
There are two U.S. Airports maps. There probably shouldn't be.
https://altair-viz.github.io/gallery/airports_count.html

https://altair-viz.github.io/gallery/airports.html

![Screenshot from 2022-06-30 14-42-01](https://user-images.githubusercontent.com/9993/176783857-c4d190a2-1d11-4ad0-b205-057ff3f979f9.png)
![Screenshot from 2022-06-30 14-42-04](https://user-images.githubusercontent.com/9993/176783877-a4afb4b9-b40f-4f88-b062-6ca6fbda55a0.png)



Discussion:

Resolving patch:
diff --git a/altair/examples/airports_count.py b/altair/examples/groupby-map.py
similarity index 79%
rename from altair/examples/airports_count.py
rename to altair/examples/groupby-map.py
--- a/altair/examples/airports_count.py
+++ b/altair/examples/groupby-map.py
@@ -1,8 +1,7 @@
 """
-Locations of US Airports
-========================
-This is a layered geographic visualization that shows the positions of US
-airports on a background of US states.
+Grouped Points with Proportional Symbols Map
+============================================
+This is a layered geographic visualization that groups points by state.
 """
 # category: maps
 import altair as alt
@@ -20,7 +19,7 @@
     height=300
 ).project('albersUsa')
 
-# airport positions on background
+# Airports grouped by state
 points = alt.Chart(airports).transform_aggregate(
     latitude='mean(latitude)',
     longitude='mean(longitude)',
diff --git a/altair/examples/airports.py b/altair/examples/point_map.py
similarity index 75%
rename from altair/examples/airports.py
rename to altair/examples/point_map.py
--- a/altair/examples/airports.py
+++ b/altair/examples/point_map.py
@@ -1,14 +1,16 @@
 """
-Locations of US Airports
-========================
-This is a layered geographic visualization that shows the positions of US
-airports on a background of US states.
+Point map
+=========
+This is a layered map that shows the positions of airports on a background of U.S. states.
 """
-# category: case studies
+# category: maps
 import altair as alt
 from vega_datasets import data
 
+# Read in points
 airports = data.airports()
+
+# Read in polygons from topojson
 states = alt.topo_feature(data.us_10m.url, feature='states')
 
 # US states background


Test patch: