anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: pydata/xarray
Issue: Inconsistent behavior between `DatasetRolling.construct` and `DataArrayRolling.construct` with stride > 1.

### What is your issue?

INSTALLED VERSIONS
------------------
commit: None
python: 3.8.10 | packaged by conda-forge | (default, May 11 2021, 07:01:05) 
[GCC 9.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-73-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.9.0

xarray: 2022.6.0
pandas: 1.4.2
numpy: 1.19.5
scipy: 1.7.0
netCDF4: 1.6.0
pydap: None
h5netcdf: 1.0.2
h5py: 3.1.0
Nio: None
zarr: 2.12.0
cftime: 1.6.1
nc_time_axis: None
PseudoNetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.3.4
dask: 2021.06.2
distributed: 2021.06.2
matplotlib: 3.5.3
cartopy: None
seaborn: 0.12.0
numbagg: None
fsspec: 2021.07.0
cupy: 9.2.0
pint: None
sparse: 0.13.0
flox: None
numpy_groupies: None
setuptools: 49.6.0.post20210108
pip: 21.1.3
conda: 4.10.3
pytest: 6.2.4
IPython: 7.24.1
sphinx: None
## Reproducing the problem
I have an xarray Dataset with a single dimension as specified. (Or any arbitrary  Xarray's `Dataset`
```
> Dimensions:
> time: 11058688
```
When applied rolling operation on `DataArray` with no overlapping window, it is working as one would normally expected.
```python
dataset.var_a.rolling(k=256).construct('w', stride=256)
```
`11058688 / 256 = 43198`
```
> Dimensions:
> time: 43198, k:  256   # 43198 windows
```

However when applying the same operation to the `Dataset`:

```python
dataset.rolling(k=256).construct('w', stride=256)
```
```
> Dimensions:
> time: 169, k:  256   # How can we even arrived at 169 windows?
```

I don't see any reasons why should rolling on `Dataset` and `DataArray` should behave differently. Shouldn't rolling on dataset is just repeating `DataArray` rolling on every data variable?
This differing behavior is not mentioned on the documentation either.

Changed files:
xarray/core/rolling.py

diff --git a/xarray/core/rolling.py b/xarray/core/rolling.py
index 8b9f31bfd..82245e0b5 100644
--- a/xarray/core/rolling.py
+++ b/xarray/core/rolling.py
@@ -780,9 +780,7 @@ class DatasetRolling(Rolling["Dataset"]):
 
         attrs = self.obj.attrs if keep_attrs else {}
 
-        return Dataset(dataset, coords=self.obj.coords, attrs=attrs).isel(
-            {d: slice(None, None, s) for d, s in zip(self.dim, strides)}
-        )
+        return Dataset(dataset, coords=self.obj.coords, attrs=attrs)
 
 
 class Coarsen(CoarsenArithmetic, Generic[T_Xarray]):
Repository: pydata/xarray
Issue: BUG: xray fails to read netCDF files where coordinates do not refer to valid variables

Instead, we should verify that that coordinates refer to valid variables and fail gracefully.

As reported by @mgarvert.


Changed files:
xray/test/test_conventions.py, xray/conventions.py

diff --git a/xray/conventions.py b/xray/conventions.py
index 315f0452e..ce30dd5db 100644
--- a/xray/conventions.py
+++ b/xray/conventions.py
@@ -696,9 +696,12 @@ def decode_cf_variables(variables, attributes, concat_characters=True,
             v, concat_characters=concat, mask_and_scale=mask_and_scale,
             decode_times=decode_times)
         if decode_coords:
-            coordinates = new_vars[k].attrs.pop('coordinates', None)
-            if coordinates is not None:
-                coord_names.update(coordinates.split())
+            var_attrs = new_vars[k].attrs
+            if 'coordinates' in var_attrs:
+                var_coord_names = var_attrs['coordinates'].split()
+                if all(k in variables for k in var_coord_names):
+                    coord_names.update(var_coord_names)
+                    del var_attrs['coordinates']
 
     if decode_coords and 'coordinates' in attributes:
         attributes = OrderedDict(attributes)
diff --git a/xray/test/test_conventions.py b/xray/test/test_conventions.py
index 8fd02bb15..f00991e22 100644
--- a/xray/test/test_conventions.py
+++ b/xray/test/test_conventions.py
@@ -347,6 +347,12 @@ class TestDecodeCF(TestCase):
         actual = conventions.decode_cf(original)
         self.assertDatasetIdentical(expected, actual)
 
+    def test_invalid_coordinates(self):
+        # regression test for GH308
+        original = Dataset({'foo': ('t', [1, 2], {'coordinates': 'invalid'})})
+        actual = conventions.decode_cf(original)
+        self.assertDatasetIdentical(original, actual)
+
 
 class CFEncodedInMemoryStore(InMemoryDataStore):
     def store(self, variables, attributes):
Repository: pydata/xarray
Issue: Aggregations on datasets drop data variables with dtype=bool

```
>>> xray.Dataset({'x': 1}).isnull().sum()
<xray.Dataset>
Dimensions:  ()
Coordinates:
    *empty*
Data variables:
    *empty*
```

This is a bug.


Changed files:
xray/core/dataset.py, xray/test/test_dataset.py

diff --git a/xray/core/dataset.py b/xray/core/dataset.py
index c25b1d3e0..75affd31e 100644
--- a/xray/core/dataset.py
+++ b/xray/core/dataset.py
@@ -1529,7 +1529,7 @@ class Dataset(Mapping, ImplementsDatasetReduce, AttrAccessMixin):
             reduce_dims = [dim for dim in var.dims if dim in dims]
             if reduce_dims or not var.dims:
                 if name not in self.coords:
-                    if not numeric_only or var.dtype.kind in 'ifc':
+                    if not numeric_only or var.dtype.kind in 'ifcb':
                         if len(reduce_dims) == var.ndim:
                             # prefer to aggregate over axis=None rather than
                             # axis=(0, 1) if they will be equivalent, because
diff --git a/xray/test/test_dataset.py b/xray/test/test_dataset.py
index 1cacff12e..2bb55c8fa 100644
--- a/xray/test/test_dataset.py
+++ b/xray/test/test_dataset.py
@@ -1497,6 +1497,12 @@ class TestDataset(TestCase):
         self.assertDatasetEqual(data1.mean(dim='dim1'),
                                 data2.mean(dim='dim1'))
 
+    def test_reduce_dtype_bool(self):
+        # regression test for GH342
+        expected = Dataset({'x': 1})
+        actual = Dataset({'x': True}).sum()
+        self.assertDatasetIdentical(expected, actual)
+
     def test_reduce_keep_attrs(self):
         data = create_test_data()
         _attrs = {'attr1': 'value1', 'attr2': 2929}
Repository: kubernetes-sigs/cluster-api
Issue: cmd/clusterctl/hack/create-local-repository.py does not work with Python 3

**What steps did you take and what happened:**
[A clear and concise description on how to REPRODUCE the bug.]

On a machine where `python` runs Python version 3.8.2:
```
$ cmd/clusterctl/hack/create-local-repository.py
Traceback (most recent call last):
  File "cmd/clusterctl/hack/create-local-repository.py", line 182, in create_dev_config
    f.write(yaml)
TypeError: a bytes-like object is required, not 'str'
```

**What did you expect to happen:**

Expected it to run without throwing a low-level error.

**Anything else you would like to add:**

On this line: https://github.com/kubernetes-sigs/cluster-api/blob/5164a1f0e2a9f4bb6c1c3ebe304877ee470ac9c5/cmd/clusterctl/hack/create-local-repository.py#L181
changing `wb` to `w` appears to get past the problem.


**Environment:**

- Cluster-api version: commit 5164a1f0e2a9f4bb6c1c3ebe304877ee470ac9c5 on master

/kind bug

 


Changed files:
cmd/clusterctl/hack/create-local-repository.py

diff --git a/cmd/clusterctl/hack/create-local-repository.py b/cmd/clusterctl/hack/create-local-repository.py
index 171f92dea..4ca3a5ab8 100755
--- a/cmd/clusterctl/hack/create-local-repository.py
+++ b/cmd/clusterctl/hack/create-local-repository.py
@@ -126,7 +126,7 @@ def write_local_repository(provider, version, components_file, components_yaml):
             if e.errno != errno.EEXIST:
                 raise
         components_path = os.path.join(provider_folder, components_file)
-        f = open(components_path, 'wb')
+        f = open(components_path, 'w')
         f.write(components_yaml)
         f.close()
 
@@ -178,7 +178,7 @@ def create_dev_config(repos):
     try:
         repository_folder = get_repository_folder()
         config_path = os.path.join(repository_folder, "config.yaml")
-        f = open(config_path, 'wb')
+        f = open(config_path, 'w')
         f.write(yaml)
         f.close()
         return components_path
Repository: ibis-project/ibis
Issue: WebHDFS.write has trouble with StringIO/BytesIO types

It hangs for a while and then gives `ConnectionError: ('Connection aborted.', BadStatusLine("''",))`.  As a temporary workaround, I will get a string version of the data by calling `getvalue` before transmitting the data.  This shouldn't cause too many surprises, bc if the user wants to write a file, they can just specify the path.  But this should be fixed.  It appears the problem is in the python `requests` library.


Changed files:
ibis/filesystems.py

diff --git a/ibis/filesystems.py b/ibis/filesystems.py
index 90d7e953ba..d61e2272cf 100644
--- a/ibis/filesystems.py
+++ b/ibis/filesystems.py
@@ -327,11 +327,9 @@ class WebHDFS(HDFS):
             else:
                 if verbose:
                     self.log('Writing buffer to HDFS {0}'.format(hdfs_path))
-                # TODO: eliminate the .getvalue() call to support general
-                # handle types
                 resource.seek(0)
-                self.client.write(hdfs_path, resource.read(),
-                                  overwrite=overwrite, **kwargs)
+                self.client.write(hdfs_path, resource, overwrite=overwrite,
+                                  **kwargs)
 
     @implements(HDFS.get)
     def get(self, hdfs_path, local_path, overwrite=False, verbose=None):