id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type
2083501344,I_kwDOAMm_X858L7Ug,8612,more frequency string updates?,10194086,closed,0,,,5,2024-01-16T09:56:48Z,2024-02-15T16:53:37Z,2024-02-15T16:53:37Z,MEMBER,,,,"### What is your issue?
I looked a bit into the frequency string update & found 3 issues we could improve upon.
1. Apart from `""M""`, pandas also deprecated `""Y""`, and `""Q""`, in favor of `""YE""` and `""QE""`. (And they are discussing renaming `""MS""` to `""MB""`). Should we do the same?
2. Should we translate the new freq strings to the old ones if pandas < 2.2 is installed? Otherwise we get the following situation:
```python
import xarray as xr
xr.date_range(""1600-02-01"", periods=3, freq=""M"") # deprecation warning
xr.date_range(""1600-02-01"", periods=3, freq=""ME"") # ValueError: Invalid frequency: ME
```
3. `date_range_like` can emit deprecation warnings without a way to mitigate them if pandas < 2.2 is installed. (When a `DatetimeIndex`) is passed. Could be nice to translate the old freq string to the new one without a warning.
I have played around with 2. and 3. and can open a PR if you are on board.
@spencerkclark @aulemahal
- pandas-dev/pandas#55792
- pandas-dev/pandas#55553
- pandas-dev/pandas#56840
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8612/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1918089795,I_kwDOAMm_X85yU7pD,8252,cannot use negative step to sel from zarr (without dask),10194086,closed,0,,,0,2023-09-28T18:52:07Z,2024-02-10T02:57:33Z,2024-02-10T02:57:33Z,MEMBER,,,,"### What happened?
As per: https://github.com/pydata/xarray/pull/8246#discussion_r1340357405
Passing a negative step in a `slice` to select a non-chunked zarr-backed datasets raises an error.
### What did you expect to happen?
zarr should allow negative step (probably?)
### Minimal Complete Verifiable Example
```Python
import xarray as xr
# create a zarr dataset
air = xr.tutorial.open_dataset(""air_temperature"")
air.to_zarr(""test.zarr"")
ds = xr.open_dataset(""test.zarr"", engine=""zarr"")
ds.air[::-1, ].load()
# note that this works if the dataset is backed by dask
ds_dask = xr.open_dataset(""test.zarr"", engine=""zarr"", chunks=""auto"")
ds_dask.air[::-1, ].load()
```
### MVCE confirmation
- [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
- [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
```Python
File ~/code/xarray/xarray/core/parallelcompat.py:93, in guess_chunkmanager(manager)
91 if isinstance(manager, str):
92 if manager not in chunkmanagers:
---> 93 raise ValueError(
94 f""unrecognized chunk manager {manager} - must be one of: {list(chunkmanagers)}""
95 )
97 return chunkmanagers[manager]
98 elif isinstance(manager, ChunkManagerEntrypoint):
99 # already a valid ChunkManager so just pass through
ValueError: unrecognized chunk manager dask - must be one of: []
```
### Anything else we need to know?
The error comes from https://github.com/zarr-developers/zarr-python/blob/6ec746ef1242dd9fec26b128cc0b3455d28ad6f0/zarr/indexing.py#L174 so it would need an upstream fix first.
cc @dcherian is this what you had in mind?
### Environment
INSTALLED VERSIONS
------------------
commit: f6d69a1f6d952dcd67609c97f3fb3069abdda586
python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 6.2.0-33-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.2
xarray: 2023.9.1.dev8+gf6d69a1f
pandas: 2.1.1
numpy: 1.24.4
scipy: 1.11.3
netCDF4: 1.6.4
pydap: installed
h5netcdf: 1.2.0
h5py: 3.9.0
Nio: None
zarr: 2.16.1
cftime: 1.6.2
nc_time_axis: 1.4.1
PseudoNetCDF: 3.2.2
iris: 3.7.0
bottleneck: 1.3.7
dask: 2023.9.2
distributed: None
matplotlib: 3.8.0
cartopy: 0.22.0
seaborn: 0.12.2
numbagg: 0.2.2
fsspec: 2023.9.2
cupy: None
pint: 0.20.1
sparse: 0.14.0
flox: 0.7.2
numpy_groupies: 0.10.1
setuptools: 68.2.2
pip: 23.2.1
conda: None
pytest: 7.4.2
mypy: None
IPython: 8.15.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8252/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
2105703882,I_kwDOAMm_X859gn3K,8679,Dataset.weighted along a dimension not on weights errors,10194086,open,0,,,2,2024-01-29T15:03:39Z,2024-02-04T11:24:54Z,,MEMBER,,,,"### What happened?
`ds.weighted(weights).mean(dims)` errors when reducing over a dimension that is neither on the `weights` nor on the variable.
### What did you expect to happen?
This used to work and was ""broken"" by #8606. However, we may want to fix this by ignoring (?) those data vars instead (#7027).
### Minimal Complete Verifiable Example
```Python
import xarray as xr
ds = xr.Dataset({""a"": ((""y"", ""x""), [[1, 2]]), ""scalar"": 1})
weights = xr.DataArray([1, 2], dims=""x"")
ds.weighted(weights).mean(""y"")
```
### MVCE confirmation
- [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
- [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.
- [ ] Recent environment — the issue occurs with the latest version of xarray and its dependencies.
### Relevant log output
```Python
ValueError Traceback (most recent call last)
Cell In[1], line 6
3 ds = xr.Dataset({""a"": ((""y"", ""x""), [[1, 2]]), ""scalar"": 1})
4 weights = xr.DataArray([1, 2], dims=""x"")
----> 6 ds.weighted(weights).mean(""y"")
File ~/code/xarray/xarray/util/deprecation_helpers.py:115, in _deprecate_positional_args.._decorator..inner(*args, **kwargs)
111 kwargs.update({name: arg for name, arg in zip_args})
113 return func(*args[:-n_extra_args], **kwargs)
--> 115 return func(*args, **kwargs)
File ~/code/xarray/xarray/core/weighted.py:497, in Weighted.mean(self, dim, skipna, keep_attrs)
489 @_deprecate_positional_args(""v2023.10.0"")
490 def mean(
491 self,
(...)
495 keep_attrs: bool | None = None,
496 ) -> T_Xarray:
--> 497 return self._implementation(
498 self._weighted_mean, dim=dim, skipna=skipna, keep_attrs=keep_attrs
499 )
File ~/code/xarray/xarray/core/weighted.py:558, in DatasetWeighted._implementation(self, func, dim, **kwargs)
555 def _implementation(self, func, dim, **kwargs) -> Dataset:
556 self._check_dim(dim)
--> 558 return self.obj.map(func, dim=dim, **kwargs)
File ~/code/xarray/xarray/core/dataset.py:6924, in Dataset.map(self, func, keep_attrs, args, **kwargs)
6922 if keep_attrs is None:
6923 keep_attrs = _get_keep_attrs(default=False)
-> 6924 variables = {
6925 k: maybe_wrap_array(v, func(v, *args, **kwargs))
6926 for k, v in self.data_vars.items()
6927 }
6928 if keep_attrs:
6929 for k, v in variables.items():
File ~/code/xarray/xarray/core/dataset.py:6925, in (.0)
6922 if keep_attrs is None:
6923 keep_attrs = _get_keep_attrs(default=False)
6924 variables = {
-> 6925 k: maybe_wrap_array(v, func(v, *args, **kwargs))
6926 for k, v in self.data_vars.items()
6927 }
6928 if keep_attrs:
6929 for k, v in variables.items():
File ~/code/xarray/xarray/core/weighted.py:286, in Weighted._weighted_mean(self, da, dim, skipna)
278 def _weighted_mean(
279 self,
280 da: T_DataArray,
281 dim: Dims = None,
282 skipna: bool | None = None,
283 ) -> T_DataArray:
284 """"""Reduce a DataArray by a weighted ``mean`` along some dimension(s).""""""
--> 286 weighted_sum = self._weighted_sum(da, dim=dim, skipna=skipna)
288 sum_of_weights = self._sum_of_weights(da, dim=dim)
290 return weighted_sum / sum_of_weights
File ~/code/xarray/xarray/core/weighted.py:276, in Weighted._weighted_sum(self, da, dim, skipna)
268 def _weighted_sum(
269 self,
270 da: T_DataArray,
271 dim: Dims = None,
272 skipna: bool | None = None,
273 ) -> T_DataArray:
274 """"""Reduce a DataArray by a weighted ``sum`` along some dimension(s).""""""
--> 276 return self._reduce(da, self.weights, dim=dim, skipna=skipna)
File ~/code/xarray/xarray/core/weighted.py:231, in Weighted._reduce(da, weights, dim, skipna)
227 da = da.fillna(0.0)
229 # `dot` does not broadcast arrays, so this avoids creating a large
230 # DataArray (if `weights` has additional dimensions)
--> 231 return dot(da, weights, dim=dim)
File ~/code/xarray/xarray/util/deprecation_helpers.py:140, in deprecate_dims..wrapper(*args, **kwargs)
132 emit_user_level_warning(
133 ""The `dims` argument has been renamed to `dim`, and will be removed ""
134 ""in the future. This renaming is taking place throughout xarray over the ""
(...)
137 PendingDeprecationWarning,
138 )
139 kwargs[""dim""] = kwargs.pop(""dims"")
--> 140 return func(*args, **kwargs)
File ~/code/xarray/xarray/core/computation.py:1885, in dot(dim, *arrays, **kwargs)
1883 dim = tuple(d for d, c in dim_counts.items() if c > 1)
1884 else:
-> 1885 dim = parse_dims(dim, all_dims=tuple(all_dims))
1887 dot_dims: set[Hashable] = set(dim)
1889 # dimensions to be parallelized
File ~/code/xarray/xarray/core/utils.py:1046, in parse_dims(dim, all_dims, check_exists, replace_none)
1044 dim = (dim,)
1045 if check_exists:
-> 1046 _check_dims(set(dim), set(all_dims))
1047 return tuple(dim)
File ~/code/xarray/xarray/core/utils.py:1131, in _check_dims(dim, all_dims)
1129 if wrong_dims:
1130 wrong_dims_str = "", "".join(f""'{d!s}'"" for d in wrong_dims)
-> 1131 raise ValueError(
1132 f""Dimension(s) {wrong_dims_str} do not exist. Expected one or more of {all_dims}""
1133 )
ValueError: Dimension(s) 'y' do not exist. Expected one or more of {'x'}
```
### Anything else we need to know?
_No response_
### Environment
Newest main (i.e. 2024.01)
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8679/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
1455395909,I_kwDOAMm_X85Wv5RF,7298,html repr fails for empty cftime arrays,10194086,closed,0,,,1,2022-11-18T16:09:00Z,2024-01-15T21:49:36Z,2024-01-15T21:49:35Z,MEMBER,,,,"### What happened?
The html repr of a cftime array wants to display the ""calendar"", which it cannot if it is empty.
### What did you expect to happen?
No error.
### Minimal Complete Verifiable Example
```Python
import numpy as np
import xarray as xr
data_obs = np.random.randn(3)
time_obs = xr.date_range(""2000-01-01"", periods=3, freq=""YS"", calendar=""noleap"")
obs = xr.DataArray(data_obs, coords={""time"": time_obs})
o = obs[:0]
xr.core.formatting_html.array_repr(o)
```
### MVCE confirmation
- [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
- [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
```Python
ValueError Traceback (most recent call last)
Input In [1], in ()
8 obs = xr.DataArray(data_obs, coords={""time"": time_obs})
10 o = obs[:0]
---> 12 xr.core.formatting_html.array_repr(o)
File ~/code/xarray/xarray/core/formatting_html.py:318, in array_repr(arr)
316 if hasattr(arr, ""xindexes""):
317 indexes = _get_indexes_dict(arr.xindexes)
--> 318 sections.append(index_section(indexes))
320 sections.append(attr_section(arr.attrs))
322 return _obj_repr(arr, header_components, sections)
File ~/code/xarray/xarray/core/formatting_html.py:195, in _mapping_section(mapping, name, details_func, max_items_collapse, expand_option_name, enabled)
188 expanded = _get_boolean_with_default(
189 expand_option_name, n_items < max_items_collapse
190 )
191 collapsed = not expanded
193 return collapsible_section(
194 name,
--> 195 details=details_func(mapping),
196 n_items=n_items,
197 enabled=enabled,
198 collapsed=collapsed,
199 )
File ~/code/xarray/xarray/core/formatting_html.py:155, in summarize_indexes(indexes)
154 def summarize_indexes(indexes):
--> 155 indexes_li = """".join(
156 f""{summarize_index(v, i)}""
157 for v, i in indexes.items()
158 )
159 return f""""
File ~/code/xarray/xarray/core/formatting_html.py:156, in (.0)
154 def summarize_indexes(indexes):
155 indexes_li = """".join(
--> 156 f""{summarize_index(v, i)}""
157 for v, i in indexes.items()
158 )
159 return f""""
File ~/code/xarray/xarray/core/formatting_html.py:140, in summarize_index(coord_names, index)
138 index_id = f""index-{uuid.uuid4()}""
139 preview = escape(inline_index_repr(index))
--> 140 details = short_index_repr_html(index)
142 data_icon = _icon(""icon-database"")
144 return (
145 f""""
146 f"" {preview} ""
(...)
150 f""{details} ""
151 )
File ~/code/xarray/xarray/core/formatting_html.py:132, in short_index_repr_html(index)
129 if hasattr(index, ""_repr_html_""):
130 return index._repr_html_()
--> 132 return f""{escape(repr(index))} ""
File ~/code/xarray/xarray/core/indexes.py:547, in PandasIndex.__repr__(self)
546 def __repr__(self):
--> 547 return f""PandasIndex({repr(self.index)})""
File ~/code/xarray/xarray/coding/cftimeindex.py:353, in CFTimeIndex.__repr__(self)
345 end_str = format_times(
346 self.values[-REPR_ELLIPSIS_SHOW_ITEMS_FRONT_END:],
347 display_width,
348 offset=offset,
349 first_row_offset=offset,
350 )
351 datastr = ""\n"".join([front_str, f""{' '*offset}..."", end_str])
--> 353 attrs_str = format_attrs(self)
354 # oneliner only if smaller than display_width
355 full_repr_str = f""{klass_name}([{datastr}], {attrs_str})""
File ~/code/xarray/xarray/coding/cftimeindex.py:272, in format_attrs(index, separator)
267 def format_attrs(index, separator="", ""):
268 """"""Format attributes of CFTimeIndex for __repr__.""""""
269 attrs = {
270 ""dtype"": f""'{index.dtype}'"",
271 ""length"": f""{len(index)}"",
--> 272 ""calendar"": f""'{index.calendar}'"",
273 ""freq"": f""'{index.freq}'"" if len(index) >= 3 else None,
274 }
276 attrs_str = [f""{k}={v}"" for k, v in attrs.items()]
277 attrs_str = f""{separator}"".join(attrs_str)
File ~/code/xarray/xarray/coding/cftimeindex.py:698, in CFTimeIndex.calendar(self)
695 """"""The calendar used by the datetimes in the index.""""""
696 from .times import infer_calendar_name
--> 698 return infer_calendar_name(self)
File ~/code/xarray/xarray/coding/times.py:374, in infer_calendar_name(dates)
371 return sample.calendar
373 # Error raise if dtype is neither datetime or ""O"", if cftime is not importable, and if element of 'O' dtype is not cftime.
--> 374 raise ValueError(""Array does not contain datetime objects."")
ValueError: Array does not contain datetime objects.
```
### Anything else we need to know?
Bisected to 7379923de756a2bcc59044d548f8ab7a68b91d4e use `_repr_inline_` for indexes that define it.
### Environment
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7298/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1959175248,I_kwDOAMm_X850xqRQ,8367,`da.xindexes` or `da.indexes` raises an error if there are none (in the repr),10194086,closed,0,,,1,2023-10-24T12:45:12Z,2023-12-06T17:06:16Z,2023-12-06T17:06:16Z,MEMBER,,,,"### What happened?
`da.xindexes` or `da.indexes` raises an error when trying to generate the repr if there are no coords (indexes)
### What did you expect to happen?
Displaying an empty Mappable?
### Minimal Complete Verifiable Example
```Python
xr.DataArray([3, 5]).indexes
xr.DataArray([3, 5]).xindexes
```
### MVCE confirmation
- [x] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [x] Complete example — the example is self-contained, including all data and the text of any traceback.
- [x] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [x] New issue — a search of GitHub Issues suggests this is not a duplicate.
- [x] Recent environment — the issue occurs with the latest version of xarray and its dependencies.
### Relevant log output
```Python
Out[9]: ---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
File ~/.conda/envs/xarray_dev/lib/python3.10/site-packages/IPython/core/formatters.py:708, in PlainTextFormatter.__call__(self, obj)
701 stream = StringIO()
702 printer = pretty.RepresentationPrinter(stream, self.verbose,
703 self.max_width, self.newline,
704 max_seq_length=self.max_seq_length,
705 singleton_pprinters=self.singleton_printers,
706 type_pprinters=self.type_printers,
707 deferred_pprinters=self.deferred_printers)
--> 708 printer.pretty(obj)
709 printer.flush()
710 return stream.getvalue()
File ~/.conda/envs/xarray_dev/lib/python3.10/site-packages/IPython/lib/pretty.py:410, in RepresentationPrinter.pretty(self, obj)
407 return meth(obj, self, cycle)
408 if cls is not object \
409 and callable(cls.__dict__.get('__repr__')):
--> 410 return _repr_pprint(obj, self, cycle)
412 return _default_pprint(obj, self, cycle)
413 finally:
File ~/.conda/envs/xarray_dev/lib/python3.10/site-packages/IPython/lib/pretty.py:778, in _repr_pprint(obj, p, cycle)
776 """"""A pprint that just redirects to the normal repr function.""""""
777 # Find newlines and replace them with p.break_()
--> 778 output = repr(obj)
779 lines = output.splitlines()
780 with p.group():
File ~/code/xarray/xarray/core/indexes.py:1659, in Indexes.__repr__(self)
1657 def __repr__(self):
1658 indexes = formatting._get_indexes_dict(self)
-> 1659 return formatting.indexes_repr(indexes)
File ~/code/xarray/xarray/core/formatting.py:474, in indexes_repr(indexes, max_rows)
473 def indexes_repr(indexes, max_rows: int | None = None) -> str:
--> 474 col_width = _calculate_col_width(chain.from_iterable(indexes))
476 return _mapping_repr(
477 indexes,
478 ""Indexes"",
(...)
482 max_rows=max_rows,
483 )
File ~/code/xarray/xarray/core/formatting.py:341, in _calculate_col_width(col_items)
340 def _calculate_col_width(col_items):
--> 341 max_name_length = max(len(str(s)) for s in col_items) if col_items else 0
342 col_width = max(max_name_length, 7) + 6
343 return col_width
ValueError: max() arg is an empty sequence
```
### Anything else we need to know?
_No response_
### Environment
INSTALLED VERSIONS
------------------
commit: ccc8f9987b553809fb6a40c52fa1a8a8095c8c5f
python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 6.2.0-35-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.2
xarray: 2023.9.1.dev8+gf6d69a1f
pandas: 2.1.1
numpy: 1.24.4
scipy: 1.11.3
netCDF4: 1.6.4
pydap: installed
h5netcdf: 1.2.0
h5py: 3.9.0
Nio: None
zarr: 2.16.1
cftime: 1.6.2
nc_time_axis: 1.4.1
PseudoNetCDF: 3.2.2
iris: 3.7.0
bottleneck: 1.3.7
dask: 2023.9.2
distributed: None
matplotlib: 3.8.0
cartopy: 0.22.0
seaborn: 0.12.2
numbagg: 0.2.2
fsspec: 2023.9.2
cupy: None
pint: 0.20.1
sparse: 0.14.0
flox: 0.7.2
numpy_groupies: 0.10.1
setuptools: 68.2.2
pip: 23.2.1
conda: None
pytest: 7.4.2
mypy: 1.5.1
IPython: 8.15.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8367/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
722168932,MDU6SXNzdWU3MjIxNjg5MzI=,4513,"where should keep_attrs be set in groupby, resample, weighted etc.?",10194086,closed,0,,,2,2020-10-15T09:36:43Z,2023-11-10T16:58:35Z,2023-11-10T16:58:35Z,MEMBER,,,,"I really should not open this can of worms but per https://github.com/pydata/xarray/issues/4450#issuecomment-697507489:
> I'm always confused about whether `ds.groupby(..., keep_attrs=True).mean()` or `ds.groupby(...).mean(keep_attrs=True)` is correct. (similarly for rolling, coarsen etc.)
Also as I try to fix the `keep_attr` behavior in #4510 it would be good to know where they should go. So I tried to figure out how this is currently handled and found the following:
**`ds.xxx(keep_attrs=True).yyy()`**
- all fixed
**`ds.xxx().yyy(keep_attrs=True)`**
- `coarsen` (fixed in #5227)
- `groupby`
- `groupby_bin`
- `resample`
- `rolling` (adjusted in #4510)
- `rolling_exp` (fixed in #4592)
- `weighted`
So the working consensus seems to be to to `ds.xxx().yyy(keep_attrs=True)` - any comments on that?
(Edit: looking at this it is only half as bad, ""only"" `coarsen`, `rolling` (#4510), and `rolling_exp` would need to be fixed.)
### Detailed analysis
```python
import xarray as xr
ds = xr.tutorial.open_dataset(""air_temperature"")
da = ds.air
```
### coarsen
```python
ds.coarsen(time=2, keep_attrs=True).mean() # keeps global attributes
ds.coarsen(time=2).mean(keep_attrs=True) # keeps DataArray attributes
ds.coarsen(time=2, keep_attrs=True).mean(keep_attrs=True) # keeps both
da.coarsen(time=2).mean(keep_attrs=True) # error
da.coarsen(time=2, keep_attrs=True).mean() # keeps DataArray attributes
```
### groupby
```python
ds.groupby(""time.month"").mean(keep_attrs=True) # keeps both
da.groupby(""time.month"").mean(keep_attrs=True) # keeps DataArray attributes
ds.groupby(""time.month"", keep_attrs=True).mean() # error
da.groupby(""time.month"", keep_attrs=True).mean() # error
```
### groupby_bins
```python
ds.groupby_bins(ds.lat, np.arange(0, 90, 10)).mean(keep_attrs=True) # keeps both
da.groupby_bins(ds.lat, np.arange(0, 90, 10)).mean(keep_attrs=True) # keeps DataArray attrs
ds.groupby_bins(ds.lat, np.arange(0, 90, 10), keep_attrs=True) # errors
da.groupby_bins(ds.lat, np.arange(0, 90, 10), keep_attrs=True) # errors
```
### resample
```python
ds.resample(time=""A"").mean(keep_attrs=True) # keeps both
da.resample(time=""A"").mean(keep_attrs=True) # keeps DataArray attributes
ds.resample(time=""A"", keep_attrs=False).mean() # ignored
da.resample(time=""A"", keep_attrs=False).mean() # ignored
```
### rolling
```python
ds.rolling(time=2).mean(keep_attrs=True) # keeps both
da.rolling(time=2).mean(keep_attrs=True) # keeps DataArray attributes
ds.rolling(time=2, keep_attrs=True).mean() # DeprecationWarning; keeps both
da.rolling(time=2, keep_attrs=True).mean() # DeprecationWarning; keeps DataArray attributes
```
see #4510
### rolling_exp
```python
ds.rolling_exp(time=5, keep_attrs=True).mean() # ignored
da.rolling_exp(time=5, keep_attrs=True).mean() # ignored
ds.rolling_exp(time=5).mean(keep_attrs=True) # keeps both
da.rolling_exp(time=5).mean(keep_attrs=True) # keeps DataArray attributes
```
### weighted
```python
ds.weighted(ds.lat).mean(keep_attrs=True) # keeps both
da.weighted(ds.lat).mean(keep_attrs=True) # keeps DataArray attrs
```
edit: moved `rolling` after #4510, moved `rolling_exp` after #4592 and `coarsen` after #5227","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4513/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1986324822,I_kwDOAMm_X852ZOlW,8436,align fails when more than one xindex is set,10194086,closed,0,,,2,2023-11-09T20:07:52Z,2023-11-10T12:53:49Z,2023-11-10T12:53:49Z,MEMBER,,,,"### What happened?
I tried a DataArray with more than one dimension coordinate. Unfortunately `xr.align` fails, which disallows any arithmetic operation - even when the coords are exactly the same.
### What did you expect to happen?
_No response_
### Minimal Complete Verifiable Example
```Python
import numpy as np
import xarray as xr
data = np.arange(12).reshape(3, 4)
y = [10, 20, 30]
s = [""a"", ""b"", ""c""]
x = [1, 2, 3, 4]
da = xr.DataArray(data, dims=(""y"", ""x""), coords={""x"": x, ""y"": y, ""s"": (""y"", s)})
da = da.set_xindex(""s"")
xr.align(da, da.y) # errors
da + da # errors
da + da.x # errors
```
### MVCE confirmation
- [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
- [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.
- [ ] Recent environment — the issue occurs with the latest version of xarray and its dependencies.
### Relevant log output
```Python
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/home/mathause/code/mesmer/devel/prepare_for_surfer.ipynb Cell 28 line 1
12 da = xr.DataArray(data, dims=(""y"", ""x""), coords={""x"": x, ""y"": y, ""s"": (""y"", s)})
13 da = da.set_xindex(""s"")
---> 15 xr.align(da, da.y) # errors
17 da + da.x # errors
File ~/.conda/envs/mesmer_dev/lib/python3.9/site-packages/xarray/core/alignment.py:888, in align(join, copy, indexes, exclude, fill_value, *objects)
692 """"""
693 Given any number of Dataset and/or DataArray objects, returns new
694 objects with aligned indexes and dimension sizes.
ref='~/.conda/envs/mesmer_dev/lib/python3.9/site-packages/xarray/core/alignment.py:0'>0;32m (...)
878
879 """"""
880 aligner = Aligner(
881 objects,
882 join=join,
ref='~/.conda/envs/mesmer_dev/lib/python3.9/site-packages/xarray/core/alignment.py:0'>0;32m (...)
886 fill_value=fill_value,
887 )
--> 888 aligner.align()
889 return aligner.results
File ~/.conda/envs/mesmer_dev/lib/python3.9/site-packages/xarray/core/alignment.py:573, in Aligner.align(self)
571 self.find_matching_indexes()
572 self.find_matching_unindexed_dims()
--> 573 self.assert_no_index_conflict()
574 self.align_indexes()
575 self.assert_unindexed_dim_sizes_equal()
File ~/.conda/envs/mesmer_dev/lib/python3.9/site-packages/xarray/core/alignment.py:318, in Aligner.assert_no_index_conflict(self)
314 if dup:
315 items_msg = "", "".join(
316 f""{k!r} ({v} conflicting indexes)"" for k, v in dup.items()
317 )
--> 318 raise ValueError(
319 ""cannot re-index or align objects with conflicting indexes found for ""
320 f""the following {msg}: {items_msg}\n""
321 ""Conflicting indexes may occur when\n""
322 ""- they relate to different sets of coordinate and/or dimension names\n""
323 ""- they don't have the same type\n""
324 ""- they may be used to reindex data along common dimensions""
325 )
ValueError: cannot re-index or align objects with conflicting indexes found for the following dimensions: 'y' (2 conflicting indexes)
Conflicting indexes may occur when
- they relate to different sets of coordinate and/or dimension names
- they don't have the same type
- they may be used to reindex data along common dimensions
```
### Anything else we need to know?
_No response_
### Environment
INSTALLED VERSIONS
------------------
commit: feba6984aa914327408fee3c286dae15969d2a2f
python: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
python-bits: 64
OS: Linux
OS-release: 6.2.0-36-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.2
libnetcdf: 4.9.2
xarray: 2023.9.1.dev8+gf6d69a1f
pandas: 2.1.1
numpy: 1.24.4
scipy: 1.11.3
netCDF4: 1.6.4
pydap: installed
h5netcdf: 1.2.0
h5py: 3.9.0
Nio: None
zarr: 2.16.1
cftime: 1.6.2
nc_time_axis: 1.4.1
PseudoNetCDF: 3.2.2
iris: 3.7.0
bottleneck: 1.3.7
dask: 2023.9.2
distributed: None
matplotlib: 3.8.0
cartopy: 0.22.0
seaborn: 0.12.2
numbagg: 0.2.2
fsspec: 2023.9.2
cupy: None
pint: 0.20.1
sparse: 0.14.0
flox: 0.7.2
numpy_groupies: 0.10.1
setuptools: 68.2.2
pip: 23.2.1
conda: None
pytest: 7.4.2
mypy: 1.5.1
IPython: 8.15.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/8436/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1657036222,I_kwDOAMm_X85ixF2-,7730,flox performance regression for cftime resampling,10194086,closed,0,,,8,2023-04-06T09:38:03Z,2023-10-15T03:48:44Z,2023-10-15T03:48:44Z,MEMBER,,,,"### What happened?
Running an in-memory `groupby` operation took much longer than expected. Turning off flox fixed this - but I don't think that's the idea ;-)
### What did you expect to happen?
flox to be at least on par with our naive implementation
### Minimal Complete Verifiable Example
```Python
import numpy as np
import xarray as xr
arr = np.random.randn(10, 10, 365*30)
time = xr.date_range(""2000"", periods=30*365, calendar=""noleap"")
da = xr.DataArray(arr, dims=(""y"", ""x"", ""time""), coords={""time"": time})
# using max
print(""max:"")
xr.set_options(use_flox=True)
%timeit da.groupby(""time.year"").max(""time"")
%timeit da.groupby(""time.year"").max(""time"", engine=""flox"")
xr.set_options(use_flox=False)
%timeit da.groupby(""time.year"").max(""time"")
# as reference
%timeit [da.sel(time=str(year)).max(""time"") for year in range(2000, 2030)]
# using mean
print(""mean:"")
xr.set_options(use_flox=True)
%timeit da.groupby(""time.year"").mean(""time"")
%timeit da.groupby(""time.year"").mean(""time"", engine=""flox"")
xr.set_options(use_flox=False)
%timeit da.groupby(""time.year"").mean(""time"")
# as reference
%timeit [da.sel(time=str(year)).mean(""time"") for year in range(2000, 2030)]
```
### MVCE confirmation
- [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
- [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
```Python
max:
158 ms ± 4.41 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
28.1 ms ± 318 µs per loop (mean ± std. dev. of 7 runs, 10 loops each)
11.5 ms ± 52.3 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
mean:
95.6 ms ± 10.8 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
34.8 ms ± 2.88 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
15.2 ms ± 232 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
```
### Anything else we need to know?
_No response_
### Environment
INSTALLED VERSIONS
------------------
commit: f8127fc9ad24fe8b41cce9f891ab2c98eb2c679a
python: 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0]
python-bits: 64
OS: Linux
OS-release: 5.15.0-69-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.9.1
xarray: main
pandas: 1.5.3
numpy: 1.23.5
scipy: 1.10.1
netCDF4: 1.6.3
pydap: installed
h5netcdf: 1.1.0
h5py: 3.8.0
Nio: None
zarr: 2.14.2
cftime: 1.6.2
nc_time_axis: 1.4.1
PseudoNetCDF: 3.2.2
iris: 3.4.1
bottleneck: 1.3.7
dask: 2023.3.2
distributed: 2023.3.2.1
matplotlib: 3.7.1
cartopy: 0.21.1
seaborn: 0.12.2
numbagg: 0.2.2
fsspec: 2023.3.0
cupy: None
pint: 0.20.1
sparse: 0.14.0
flox: 0.6.10
numpy_groupies: 0.9.20
setuptools: 67.6.1
pip: 23.0.1
conda: None
pytest: 7.2.2
mypy: None
IPython: 8.12.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7730/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
748684119,MDU6SXNzdWU3NDg2ODQxMTk=,4601,Don't type check __getattr__?,10194086,open,0,,,8,2020-11-23T10:41:21Z,2023-09-25T05:33:09Z,,MEMBER,,,,"In #4592 I had the issue that mypy did not raise an error on a missing method:
```python
from xarray.core.common import DataWithCoords
hasattr(xr.core.common.DataWithCoords, ""reduce"") # -> False
def test(x: ""DataWithCoords""):
x.reduce() # mypy does not error
```
This is because `DataWithCoords` implements `__getattr__`:
```python
class A:
pass
class B:
def __getattr__(self, name):
...
def testA(x: ""A""):
x.reduce() # mypy errors
def testB(x: ""B""):
x.reduce() # mypy does not error
```
The solution seems to be to not typecheck `__getattr__` (see https://github.com/python/mypy/issues/6251#issuecomment-457287161):
```python
from typing import no_type_check
class C:
@no_type_check
def __getattr__(self, name):
...
def testC(x: ""C""):
x.reduce() # mypy errors
```
The only `__getattr__` within xarray is here:
https://github.com/pydata/xarray/blob/17358922d480c038e66430735bf4c365a7677df8/xarray/core/common.py#L221
Using `@no_type_check` leads to 24 errors and not all of them can be trivially solved. E.g. `DataWithCoords` [wants of use](https://github.com/pydata/xarray/blob/17358922d480c038e66430735bf4c365a7677df8/xarray/core/common.py#L368) `self.isel` but does not implement the method. The solution is probably to add `isel` to `DataWithCoords` as an `ABC` or using `NotImplemented`.
Thoughts?
**All errors**
```python-traceback
xarray/core/common.py:370: error: ""DataWithCoords"" has no attribute ""isel""
xarray/core/common.py:374: error: ""DataWithCoords"" has no attribute ""dims""
xarray/core/common.py:378: error: ""DataWithCoords"" has no attribute ""indexes""
xarray/core/common.py:381: error: ""DataWithCoords"" has no attribute ""sizes""
xarray/core/common.py:698: error: ""DataWithCoords"" has no attribute ""_groupby_cls""
xarray/core/common.py:761: error: ""DataWithCoords"" has no attribute ""_groupby_cls""
xarray/core/common.py:866: error: ""DataWithCoords"" has no attribute ""_rolling_cls""; maybe ""_rolling_exp_cls""?
xarray/core/common.py:977: error: ""DataWithCoords"" has no attribute ""_coarsen_cls""
xarray/core/common.py:1108: error: ""DataWithCoords"" has no attribute ""dims""
xarray/core/common.py:1109: error: ""DataWithCoords"" has no attribute ""dims""
xarray/core/common.py:1133: error: ""DataWithCoords"" has no attribute ""indexes""
xarray/core/common.py:1144: error: ""DataWithCoords"" has no attribute ""_resample_cls""; maybe ""resample""?
xarray/core/common.py:1261: error: ""DataWithCoords"" has no attribute ""isel""
xarray/core/alignment.py:278: error: ""DataAlignable"" has no attribute ""copy""
xarray/core/alignment.py:283: error: ""DataAlignable"" has no attribute ""dims""
xarray/core/alignment.py:286: error: ""DataAlignable"" has no attribute ""indexes""
xarray/core/alignment.py:288: error: ""DataAlignable"" has no attribute ""sizes""
xarray/core/alignment.py:348: error: ""DataAlignable"" has no attribute ""dims""
xarray/core/alignment.py:351: error: ""DataAlignable"" has no attribute ""copy""
xarray/core/alignment.py:353: error: ""DataAlignable"" has no attribute ""reindex""
xarray/core/alignment.py:356: error: ""DataAlignable"" has no attribute ""encoding""
xarray/core/weighted.py:157: error: ""DataArray"" has no attribute ""notnull""
xarray/core/dataset.py:3792: error: ""Dataset"" has no attribute ""virtual_variables""
xarray/core/dataset.py:6135: error: ""DataArray"" has no attribute ""isnull""
```
Edit:
one problem is certainly the method injection, as mypy cannot detect those types.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4601/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
235224055,MDU6SXNzdWUyMzUyMjQwNTU=,1449,time.units truncated when saving to_netcdf,10194086,closed,0,,,6,2017-06-12T12:58:37Z,2023-09-13T13:25:25Z,2023-09-13T13:25:24Z,MEMBER,,,,"When I manually specify the `units` attribute for time, and then save the Dataset `to_netcdf` the string is truncated. See exaple
import pandas as pd
import xarray as xr
time = pd.date_range('2000-01-01', '2000-01-31', freq='6h')
ds = xr.Dataset(coords=dict(time=time))
units = 'days since 1975-01-01 00:00:00'
calendar = 'gregorian'
encoding=dict(time=dict(units=units, calendar=calendar))
ds.to_netcdf('test.nc', format='NETCDF4_CLASSIC', encoding=encoding)
! ncdump -h test.nc
# time:units = ""days since 1975-01-01"" ;
Some programs seem to require the hours to be present to interpret the time properly (e.g. panoply). When specifying the hour, a 'T' is added.
units = 'days since 1975-01-01 01:00:00'
! ncdump -h test.nc
# time:units = ""days since 1975-01-01T01:00:00"" ;
When xarray defines the `time.units` it works fine.
ds = xr.Dataset(coords=dict(time=time))
ds.to_netcdf('test.nc', format='NETCDF4_CLASSIC',)
! ncdump -h test.nc
# time:units = ""hours since 2000-01-01 00:00:00"" ;
xarray version 0.9.6","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1449/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1371397741,I_kwDOAMm_X85Rvd5t,7027,"don't apply `weighted`, `groupby`, etc. to `DataArray` without `dims`?",10194086,open,0,,,1,2022-09-13T12:44:34Z,2023-08-26T19:13:39Z,,MEMBER,,,,"### What is your issue?
Applying e.g. `ds.weighted(weights).mean()` applies the operation over all `DataArray` objects - even if they don't have the dimensions over which it is applied (or is a scalar variable). I don't think this is wanted.
```python
import xarray as xr
air = xr.tutorial.open_dataset(""air_temperature"")
air.attrs = {}
# add variable without dims
air[""foo""] = 5
print(""resample"")
print(air.resample(time=""MS"").mean(dim=""time"").foo.dims)
print(""groupby"")
print(air.groupby(""time.year"").mean(dim=""time"").foo.dims)
print(""weighted"")
print(air.weighted(weights=air.time.dt.year).mean(""lat"").foo.dims)
print(""where"")
print(air.where(air.air > 5).foo.dims)
```
Results
```
resample
('time',)
groupby
('year',)
weighted
('time',)
```
Related #6952 - I am sure there are other issues, but couldn't find them quickly...
`rolling` and `coarsen` don't seem to do this.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7027/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
1719805837,I_kwDOAMm_X85mgieN,7860,diff of cftime.Datetime,10194086,open,0,,,3,2023-05-22T14:21:06Z,2023-08-04T12:01:33Z,,MEMBER,,,,"### What happened?
A cftime variable returns a timedelta64[ns] when calling `diff` / `+` / `-` and it can then not be added/ subtracted from the original data.
### What did you expect to happen?
We can `add` cftime timedeltas.
### Minimal Complete Verifiable Example
```Python
import xarray as xr
air = xr.tutorial.open_dataset(""air_temperature"", use_cftime=True)
air.time + air.time.diff(""time"") / 2
```
### MVCE confirmation
- [x] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [x] Complete example — the example is self-contained, including all data and the text of any traceback.
- [x] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [x] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
```Python
air.time.variable.values[1:] - air.time.variable.values[:-1]
```
returns `array([datetime.timedelta(seconds=21600), ...])` but then
```Python
xr.Variable((""time"",), np.array([datetime.timedelta(0)]))
```
returns a `dtype='timedelta64[ns]'` array.
### Anything else we need to know?
- See upstream PR: xarray-contrib/cf-xarray#441
- Similar to #7381 (but I don't think it's the same issue, feel free to close if you disagree)
- That might need a special data type for timedeltas of cftime.Datetime objects, or allowing to add `'timedelta64[ns]'` to cftime.Datetime objects
- The casting comes from
https://github.com/pydata/xarray/blob/d8ec3a3f6b02a8b941b484b3d254537af84b5fde/xarray/core/variable.py#L366
https://github.com/pydata/xarray/blob/d8ec3a3f6b02a8b941b484b3d254537af84b5fde/xarray/core/variable.py#L272
### Environment
INSTALLED VERSIONS
------------------
commit: d8ec3a3f6b02a8b941b484b3d254537af84b5fde
python: 3.10.9 | packaged by conda-forge | (main, Feb 2 2023, 20:20:04) [GCC 11.3.0]
python-bits: 64
OS: Linux
OS-release: 5.14.21-150400.24.63-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.12.2
libnetcdf: 4.9.1
xarray: 2023.2.1.dev20+g06a87062
pandas: 1.5.3
numpy: 1.23.5
scipy: 1.10.1
netCDF4: 1.6.2
pydap: installed
h5netcdf: 1.1.0
h5py: 3.8.0
Nio: None
zarr: 2.13.6
cftime: 1.6.2
nc_time_axis: 1.4.1
PseudoNetCDF: 3.2.2
iris: 3.4.1
bottleneck: 1.3.6
dask: 2023.2.1
distributed: 2023.2.1
matplotlib: 3.7.0
cartopy: 0.21.1
seaborn: 0.12.2
numbagg: 0.2.2
fsspec: 2023.1.0
cupy: None
pint: 0.20.1
sparse: 0.14.0
flox: 0.6.8
numpy_groupies: 0.9.20
setuptools: 67.4.0
pip: 23.0.1
conda: None
pytest: 7.2.1
mypy: None
IPython: 8.11.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7860/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
594669577,MDU6SXNzdWU1OTQ2Njk1Nzc=,3937,"compose weighted with groupby, coarsen, resample, rolling etc.",10194086,open,0,,,7,2020-04-05T22:00:40Z,2023-07-27T18:10:10Z,,MEMBER,,,,"It would be nice to make `weighted` work with `groupby` - e.g. [#3935 (comment)](https://github.com/pydata/xarray/pull/3935/files#r403742055)
However, it is not entirely clear to me how that should be done. One way would be to do:
```python
da.groupby(...).weighted(weights).mean()
```
this would require that the `groupby` operation is applied over the `weights` (how would this be done?)
Or should it be
```python
da.weighted(weights).groupby(...).mean()
```
but this seems less intuitive to me.
Or
```python
da.groupby(..., weights=weights).mean()
```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3937/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
715730538,MDU6SXNzdWU3MTU3MzA1Mzg=,4491,deprecate pynio backend,10194086,closed,0,,,21,2020-10-06T14:27:20Z,2022-11-26T15:40:37Z,2022-11-26T15:40:37Z,MEMBER,,,,"
We are currently not testing with the newest version of netCDF4 because it is incompatible with pynio (the newest version is [1.5.4](https://github.com/Unidata/netcdf4-python/blob/master/Changelog), we are at [1.5.3](https://dev.azure.com/xarray/xarray/_build/results?buildId=3974&view=logs&j=ba13898e-1dfb-5ace-9966-8b7af3677790&t=0a8d5551-2e87-575f-4689-3e85d9688898&l=220)). This is unlikely to be fixed, see conda-forge/pynio-feedstock#90.
Therefore we need to think how to setup the tests so we use the newest version of netCDF4. Maybe just remove it from `py38.yml`?
And long term what to do with the pynio backend? Deprecate? Move to an external repo?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4491/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1372729718,I_kwDOAMm_X85R0jF2,7036,index refactor: more `_coord_names` than `_variables` on Dataset,10194086,closed,0,,,3,2022-09-14T10:19:00Z,2022-09-27T10:35:40Z,2022-09-27T10:35:40Z,MEMBER,,,,"### What happened?
`xr.core.dataset.DataVariables` assumes that everything that is in `ds._dataset._variables` and not in `self._dataset._coord_names` is a ""data variable"". However, since the index refactor we can end up with more `_coord_names` than `_variables` which breaks a number of stuff (e.g. the repr).
### What did you expect to happen?
Well it seems this assumption is now wrong.
### Minimal Complete Verifiable Example
```Python
ds = xr.Dataset(coords={""a"": (""x"", [1, 2, 3]), ""b"": (""x"", ['a', 'b', 'c'])})
ds.set_index(z=['a', 'b']).reset_index(""z"", drop=True)
```
### MVCE confirmation
- [ ] Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
- [ ] Complete example — the example is self-contained, including all data and the text of any traceback.
- [ ] Verifiable example — the example copy & pastes into an IPython prompt or [Binder notebook](https://mybinder.org/v2/gh/pydata/xarray/main?urlpath=lab/tree/doc/examples/blank_template.ipynb), returning the result.
- [ ] New issue — a search of GitHub Issues suggests this is not a duplicate.
### Relevant log output
```Python
ValueError: __len__() should return >= 0
```
### Anything else we need to know?
The error comes from here
https://github.com/pydata/xarray/blob/63ba862d03c8d0cd8b44d2071bc360e9fed4519d/xarray/core/dataset.py#L368
Bisected to #5692 - which probably does not help too much.
### Environment
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7036/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1094725752,I_kwDOAMm_X85BQDB4,6142,dimensions: type as `str | Iterable[Hashable]`?,10194086,open,0,,,14,2022-01-05T20:39:00Z,2022-06-26T11:57:40Z,,MEMBER,,,,"### What happened?
We generally type dimensions as:
```python
dims: Hashable | Iterable[Hashable]
```
However, this is in conflict with passing a tuple of independent dimensions to a method - e.g. `da.mean((""x"", ""y""))` because a tuple is also hashable.
Also mypy requires an `isinstance(dims, Hashable)` check when typing a function. We use an `isinstance(dims, str)` check in many places to wrap a single dimension in a list. Changing this to `isinstance(dims, Hashable)` will change the behavior for tuples.
### What did you expect to happen?
In the community call today we discussed to change this to
```python
dims: str | Iterable[Hashable]
```
i.e. if a single dim is passed it has to be a string and wrapping it in a list is a convenience function. Special use cases with `Hashable` types should be wrapped in a `Iterable` by the user. This probably best reflects the current state of the repo (`dims = [dims] if isinstance(dims, str) else dims`).
The disadvantage could be that it is a bit more difficult to explain in the docstrings?
@shoyer - did I get this right from the discussion?
---
Other options
1. Require `str` as dimension names.
This could be too restrictive. @keewis mentioned that tuple dimension names are already used somwehere in the xarray repo. Also we discussed in another issue or PR (which I cannot find right know) that we want to keep allowing `Hashable`.
2. Disallow passing tuples (only allow tuples if a dimension is a tuple), require lists to pass several dimensions.
This is too restrictive in the other direction and will probably lead to a lot of downstream troubles. Naming a single dimension with a tuple will be a very rare case, in contrast to passing several dimension names as a tuple.
3. Special case tuples. We could potentially check if `dims` is a tuple and if there are any dimension names consisting of a tuple. Seems more complicated and potentially brittle for probably small gains (IMO).
### Minimal Complete Verifiable Example
_No response_
### Relevant log output
_No response_
### Anything else we need to know?
* We need to check carefully where general `Hashable` are really allowed. E.g. `dims` of a `DataArray` are typed as
https://github.com/pydata/xarray/blob/e056cacdca55cc9d9118c830ca622ea965ebcdef/xarray/core/dataarray.py#L380
but tuples are not actually allowed:
```python
import xarray as xr
xr.DataArray([1], dims=(""x"", ""y""))
# ValueError: different number of dimensions on data and dims: 1 vs 2
xr.DataArray([1], dims=[(""x"", ""y"")])
# TypeError: dimension ('x', 'y') is not a string
```
* We need to be careful typing functions where only one dim is allowed, e.g. `xr.concat`, which should probably set `dim: Hashable` (and make sure it works).
* Do you have examples for other real-world hashable types except for `str` and `tuple`? (Would be good for testing purposes).
### Environment
N/A","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6142/reactions"", ""total_count"": 2, ""+1"": 2, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
685739084,MDU6SXNzdWU2ODU3MzkwODQ=,4375,allow using non-dimension coordinates in polyfit,10194086,open,0,,,1,2020-08-25T19:40:55Z,2022-04-09T02:58:48Z,,MEMBER,,,,"
`polyfit` currently only allows to fit along a dimension and not along a non-dimension coordinate (or a virtual coordinate)
Example:
```python
da = xr.DataArray(
[1, 3, 2], dims=[""x""], coords=dict(x=[""a"", ""b"", ""c""], y=(""x"", [0, 1, 2]))
)
print(da)
da.polyfit(""y"", 1)
```
Output:
```python
array([1, 3, 2])
Coordinates:
* x (x) in
5 print(da)
6
----> 7 da.polyfit(""y"", 1)
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/core/dataarray.py in polyfit(self, dim, deg, skipna, rcond, w, full, cov)
3507 """"""
3508 return self._to_temp_dataset().polyfit(
-> 3509 dim, deg, skipna=skipna, rcond=rcond, w=w, full=full, cov=cov
3510 )
3511
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/core/dataset.py in polyfit(self, dim, deg, skipna, rcond, w, full, cov)
6005 skipna_da = skipna
6006
-> 6007 x = get_clean_interp_index(self, dim, strict=False)
6008 xname = ""{}_"".format(self[dim].name)
6009 order = int(deg) + 1
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/core/missing.py in get_clean_interp_index(arr, dim, use_coordinate, strict)
246
247 if use_coordinate is True:
--> 248 index = arr.get_index(dim)
249
250 else: # string
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/core/common.py in get_index(self, key)
378 """"""
379 if key not in self.dims:
--> 380 raise KeyError(key)
381
382 try:
KeyError: 'y'
```
**Describe the solution you'd like**
Would be nice if that worked.
**Describe alternatives you've considered**
One could just set the non-dimension coordinate as index, e.g.: `da = da.set_index(x=""y"")`
**Additional context**
Allowing this *may* be as easy as replacing
https://github.com/pydata/xarray/blob/9c85dd5f792805bea319f01f08ee51b83bde0f3b/xarray/core/missing.py#L248
by
```
index = arr[dim]
```
but I might be missing something. Or probably a `use_coordinate` must be threaded through to `get_clean_interp_index` (although I am a bit confused by this argument).
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4375/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
144630996,MDU6SXNzdWUxNDQ2MzA5OTY=,810,correct DJF mean,10194086,closed,0,,,4,2016-03-30T15:36:42Z,2022-04-06T16:19:47Z,2016-05-04T12:56:30Z,MEMBER,,,,"This started as a question and I add it as reference. Maybe you have a comment.
There are several ways to calculate time series of seasonal data (starting from monthly or daily data):
```
# load libraries
import pandas as pd
import matplotlib.pyplot
import numpy as np
import xarray as xr
# Create Example Dataset
time = pd.date_range('2000.01.01', '2010.12.31', freq='M')
data = np.random.rand(*time.shape)
ds = xr.DataArray(data, coords=dict(time=time))
# (1) using resample
ds_res = ds.resample('Q-FEB', 'time')
ds_res = ds_res.sel(time=ds_res['time.month'] == 2)
ds_res = ds_res.groupby('time.year').mean('time')
# (2) this is wrong
ds_season = ds.where(ds['time.season'] == 'DJF').groupby('time.year').mean('time')
# (3) using where and rolling
# mask other months with nan
ds_DJF = ds.where(ds['time.season'] == 'DJF')
# rolling mean -> only Jan is not nan
# however, we loose Jan/ Feb in the first year and Dec in the last
ds_DJF = ds_DJF.rolling(min_periods=3, center=True, time=3).mean()
# make annual mean
ds_DJF = ds_DJF.groupby('time.year').mean('time')
ds_res.plot(marker='*')
ds_season.plot()
ds_DJF.plot()
plt.show()
```
(1) The first is to use resample with 'Q-FEB' as argument. This works fine. It does include Jan/ Feb in the first year, and Dec in the last year + 1. If this makes sense can be debated.
One case where this does not work is when you have, say, two regions in your data set, for one you want to calculate DJF and for the other you want NovDecJan.
(2) Using 'time.season' is wrong as it combines Jan, Feb and Dec from the same year.
(3) The third uses `where` and `rolling` and you lose 'incomplete' seasons. If you replace `ds.where(ds['time.season'] == 'DJF')` with `ds.groupby('time.month').where(summer_months)`, where `summer_months` is a boolean array it works also for non-standard 'summers' (or seasons) across the globe.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/810/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
310833761,MDU6SXNzdWUzMTA4MzM3NjE=,2037,to_netcdf -> _fill_value without NaN,10194086,open,0,,,8,2018-04-03T13:20:19Z,2022-03-10T10:59:17Z,,MEMBER,,,,"#### Code Sample, a copy-pastable example if possible
```python
# Your code here
import xarray as xr
import numpy as np
x = np.arange(10.)
da = xr.Dataset(data_vars=dict(data=('dim1', x)), coords=dict(dim1=('dim1', x)))
da.to_netcdf('tst.nc')
```
#### Problem description
Apologies if this was discussed somwhere and it probably does not matter much, but `tst.nc` has `_FillValue` although it is not really necessary.
#### Output of ``xr.show_versions()``
# Paste the output here xr.show_versions() here
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2037/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
1150251120,I_kwDOAMm_X85Ej3Bw,6304,add join argument to xr.broadcast?,10194086,open,0,,,1,2022-02-25T09:52:14Z,2022-02-25T21:50:16Z,,MEMBER,,,,"### Is your feature request related to a problem?
`xr.broadcast` always does an outer join:
https://github.com/pydata/xarray/blob/de965f342e1c9c5de92ab135fbc4062e21e72453/xarray/core/alignment.py#L702
https://github.com/pydata/xarray/blob/de965f342e1c9c5de92ab135fbc4062e21e72453/xarray/core/alignment.py#L768
This is not how the (default) broadcasting (arithmetic join) works, e.g. the following first does an inner join and then broadcasts:
```python
import xarray as xr
da1 = xr.DataArray([[0, 1, 2]], dims=(""y"", ""x""), coords={""x"": [0, 1, 2]})
da2 = xr.DataArray([0, 1, 2, 3, 4], dims=""x"", coords={""x"": [0, 1, 2, 3, 4]})
da1 + da2
```
```
array([[0, 2, 4]])
Coordinates:
* x (x) int64 0 1 2
Dimensions without coordinates: y
```
### Describe the solution you'd like
Add a `join` argument to `xr.broadcast`. I would propose to leave the default as is
```python
def broadcast(*args, exclude=None, join=""outer""):
args = align(*args, join=join, copy=False, exclude=exclude)
```
### Describe alternatives you've considered
- We could make `broadcast` respect `options -> arithmetic_join` but that would be a breaking change and I am not sure how the deprecation should/ would be handled...
- We could leave it as is.
### Additional context
- `xr.broadcast` should not be used often because this is should happen automatically in most cases
- in #6059 I use `broadcast` because I couldn't get it to work otherwise (maybe there is a better way?). However, the ""outer elements"" are immediately discarded again - so it's kind of pointless to do an outer join.
```python
import numpy as np
import xarray as xr
da = xr.DataArray(np.arange(6).reshape(3, 2), coords={""dim_0"": [0, 1, 2]})
w = xr.DataArray([1, 1, 1, 1, 1, 1], coords={""dim_0"": [0, 1, 2, 4, 5, 6]})
da.weighted(w).quantile(0.5)
```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6304/reactions"", ""total_count"": 4, ""+1"": 4, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
1111644832,I_kwDOAMm_X85CQlqg,6186,upstream dev CI: enable bottleneck again,10194086,closed,0,,,2,2022-01-22T18:11:25Z,2022-02-07T09:05:24Z,2022-02-07T09:05:24Z,MEMBER,,,,bottleneck cannot be built with python 3.10. See https://github.com/pydata/xarray/actions/runs/1731371015,"{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6186/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
975385095,MDU6SXNzdWU5NzUzODUwOTU=,5721,pandas deprecates Index.get_loc with method,10194086,closed,0,,,7,2021-08-20T08:24:16Z,2022-01-27T21:06:40Z,2022-01-27T21:06:40Z,MEMBER,,,,"pandas deprecates the `method` keyword in `Index.get_loc`, see pandas-dev/pandas#42269. Therefore we end up with about 5000 warnings in our upstream tests:
`FutureWarning: Passing method to Index.get_loc is deprecated and will raise in a future version. Use index.get_indexer([item], method=...) instead`
We should fix this before pandas releases because the warning will not be silent (`FutureWarning`) or ask pandas to give us more time and use a `DeprecationWarning` at the moment.
We use this here:
https://github.com/pydata/xarray/blob/4bb9d9c6df77137f05e85c7cc6508fe7a93dc0e4/xarray/core/indexes.py#L233-L235
Is this only ever called with one item? Then we might be able to use
```python
indexer = self.index.get_indexer(
[label_value], method=method, tolerance=tolerance
).item()
if indexer == -1:
raise KeyError(label_value)
```
---
https://github.com/pydata/xarray/blob/3956b73a7792f41e4410349f2c40b9a9a80decd2/xarray/core/missing.py#L571-L572
This one could be easy to fix (replace with `imin = index.get_indexer([minval], method=""nearest"").item()`)
---
It is also defined in `CFTimeIndex`, which complicates things:
https://github.com/pydata/xarray/blob/eea76733770be03e78a0834803291659136bca31/xarray/coding/cftimeindex.py#L461-L466
because `get_indexer` expects an iterable and thus the `if isinstance(key, str)` test no longer works.
@benbovy @spencerkclark ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5721/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
432074821,MDU6SXNzdWU0MzIwNzQ4MjE=,2889,nansum vs nanmean for all-nan vectors,10194086,closed,0,,,3,2019-04-11T15:04:39Z,2022-01-05T21:59:48Z,2019-04-11T16:08:02Z,MEMBER,,,,"
```python
import xarray as xr
import numpy as np
ds = xr.DataArray([np.NaN, np.NaN])
ds.mean()
ds.sum()
```
#### Problem description
`ds.mean()` returns `NaN`, `ds.sum()` returns `0`. This comes from numpy (cp `np.nanmean` vs. `np.nansum`), so it might have to be discussed upstream, but I wanted to ask the xarray community first on their opinion. This is also relevant for #422 (what happens if the all weights are NaN or sum up to 0).
#### Expected Output
I would expect both to return `np.nan`.
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:01:00)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.4.176-96-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.12.1
pandas: 0.24.2
numpy: 1.16.2
scipy: 1.2.1
netCDF4: 1.5.0.1
pydap: None
h5netcdf: 0.7.1
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: 1.2.0
PseudonetCDF: None
rasterio: 1.0.22
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 1.1.5
distributed: 1.26.1
matplotlib: 3.0.3
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 41.0.0
pip: 19.0.3
conda: None
pytest: 4.4.0
IPython: 7.4.0
sphinx: 2.0.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2889/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
1086797050,I_kwDOAMm_X85AxzT6,6101,enable pytest-xdist again (after dask release),10194086,closed,0,,,0,2021-12-22T12:57:03Z,2022-01-03T08:29:48Z,2022-01-03T08:29:48Z,MEMBER,,,,I disabled pytest-xdist because a dask issue renders our CI unusable. As soon as dask releases a new version we should revert #6077 again.,"{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6101/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
307783090,MDU6SXNzdWUzMDc3ODMwOTA=,2007,rolling: allow control over padding,10194086,open,0,,,20,2018-03-22T19:27:07Z,2021-07-14T19:10:47Z,,MEMBER,,,,"#### Code Sample, a copy-pastable example if possible
```python
import numpy as np
import xarray as xr
x = np.arange(1, 366)
y = np.random.randn(365)
ds = xr.DataArray(y, dims=dict(dayofyear=x))
ds.rolling(center=True, dayofyear=31).mean()
```
#### Problem description
`rolling` cannot directly handle periodic boundary conditions (lon, dayofyear, ...), but could be very helpful to e.g. calculate climate indices. Also I cannot really think of an easy way to append the first elements to the end of the dataset and then calculate rolling.
Is there a way to do this? Should xarray support this feature?
This might also belong to SO...
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2007/reactions"", ""total_count"": 3, ""+1"": 3, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
788534915,MDU6SXNzdWU3ODg1MzQ5MTU=,4824,combine_by_coords can succed when it shouldn't,10194086,open,0,,,15,2021-01-18T20:39:29Z,2021-07-08T17:44:38Z,,MEMBER,,,,"**What happened**:
`combine_by_coords` can succeed when it should not - depending on the name of the dimensions (which determines the order of operations in `combine_by_coords`).
**What you expected to happen**:
* I think it should throw an error in both cases.
**Minimal Complete Verifiable Example**:
```python
import numpy as np
import xarray as xr
data = np.arange(5).reshape(1, 5)
x = np.arange(5)
x_name = ""lat""
da0 = xr.DataArray(data, dims=(""t"", x_name), coords={""t"": [1], x_name: x}).to_dataset(name=""a"")
x = x + 1e-6
da1 = xr.DataArray(data, dims=(""t"", x_name), coords={""t"": [2], x_name: x}).to_dataset(name=""a"")
ds = xr.combine_by_coords((da0, da1))
ds
```
returns:
```python
Dimensions: (lat: 10, t: 2)
Coordinates:
* lat (lat) float64 0.0 1e-06 1.0 1.0 2.0 2.0 3.0 3.0 4.0 4.0
* t (t) int64 1 2
Data variables:
a (t, lat) float64 0.0 nan 1.0 nan 2.0 nan ... 2.0 nan 3.0 nan 4.0
```
Thus lat is interlaced - it don't think `combine_by_coords` should do this. If you set
```python
x_name = ""lat""
```
and run the example again, it returns:
```python-traceback
ValueError: Resulting object does not have monotonic global indexes along dimension x
```
**Anything else we need to know?**:
* this is vaguely related to #4077 but I think it is separate
* `combine_by_coords` concatenates over all dimensions where the coords are different - therefore `compat=""override""` doesn't actually do anything? Or does it?
https://github.com/pydata/xarray/blob/ba42c08af9afbd9e79d47bda404bf4a92a7314a0/xarray/core/combine.py#L69
cc @dcherian @TomNicholas
**Environment**:
Output of xr.show_versions()
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4824/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
773750763,MDU6SXNzdWU3NzM3NTA3NjM=,4727,xr.testing.assert_equal does not test for dtype,10194086,open,0,,,5,2020-12-23T13:14:41Z,2021-07-04T04:08:51Z,,MEMBER,,,,"In #4622 @toddrjen points out that `xr.testing.assert_equal` does not test for the `dtype`, only for the value. Therefore the following does not raise an error:
```python
import numpy as np
import xarray as xr
import pandas as pd
xr.testing.assert_equal(
xr.DataArray(np.array(1, dtype=int)), xr.DataArray(np.array(1, dtype=float))
)
xr.testing.assert_equal(
xr.DataArray(np.array(1, dtype=int)), xr.DataArray(np.array(1, dtype=object))
)
xr.testing.assert_equal(
xr.DataArray(np.array(""a"", dtype=str)), xr.DataArray(np.array(""a"", dtype=object))
)
```
This comes back to numpy, i.e. the following is True:
```python
np.array(1, dtype=int) == np.array(1, dtype=float)
```
Depending on the situation one or the other is desirable or not. Thus, I would suggest to add a `check_dtype` argument to `xr.testing.assert_equal` and also to `DataArray.equals` (and `Dataset` and `Variable` and `identical`). I have not seen such an option in numpy, but pandas has it (e.g. `pd.testing.assert_series_equal(left, right, check_dtype=True, ...) `. I would _not_ change `__eq__`.
* Thoughts?
* What should the default be? We could try `True` first and see how many failures this creates?
* What to do with coords and indexes? `pd.testing.assert_series_equal` has a `check_index_type` keyword. Probably we need `check_coords_type` as well? This makes the whole thing much more complicated... Also #4543
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4727/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
559217441,MDU6SXNzdWU1NTkyMTc0NDE=,3744,Contour with vmin/ vmax differs from matplotlib,10194086,open,0,,,0,2020-02-03T17:11:24Z,2021-07-04T02:03:02Z,,MEMBER,,,,"#### MCVE Code Sample
```python
import numpy as np
import xarray as xr
import matplotlib as mpl
import matplotlib.pyplot as plt
data = xr.DataArray(np.arange(24).reshape(4, 6))
data.plot.contour(vmax=10, add_colorbar=True)
```

#### Expected Output
```python
h = plt.contour(data.values, vmax=10)
plt.colorbar(h)
```

#### Problem Description
A `contour(vmax=vmax)` plot differs between xarray and matplotlib. I *think* the problem is here:
https://github.com/pydata/xarray/blob/95e4f6c7a636878c94b892ee8d49866823d0748f/xarray/plot/utils.py#L265
xarray calculates the levels from `vmax` while matplotlib (probably) calculates the `levels` from `data.max()` and uses `vmax` only for the `norm`. For `contourf` and `pcolormesh` this is not so relevant as the capped values are then drawn with the `over` color. However, there may also be a good reason for this behavior.
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: 4c96d53e6caa78d56b785f4edee49bbd4037a82f
python: 3.7.6 | packaged by conda-forge | (default, Jan 7 2020, 22:33:48)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.36-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.6.2
xarray: 999 (master)
pandas: 0.25.3
numpy: 1.17.3
scipy: 1.4.1
netCDF4: 1.5.1.2
pydap: installed
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: 1.5.5
zarr: 2.4.0
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: installed
rasterio: 1.1.0
cfgrib: 0.9.7.6
iris: 2.2.0
bottleneck: 1.3.1
dask: 2.9.2
distributed: 2.9.2
matplotlib: 3.1.2
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: installed
setuptools: 45.0.0.post20200113
pip: 19.3.1
conda: None
pytest: 5.3.3
IPython: 7.11.1
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3744/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
587048587,MDU6SXNzdWU1ODcwNDg1ODc=,3883,weighted operations: performance optimisations,10194086,open,0,,,3,2020-03-24T15:31:54Z,2021-07-04T02:01:28Z,,MEMBER,,,,"There was a discussion on the performance of the weighted mean/ sum in terms of memory footprint but also speed, and there may indeed be some things that can be optimized. See the [posts at the end of the PR](https://github.com/pydata/xarray/pull/2922#issuecomment-601496897). However, the optimal implementation will probably depend on the use case and some profiling will be required.
I'll just open an issue to keep track of this.
@seth-p ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3883/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
834641104,MDU6SXNzdWU4MzQ2NDExMDQ=,5053,ImportError: module 'xarray.backends.*' has no attribute '*_backend',10194086,closed,0,,,3,2021-03-18T10:44:33Z,2021-04-25T16:23:20Z,2021-04-25T16:23:19Z,MEMBER,,,,"**What happened**:
I could not open the test dataset on master. It's a bit strange that this is not picked up by the tests, so probably something to do with the environment I have (I just updated all packages).
@alexamici @aurghs does that tell you anything?
I can also try to figure it out.
**Minimal Complete Verifiable Example**:
calling `open_dataset` with `""""` is enough to trigger the error:
```python
import xarray as xr
air = xr.open_dataset("""")
```
**Anything else we need to know?**:
And the traceback:
```python-traceback
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/conda/envs/xarray_dev/lib/python3.8/site-packages/pkg_resources/__init__.py in resolve(self)
2479 try:
-> 2480 return functools.reduce(getattr, self.attrs, module)
2481 except AttributeError as exc:
AttributeError: module 'xarray.backends.cfgrib_' has no attribute 'cfgrib_backend'
The above exception was the direct cause of the following exception:
ImportError Traceback (most recent call last)
in
----> 1 air = xr.tutorial.open_dataset(""air_temperature"")
~/code/xarray/xarray/tutorial.py in open_dataset(name, cache, cache_dir, github_url, branch, **kws)
93 raise OSError(msg)
94
---> 95 ds = _open_dataset(localfile, **kws)
96
97 if not cache:
~/code/xarray/xarray/backends/api.py in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, backend_kwargs, *args, **kwargs)
491
492 if engine is None:
--> 493 engine = plugins.guess_engine(filename_or_obj)
494
495 backend = plugins.get_backend(engine)
~/code/xarray/xarray/backends/plugins.py in guess_engine(store_spec)
99
100 def guess_engine(store_spec):
--> 101 engines = list_engines()
102
103 for engine, backend in engines.items():
~/code/xarray/xarray/backends/plugins.py in list_engines()
95 def list_engines():
96 pkg_entrypoints = pkg_resources.iter_entry_points(""xarray.backends"")
---> 97 return build_engines(pkg_entrypoints)
98
99
~/code/xarray/xarray/backends/plugins.py in build_engines(pkg_entrypoints)
82 backend_entrypoints = BACKEND_ENTRYPOINTS.copy()
83 pkg_entrypoints = remove_duplicates(pkg_entrypoints)
---> 84 external_backend_entrypoints = backends_dict_from_pkg(pkg_entrypoints)
85 backend_entrypoints.update(external_backend_entrypoints)
86 backend_entrypoints = sort_backends(backend_entrypoints)
~/code/xarray/xarray/backends/plugins.py in backends_dict_from_pkg(pkg_entrypoints)
56 for pkg_ep in pkg_entrypoints:
57 name = pkg_ep.name
---> 58 backend = pkg_ep.load()
59 backend_entrypoints[name] = backend
60 return backend_entrypoints
~/conda/envs/xarray_dev/lib/python3.8/site-packages/pkg_resources/__init__.py in load(self, require, *args, **kwargs)
2470 if require:
2471 self.require(*args, **kwargs)
-> 2472 return self.resolve()
2473
2474 def resolve(self):
~/conda/envs/xarray_dev/lib/python3.8/site-packages/pkg_resources/__init__.py in resolve(self)
2480 return functools.reduce(getattr, self.attrs, module)
2481 except AttributeError as exc:
-> 2482 raise ImportError(str(exc)) from exc
2483
2484 def require(self, env=None, installer=None):
ImportError: module 'xarray.backends.cfgrib_' has no attribute 'cfgrib_backend'
```
**Environment**:
Output of xr.show_versions()
```
INSTALLED VERSIONS
------------------
commit: a6f51c680f4e4c3ed5101b9c1111f0b94d28a781
python: 3.8.6 | packaged by conda-forge | (default, Jan 25 2021, 23:21:18)
[GCC 9.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-67-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.16.2.dev111+g0d93c4f9.d20201219
pandas: 1.2.3
numpy: 1.20.1
scipy: 1.6.1
netCDF4: 1.5.6
pydap: installed
h5netcdf: 0.10.0
h5py: 3.1.0
Nio: None
zarr: 2.6.1
cftime: 1.4.1
nc_time_axis: 1.2.0
PseudoNetCDF: installed
rasterio: 1.2.1
cfgrib: 0.9.8.5
iris: 2.4.0
bottleneck: 1.3.2
dask: 2021.03.0
distributed: 2021.03.0
matplotlib: 3.3.4
cartopy: 0.18.0
seaborn: 0.11.1
numbagg: installed
pint: 0.16.1
setuptools: 49.6.0.post20210108
pip: 21.0.1
conda: None
pytest: 6.2.2
IPython: 7.21.0
sphinx: None
```
and my conda list:
```
# packages in environment at /home/mathause/conda/envs/xarray_dev:
#
# Name Version Build Channel
_libgcc_mutex 0.1 conda_forge conda-forge
_openmp_mutex 4.5 1_gnu conda-forge
affine 2.3.0 py_0 conda-forge
antlr-python-runtime 4.7.2 py38h578d9bd_1002 conda-forge
apipkg 1.5 py_0 conda-forge
appdirs 1.4.4 pyh9f0ad1d_0 conda-forge
asciitree 0.3.3 py_2 conda-forge
attrs 20.3.0 pyhd3deb0d_0 conda-forge
backcall 0.2.0 pyh9f0ad1d_0 conda-forge
backports 1.0 py_2 conda-forge
backports.functools_lru_cache 1.6.1 py_0 conda-forge
beautifulsoup4 4.9.3 pyhb0f4dca_0 conda-forge
black 20.8b1 py_1 conda-forge
bokeh 2.3.0 py38h578d9bd_0 conda-forge
boost-cpp 1.72.0 h9d3c048_4 conda-forge
boto3 1.17.30 pyhd8ed1ab_0 conda-forge
botocore 1.20.30 pyhd8ed1ab_0 conda-forge
bottleneck 1.3.2 py38h5c078b8_3 conda-forge
brotlipy 0.7.0 py38h497a2fe_1001 conda-forge
bzip2 1.0.8 h7f98852_4 conda-forge
c-ares 1.17.1 h7f98852_1 conda-forge
ca-certificates 2020.12.5 ha878542_0 conda-forge
cached-property 1.5.2 hd8ed1ab_1 conda-forge
cached_property 1.5.2 pyha770c72_1 conda-forge
cairo 1.16.0 h7979940_1007 conda-forge
cartopy 0.18.0 py38hab71064_13 conda-forge
cdat_info 8.2.1 pyh9f0ad1d_1 conda-forge
cdms2 3.1.5 pypi_0 pypi
cdtime 3.1.4 py38h49bcaf2_2 conda-forge
certifi 2020.12.5 py38h578d9bd_1 conda-forge
cf-units 2.1.4 py38hab2c0dc_2 conda-forge
cffi 1.14.5 py38ha65f79e_0 conda-forge
cfgrib 0.9.8.5 pyhd8ed1ab_0 conda-forge
cfgv 3.2.0 py_0 conda-forge
cfitsio 3.470 hb418390_7 conda-forge
cftime 1.4.1 py38h5c078b8_0 conda-forge
chardet 4.0.0 py38h578d9bd_1 conda-forge
click 7.1.2 pyh9f0ad1d_0 conda-forge
click-plugins 1.1.1 py_0 conda-forge
cligj 0.7.1 pyhd8ed1ab_0 conda-forge
cloudpickle 1.6.0 py_0 conda-forge
coverage 5.5 py38h497a2fe_0 conda-forge
coveralls 3.0.1 pyhd8ed1ab_0 conda-forge
cryptography 3.4.6 py38ha5dfef3_0 conda-forge
curl 7.75.0 h979ede3_0 conda-forge
cycler 0.10.0 py_2 conda-forge
cytoolz 0.11.0 py38h497a2fe_3 conda-forge
dask 2021.3.0 pyhd8ed1ab_0 conda-forge
dask-core 2021.3.0 pyhd8ed1ab_0 conda-forge
dataclasses 0.8 pyhc8e2a94_1 conda-forge
dbus 1.13.6 hfdff14a_1 conda-forge
decorator 4.4.2 py_0 conda-forge
distarray 2.12.2 py_1 conda-forge
distlib 0.3.1 pyh9f0ad1d_0 conda-forge
distributed 2021.3.0 py38h578d9bd_0 conda-forge
docopt 0.6.2 py_1 conda-forge
eccodes 2.20.0 ha0e6eb6_0 conda-forge
editdistance 0.5.3 py38h709712a_3 conda-forge
esmf 8.0.1 mpi_mpich_h3cbecb6_102 conda-forge
esmpy 8.0.1 mpi_mpich_py38h6f0bf2d_102 conda-forge
execnet 1.8.0 pyh44b312d_0 conda-forge
expat 2.2.10 h9c3ff4c_0 conda-forge
fasteners 0.14.1 py_3 conda-forge
filelock 3.0.12 pyh9f0ad1d_0 conda-forge
flake8 3.9.0 pyhd8ed1ab_0 conda-forge
fontconfig 2.13.1 hba837de_1004 conda-forge
freetype 2.10.4 h0708190_1 conda-forge
freexl 1.0.6 h7f98852_0 conda-forge
fsspec 0.8.7 pyhd8ed1ab_0 conda-forge
future 0.18.2 py38h578d9bd_3 conda-forge
g2clib 1.6.0 hf3f1b0b_9 conda-forge
geos 3.9.1 h9c3ff4c_2 conda-forge
geotiff 1.6.0 h11d48b3_4 conda-forge
gettext 0.19.8.1 h0b5b191_1005 conda-forge
giflib 5.2.1 h516909a_2 conda-forge
glib 2.66.7 h9c3ff4c_1 conda-forge
glib-tools 2.66.7 h9c3ff4c_1 conda-forge
gprof2dot 2019.11.30 py_0 conda-forge
gst-plugins-base 1.18.4 h29181c9_0 conda-forge
gstreamer 1.18.4 h76c114f_0 conda-forge
h5netcdf 0.10.0 pyhd8ed1ab_0 conda-forge
h5py 3.1.0 nompi_py38hafa665b_100 conda-forge
hdf4 4.2.13 h10796ff_1004 conda-forge
hdf5 1.10.6 mpi_mpich_h996c276_1014 conda-forge
heapdict 1.0.1 py_0 conda-forge
hypothesis 6.8.1 pyhd8ed1ab_0 conda-forge
icu 68.1 h58526e2_0 conda-forge
identify 2.1.3 pyhd8ed1ab_0 conda-forge
idna 2.10 pyh9f0ad1d_0 conda-forge
importlib-metadata 3.7.3 py38h578d9bd_0 conda-forge
importlib_metadata 3.7.3 hd8ed1ab_0 conda-forge
importlib_resources 5.1.2 py38h578d9bd_0 conda-forge
iniconfig 1.1.1 pyh9f0ad1d_0 conda-forge
ipython 7.21.0 py38h81c977d_0 conda-forge
ipython_genutils 0.2.0 py_1 conda-forge
iris 2.4.0 py38h578d9bd_1 conda-forge
isort 5.7.0 pyhd8ed1ab_0 conda-forge
jasper 1.900.1 h07fcdf6_1006 conda-forge
jedi 0.18.0 py38h578d9bd_2 conda-forge
jinja2 2.11.3 pyh44b312d_0 conda-forge
jmespath 0.10.0 pyh9f0ad1d_0 conda-forge
jpeg 9d h516909a_0 conda-forge
json-c 0.15 h98cffda_0 conda-forge
jsonschema 3.2.0 py38h32f6830_1 conda-forge
jupyter_core 4.7.1 py38h578d9bd_0 conda-forge
kealib 1.4.14 hcc255d8_2 conda-forge
kiwisolver 1.3.1 py38h1fd1430_1 conda-forge
krb5 1.17.2 h926e7f8_0 conda-forge
lazy-object-proxy 1.5.2 py38h497a2fe_1 conda-forge
lcms2 2.12 hddcbb42_0 conda-forge
ld_impl_linux-64 2.35.1 hea4e1c9_2 conda-forge
libaec 1.0.4 he1b5a44_1 conda-forge
libblas 3.8.0 17_openblas conda-forge
libcblas 3.8.0 17_openblas conda-forge
libcdms 3.1.2 h981a4fd_113 conda-forge
libcf 1.0.3 py38h88b7cc0_109 conda-forge
libclang 11.1.0 default_ha53f305_0 conda-forge
libcst 0.3.17 py38h578d9bd_0 conda-forge
libcurl 7.75.0 hc4aaa36_0 conda-forge
libdap4 3.20.6 hd7c4107_1 conda-forge
libdrs 3.1.2 h7918d09_113 conda-forge
libdrs_f 3.1.2 h5026c31_111 conda-forge
libedit 3.1.20191231 he28a2e2_2 conda-forge
libev 4.33 h516909a_1 conda-forge
libevent 2.1.10 hcdb4288_3 conda-forge
libffi 3.3 h58526e2_2 conda-forge
libgcc-ng 9.3.0 h2828fa1_18 conda-forge
libgdal 3.2.1 h38ff51b_7 conda-forge
libgfortran-ng 9.3.0 hff62375_18 conda-forge
libgfortran5 9.3.0 hff62375_18 conda-forge
libglib 2.66.7 h3e27bee_1 conda-forge
libgomp 9.3.0 h2828fa1_18 conda-forge
libiconv 1.16 h516909a_0 conda-forge
libkml 1.3.0 hd79254b_1012 conda-forge
liblapack 3.8.0 17_openblas conda-forge
libllvm10 10.0.1 he513fc3_3 conda-forge
libllvm11 11.1.0 hf817b99_0 conda-forge
libnetcdf 4.7.4 mpi_mpich_hdef422e_7 conda-forge
libnghttp2 1.43.0 h812cca2_0 conda-forge
libopenblas 0.3.10 pthreads_h4812303_5 conda-forge
libpng 1.6.37 hed695b0_2 conda-forge
libpq 13.1 hfd2b0eb_2 conda-forge
librttopo 1.1.0 h1185371_6 conda-forge
libspatialite 5.0.1 he52d314_3 conda-forge
libssh2 1.9.0 ha56f1ee_6 conda-forge
libstdcxx-ng 9.3.0 h6de172a_18 conda-forge
libtiff 4.2.0 hdc55705_0 conda-forge
libuuid 2.32.1 h14c3975_1000 conda-forge
libwebp-base 1.2.0 h7f98852_2 conda-forge
libxcb 1.13 h7f98852_1003 conda-forge
libxkbcommon 1.0.3 he3ba5ed_0 conda-forge
libxml2 2.9.10 h72842e0_3 conda-forge
libxslt 1.1.33 h15afd5d_2 conda-forge
line_profiler 3.1.0 py38h82cb98a_1 conda-forge
llvmlite 0.36.0 py38h4630a5e_0 conda-forge
locket 0.2.0 py_2 conda-forge
lxml 4.6.2 py38hf1fe3a4_1 conda-forge
lz4-c 1.9.3 h9c3ff4c_0 conda-forge
markupsafe 1.1.1 py38h497a2fe_3 conda-forge
matplotlib 3.3.4 py38h578d9bd_0 conda-forge
matplotlib-base 3.3.4 py38h0efea84_0 conda-forge
mccabe 0.6.1 py_1 conda-forge
mechanicalsoup 1.0.0 pyhd8ed1ab_0 conda-forge
monkeytype 20.5.0 pyh516909a_0 conda-forge
monotonic 1.5 py_0 conda-forge
more-itertools 8.7.0 pyhd8ed1ab_0 conda-forge
mpi 1.0 mpich conda-forge
mpi4py 3.0.3 py38he865349_5 conda-forge
mpich 3.4.1 h846660c_104 conda-forge
msgpack-python 1.0.2 py38h1fd1430_1 conda-forge
mypy 0.812 pyhd8ed1ab_0 conda-forge
mypy_extensions 0.4.3 py38h578d9bd_3 conda-forge
mysql-common 8.0.23 ha770c72_1 conda-forge
mysql-libs 8.0.23 h935591d_1 conda-forge
nbformat 5.1.2 pyhd8ed1ab_1 conda-forge
nc-time-axis 1.2.0 py_1 conda-forge
ncurses 6.2 h58526e2_4 conda-forge
netcdf-fortran 4.5.3 mpi_mpich_h7ad8bfe_1 conda-forge
netcdf4 1.5.6 nompi_py38h1cdf482_100 conda-forge
nodeenv 1.5.0 pyh9f0ad1d_0 conda-forge
nspr 4.30 h9c3ff4c_0 conda-forge
nss 3.62 hb5efdd6_0 conda-forge
numba 0.53.0 py38h5e62926_1 conda-forge
numbagg 0.1 pypi_0 pypi
numcodecs 0.7.3 py38h709712a_0 conda-forge
numpy 1.20.1 py38h18fd61f_0 conda-forge
olefile 0.46 pyh9f0ad1d_1 conda-forge
openblas 0.3.10 pthreads_h04b7a96_5 conda-forge
openjpeg 2.4.0 hf7af979_0 conda-forge
openssl 1.1.1j h7f98852_0 conda-forge
packaging 20.9 pyh44b312d_0 conda-forge
pandas 1.2.3 py38h51da96c_0 conda-forge
parso 0.8.1 pyhd8ed1ab_0 conda-forge
partd 1.1.0 py_0 conda-forge
pathspec 0.8.1 pyhd3deb0d_0 conda-forge
patsy 0.5.1 py_0 conda-forge
pcre 8.44 he1b5a44_0 conda-forge
pexpect 4.8.0 py38h32f6830_1 conda-forge
pickleshare 0.7.5 py38h32f6830_1002 conda-forge
pillow 8.1.2 py38ha0e1e83_0 conda-forge
pint 0.16.1 py_0 conda-forge
pip 21.0.1 pyhd8ed1ab_0 conda-forge
pixman 0.40.0 h36c2ea0_0 conda-forge
pluggy 0.13.1 py38h578d9bd_4 conda-forge
poppler 0.89.0 h2de54a5_5 conda-forge
poppler-data 0.4.10 0 conda-forge
postgresql 13.1 h6303168_2 conda-forge
pre-commit 2.11.1 py38h578d9bd_0 conda-forge
proj 7.2.0 h277dcde_2 conda-forge
prompt-toolkit 3.0.17 pyha770c72_0 conda-forge
pseudonetcdf 3.1.0 py_1 conda-forge
psutil 5.8.0 py38h497a2fe_1 conda-forge
pthread-stubs 0.4 h36c2ea0_1001 conda-forge
ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge
py 1.10.0 pyhd3deb0d_0 conda-forge
pycodestyle 2.7.0 pyhd8ed1ab_0 conda-forge
pycparser 2.20 pyh9f0ad1d_2 conda-forge
pydap 3.2.2 py38_1000 conda-forge
pyflakes 2.3.0 pyhd8ed1ab_0 conda-forge
pygments 2.8.1 pyhd8ed1ab_0 conda-forge
pyke 1.1.1 py38h578d9bd_1003 conda-forge
pyopenssl 20.0.1 pyhd8ed1ab_0 conda-forge
pyparsing 2.4.7 pyh9f0ad1d_0 conda-forge
pyqt 5.12.3 py38h578d9bd_7 conda-forge
pyqt-impl 5.12.3 py38h7400c14_7 conda-forge
pyqt5-sip 4.19.18 py38h709712a_7 conda-forge
pyqtchart 5.12 py38h7400c14_7 conda-forge
pyqtwebengine 5.12.1 py38h7400c14_7 conda-forge
pyrsistent 0.17.3 py38h497a2fe_2 conda-forge
pyshp 2.1.3 pyh44b312d_0 conda-forge
pysocks 1.7.1 py38h578d9bd_3 conda-forge
pytest 6.2.2 py38h578d9bd_0 conda-forge
pytest-cov 2.11.1 pyh44b312d_0 conda-forge
pytest-env 0.6.2 py_0 conda-forge
pytest-forked 1.3.0 pyhd3deb0d_0 conda-forge
pytest-profiling 1.7.0 py_1 conda-forge
pytest-xdist 2.2.1 pyhd8ed1ab_0 conda-forge
python 3.8.6 hffdb5ce_5_cpython conda-forge
python-dateutil 2.8.1 py_0 conda-forge
python-xxhash 2.0.0 py38h497a2fe_1 conda-forge
python_abi 3.8 1_cp38 conda-forge
pytz 2021.1 pyhd8ed1ab_0 conda-forge
pyyaml 5.4.1 py38h497a2fe_0 conda-forge
qt 5.12.9 hda022c4_4 conda-forge
rasterio 1.2.1 py38h57accd2_2 conda-forge
readline 8.0 he28a2e2_2 conda-forge
regex 2020.11.13 py38h497a2fe_1 conda-forge
regrid2 3.1.5 pypi_0 pypi
requests 2.25.1 pyhd3deb0d_0 conda-forge
s3transfer 0.3.4 pyhd8ed1ab_0 conda-forge
scipy 1.6.1 py38hb2138dd_0 conda-forge
seaborn 0.11.1 ha770c72_0 conda-forge
seaborn-base 0.11.1 pyhd8ed1ab_1 conda-forge
setuptools 49.6.0 py38h578d9bd_3 conda-forge
shapely 1.7.1 py38h4fc1155_4 conda-forge
six 1.15.0 pyh9f0ad1d_0 conda-forge
snuggs 1.4.7 py_0 conda-forge
sortedcontainers 2.3.0 pyhd8ed1ab_0 conda-forge
soupsieve 2.0.1 py38h32f6830_0 conda-forge
sparse 0.11.2 py_0 conda-forge
sqlite 3.34.0 h74cdb3f_0 conda-forge
statsmodels 0.12.2 py38h5c078b8_0 conda-forge
tblib 1.6.0 py_0 conda-forge
tiledb 2.2.5 h91fcb0e_0 conda-forge
tk 8.6.10 hed695b0_1 conda-forge
toml 0.10.2 pyhd8ed1ab_0 conda-forge
toolz 0.11.1 py_0 conda-forge
tornado 6.1 py38h497a2fe_1 conda-forge
traitlets 5.0.5 py_0 conda-forge
typed-ast 1.4.2 py38h497a2fe_0 conda-forge
typing_extensions 3.7.4.3 py_0 conda-forge
typing_inspect 0.6.0 pyh9f0ad1d_0 conda-forge
tzcode 2021a h7f98852_1 conda-forge
tzdata 2021a he74cb21_0 conda-forge
udunits2 2.2.27.27 h360fe7b_0 conda-forge
urllib3 1.26.4 pyhd8ed1ab_0 conda-forge
virtualenv 20.4.3 py38h578d9bd_0 conda-forge
wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge
webob 1.8.6 py_0 conda-forge
wheel 0.36.2 pyhd3deb0d_0 conda-forge
xarray 0.16.2.dev111+g0d93c4f9.d20201219 dev_0
xerces-c 3.2.3 h9d8b166_2 conda-forge
xorg-kbproto 1.0.7 h14c3975_1002 conda-forge
xorg-libice 1.0.10 h516909a_0 conda-forge
xorg-libsm 1.2.3 hd9c2040_1000 conda-forge
xorg-libx11 1.7.0 h36c2ea0_0 conda-forge
xorg-libxau 1.0.9 h14c3975_0 conda-forge
xorg-libxdmcp 1.1.3 h516909a_0 conda-forge
xorg-libxext 1.3.4 h7f98852_1 conda-forge
xorg-libxrender 0.9.10 h7f98852_1003 conda-forge
xorg-renderproto 0.11.1 h14c3975_1002 conda-forge
xorg-xextproto 7.3.0 h14c3975_1002 conda-forge
xorg-xproto 7.0.31 h14c3975_1007 conda-forge
xxhash 0.8.0 h7f98852_3 conda-forge
xz 5.2.5 h516909a_1 conda-forge
yaml 0.2.5 h516909a_0 conda-forge
zarr 2.6.1 pyhd8ed1ab_0 conda-forge
zict 2.0.0 py_0 conda-forge
zipp 3.4.1 pyhd8ed1ab_0 conda-forge
zlib 1.2.11 h516909a_1010 conda-forge
zstd 1.4.9 ha95c52a_0 conda-forge
```
---
edit: added the traceback","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/5053/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
806218687,MDU6SXNzdWU4MDYyMTg2ODc=,4892,disallow boolean coordinates?,10194086,open,0,,,2,2021-02-11T09:33:17Z,2021-03-31T10:30:49Z,,MEMBER,,,,"Today I stumbled over a small pitfall, which I think could be avoided:
I am working with arrays that have axes labeled with categorical values and I ended up using True/False as labels for some binary categories:
```python
test = xarray.DataArray(
numpy.ones((3,2)),
dims=[""binary"",""ternary""],
coords={""ternary"":[3,7,9],""binary"":[False,True]}
)
```
now came the big surprise, when I wanted to reduce over selections of the data:
```
test.sel(ternary=[9,3,7]) # does exactly what I expect and gives me the correctly permuted 3x2 array
test.sel(binary=[True,False]) # does not do what I expect
```
Instead of using the coordinate values like with the ternary category, it uses the list as boolean mask and hence I get a 3x1 array at the binary=False coordinate.
I assume that this behavior is reasonable in most cases - And I for sure will stop using bools as binary category labels.
That said in the above case the conceptually identical call results in completely different outcome.
My (radical) proposal would be: forbid binary coordinates in general to avoid such confusion.
Curious about your thoughts! Hth,
Marti
_Originally posted by @martinitus in https://github.com/pydata/xarray/discussions/4861_","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4892/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
683777199,MDU6SXNzdWU2ODM3NzcxOTk=,4364,plt.pcolormesh will infer interval breaks per default,10194086,open,0,,,3,2020-08-21T19:15:57Z,2021-03-19T14:09:52Z,,MEMBER,,,,"Looking at some warnings in #3266 I saw that matplotlib will deprecate the old behaviour of `pcolormesh` when the shape of the data and the coordinates are equal (they silently cut a row and a column of the data). With the new behaviour they will interpolate the coordinates.
```python
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1, 2, 3])
y = np.array([1, 2, 3, 4, 5])
data = np.random.randn(*y.shape + x.shape)
f, axes = plt.subplots(1, 2)
for ax, shading, behavior in zip(axes, [""flat"", ""nearest""], [""old"", ""new""]):
ax.pcolormesh(x, y, data, shading=shading, vmin=-0.75, vmax=0.75)
ax.set_title(f""{behavior}: shading='{shading}'"")
```

This is a good thing in general - we already do this for a long time with the `infer_intervals` keyword. Unfortunately they don't check if the data is monotonic (matplotlib/matplotlib#18317) which can lead to problems for maps (scitools/cartopy#1638). I don't think there is a need to do something right now - let's see what they think upstream.
This change was introduced in mpl 3.3.0
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4364/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
817951965,MDU6SXNzdWU4MTc5NTE5NjU=,4970,minimum version and non-semantic versioning (netCDF4),10194086,closed,0,,,1,2021-02-27T15:33:48Z,2021-03-08T00:20:38Z,2021-03-08T00:20:38Z,MEMBER,,,,"We currently pin netCDF4 to [version 1.5](https://github.com/pydata/xarray/blob/48378c4b11c5c2672ff91396d4284743165b4fbe/ci/requirements/py37-min-all-deps.yml#L28). However, I think netCDF4 does not really follow semantic versioning, e.g. python 2 support was dropped in version 1.5.6. So they may actually be doing something like `1.major.minor[.patch]` - I asked about their versioning scheme in Unidata/netcdf4-python#1090.
So I wonder if we would need to pin netCDF to version to version 1.5.4.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4970/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
814806676,MDU6SXNzdWU4MTQ4MDY2NzY=,4945,Upstream CI failing silently,10194086,closed,0,,,1,2021-02-23T20:30:29Z,2021-02-24T08:14:00Z,2021-02-24T08:14:00Z,MEMBER,,,,"The last 5 days our Upstream CI failed silently with a timeout after 6h:
https://github.com/pydata/xarray/actions/workflows/upstream-dev-ci.yaml?query=branch%3Amaster+event%3Aschedule
This was probably caused by #4934. As mentioned in dask/dask#4934 this is probably dask/dask#6738 which was merged 5 days ago.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4945/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
803402841,MDU6SXNzdWU4MDM0MDI4NDE=,4881,check mypy at the end of some CI runs?,10194086,closed,0,,,2,2021-02-08T10:04:44Z,2021-02-22T16:33:50Z,2021-02-22T16:33:50Z,MEMBER,,,,"We currently run mypy in the `pre-commit hooks` CI. However, this is done in an environment where no dependencies are installed. Therefore we missed the errors that pop up when running mypy with numpy 1.20 installed. (Please correct my if I misunderstood this). Should we add a new step to our CI and run mypy?
I think we should at least add this to `ubuntu-latest py3.8`. For more complete checks we could also go for ` ubuntu-latest py37-min-all-deps` and `upstream-dev`.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4881/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
739008382,MDU6SXNzdWU3MzkwMDgzODI=,4570,fix compatibility with h5py version 3 and unpin tests,10194086,closed,0,,,6,2020-11-09T13:00:01Z,2021-02-17T08:41:20Z,2021-02-17T08:41:20Z,MEMBER,,,,"h5py version 3.1 broke our tests. I pinned it to version 2.10 in #4569. We should therefore
* fix the issues
* unpin h5py again
The failures could be related to a change how strings are read: https://docs.h5py.org/en/latest/strings.html I am not sure if this has to be fixed in xarray or in h5necdf. I'd be happy if someone else took this one.
Failed tests:
```
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_zero_dimensional_variable
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_write_store - As...
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_roundtrip_test_data
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_load - Assertion...
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_dataset_compute
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_roundtrip_object_dtype
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_roundtrip_string_data
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_orthogonal_indexing
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_vectorized_indexing
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_isel_dataarray
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_array_type_after_indexing
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_append_write - A...
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_append_overwrite_values
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_write_groups - A...
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_encoding_kwarg_vlen_string
FAILED xarray/tests/test_backends.py::TestH5NetCDFData::test_compression_encoding
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_zero_dimensional_variable
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_write_store
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_roundtrip_test_data
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_load - Ass...
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_dataset_compute
FAILED xarray/tests/test_backends.py::TestH5NetCDFFileObject::test_roundtrip_object_dtype
FAILED xarray/tests/test_backends.py::TestH5NetCDFViaDaskData::test_encoding_kwarg_vlen_string
FAILED xarray/tests/test_backends.py::TestH5NetCDFViaDaskData::test_compression_encoding
FAILED xarray/tests/test_distributed.py::test_dask_distributed_netcdf_roundtrip[h5netcdf-NETCDF4]
FAILED xarray/tests/test_distributed.py::test_dask_distributed_read_netcdf_integration_test[h5netcdf-NETCDF4]
```
**Example failure:**
```python traceback
> assert_allclose(original, computed)
E AssertionError: Left and right Dataset objects are not close
E
E Differing coordinates:
E L * dim3 (dim3)
**What happened**:
Our doctests fail since numpy 1.20 came out:
https://github.com/pydata/xarray/pull/4760/checks?check_run_id=1818512841#step:8:69
**What you expected to happen**:
They don't ;-)
**Minimal Complete Verifiable Example**:
The following fails with numpy 1.20 while it converted `np.NaN` to an integer before ([xarray.DataArray.pad](http://xarray.pydata.org/en/v0.16.2/generated/xarray.DataArray.pad.html#xarray.DataArray.pad) at the bottom)
```python
import numpy as np
x = np.arange(10)
x = np.pad(x, 1, ""constant"", constant_values=np.nan)
```
requires numpy 1.20
**Anything else we need to know?**:
- that's probably related to https://numpy.org/doc/stable/release/1.20.0-notes.html#numpy-scalars-are-cast-when-assigned-to-arrays
- I asked if this behavior will stay: https://github.com/numpy/numpy/issues/16499#issuecomment-772342087
- One possibility is to add a check `np.can_cast(constant_values.dtype, array.dtype)` (or similar) for a better error message.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4858/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
802992417,MDU6SXNzdWU4MDI5OTI0MTc=,4875,assigning values with incompatible dtype,10194086,open,0,,,0,2021-02-07T16:28:24Z,2021-02-07T16:28:24Z,,MEMBER,,,,"The behavior of xarray when assigning values with incompatible dtypes is a bit arbitrary. This is partly due to the behavior of numpy.... numpy 1.20 got a bit cleverer but still seems inconsistent at times... I am not sure what to do about this (and if we should actually be clever here).
1. Direct assignment (dupe of #4612)
```python
import xarray as xr
import numpy as np
arr = np.array([2])
arr[0] = np.nan
# ValueError (since numpy 1.20)
arr[0:1] = np.array([np.nan])
# -> array([-9223372036854775808])
da = xr.DataArray([5], dims=""x"")
da[0] = np.nan
#
# array([-9223372036854775808])
# Dimensions without coordinates: x
(because this gets converted to da.variable._data[0:1, 0:1] = np.array([np.nan]) (approximately).
da[0] = 1.2345
# casts constant_values to int
```
2. Via a numpy function (`pad`, `shift`, `rolling`)
**pad**
```python
da.pad(x=1, constant_values=np.nan)
# ValueError: cannot convert float NaN to integer
da.pad(x=1, constant_values=None)
# casts da to float
da.pad(x=1, constant_values=1.5)
# casts constant_values to int
```
**shift**
```python
da.shift(x=1, fill_value=np.nan)
# ValueError: cannot convert float NaN to integer
# da.shift(x=1, fill_value=None)
# None not allowed by shift
da.shift(x=1, fill_value=1.5)
# casts fill_value to int
```
**rolling**
```python
da.rolling(x=1).construct(""new_axis"", stride=3, fill_value=np.nan)
# ValueError: cannot convert float NaN to integer
# da.rolling(x=1).construct(""new_axis"", stride=3, fill_value=None)
# None not allowed by rolling
da.rolling(x=3).construct(""new_axis"", stride=3, fill_value=1.5)
# casts fill_value to int
```
---
To check:
* What does dask do in these cases?
* What does pandas do?
* What about `str` dtypes?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4875/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,,13221727,issue
785825401,MDU6SXNzdWU3ODU4MjU0MDE=,4808,"Upstream dev CI does not show ""version info""",10194086,closed,0,,,3,2021-01-14T09:24:04Z,2021-01-15T01:01:04Z,2021-01-14T23:45:07Z,MEMBER,,,,"Would be nice if it did :-)
e.g. https://github.com/pydata/xarray/runs/1698988952","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4808/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
722437965,MDU6SXNzdWU3MjI0Mzc5NjU=,4514,"encode_cf_datetime: reference_date can not be ""2000-02-30""",10194086,closed,0,,,3,2020-10-15T15:25:10Z,2021-01-05T15:42:37Z,2021-01-05T15:42:37Z,MEMBER,,,,"**What happened**:
I try to save the result of `ds.resample(""time"": ""Q-FEB"").mean()` with a `360_day` calendar as netcdf. Thus, my first date is `cftime.Datetime360Day(2000-02-30)` (note the day). xarray then tries to use `units='days since 2000-02-30'` which fails with `ValueError: day is out of range for month`.
**What you expected to happen**:
The dataset can be saved.
**Minimal Complete Verifiable Example**:
```python
import cftime
import xarray as xr
time = xr.cftime_range(""2000-02-30"", ""2001-01-01"", freq=""3M"", calendar=""360_day"")
dates = np.asarray(time)
reference_date = xr.coding.times.infer_datetime_units(dates)
# 'days since 2000-02-30 00:00:00.000000'
xr.coding.times.encode_cf_datetime(time)
# ValueError
```
Traceback:
```python-traceback
---------------------------------------------------------------------------
OutOfBoundsDatetime Traceback (most recent call last)
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/coding/times.py in encode_cf_datetime(dates, units, calendar)
367 # parse with cftime instead
--> 368 raise OutOfBoundsDatetime
369 assert dates.dtype == ""datetime64[ns]""
OutOfBoundsDatetime:
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
in
4 time = xr.cftime_range(""2000-02-30"", ""2001-01-01"", freq=""3M"", calendar=""360_day"")
5
----> 6 xr.coding.times.encode_cf_datetime(time)
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/coding/times.py in encode_cf_datetime(dates, units, calendar)
385
386 except (OutOfBoundsDatetime, OverflowError):
--> 387 num = _encode_datetime_with_cftime(dates, units, calendar)
388
389 num = cast_to_int_if_safe(num)
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/coding/times.py in _encode_datetime_with_cftime(dates, units, calendar)
332 return np.nan if d is None else cftime.date2num(d, units, calendar)
333
--> 334 return np.vectorize(encode_datetime)(dates)
335
336
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/numpy/lib/function_base.py in __call__(self, *args, **kwargs)
2089 vargs.extend([kwargs[_n] for _n in names])
2090
-> 2091 return self._vectorize_call(func=func, args=vargs)
2092
2093 def _get_ufunc_and_otypes(self, func, args):
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/numpy/lib/function_base.py in _vectorize_call(self, func, args)
2159 res = func()
2160 else:
-> 2161 ufunc, otypes = self._get_ufunc_and_otypes(func=func, args=args)
2162
2163 # Convert args to object arrays first
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/numpy/lib/function_base.py in _get_ufunc_and_otypes(self, func, args)
2119
2120 inputs = [arg.flat[0] for arg in args]
-> 2121 outputs = func(*inputs)
2122
2123 # Performance note: profiling indicates that -- for simple
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/coding/times.py in encode_datetime(d)
330
331 def encode_datetime(d):
--> 332 return np.nan if d is None else cftime.date2num(d, units, calendar)
333
334 return np.vectorize(encode_datetime)(dates)
cftime/_cftime.pyx in cftime._cftime.date2num()
cftime/_cftime.pyx in cftime._cftime._dateparse()
ValueError: day is out of range for month
```
**Anything else we need to know?**:
This goes wrong here:
https://github.com/pydata/xarray/blob/15537497136345ed67e9e8b089bcd4573df0b2ea/xarray/coding/times.py#L249-L250
A possible fix is to add the following lines:
```python
try:
cftime._cftime._dateparse(reference_date)
except ValueError:
reference_date = type(dates[0])(dates[0].year, dates[0].month, 1)
reference_date = xr.coding.times.format_cftime_datetime(reference_date)
```
To workaround set the encoding manually:
```python
encoding = {}
encoding['time'] = {'units': 'days since 1850-01-01'}
ds.to_netcdf(filename, encoding=encoding)
```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4514/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
761266480,MDU6SXNzdWU3NjEyNjY0ODA=,4671,windows test timeout,10194086,closed,0,,,3,2020-12-10T14:00:54Z,2020-12-15T16:40:38Z,2020-12-15T16:40:38Z,MEMBER,,,,"The windows tests seem to regularly time out after 60 min, which is annoying. All other tests seem to run about twice as fast... There is some stuff we can try (which may or may not help):
- [ ] switch to the newest windows image
- [ ] use mamba to resolve dependencies
- [ ] use matplotlib-base
- [ ] find the slowest tests using `py.test xarray/tests/ --durations=100`
- [ ] de-parametrize tests with a slow setup (if possible)
- [ ] reduce the number of xfails
- [ ] other ideas?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4671/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
766450436,MDU6SXNzdWU3NjY0NTA0MzY=,4690,Linux py36-bare-minimum will likely fail,10194086,closed,0,,,1,2020-12-14T13:41:56Z,2020-12-14T19:47:59Z,2020-12-14T19:47:59Z,MEMBER,,,,"The Linux py36-bare-minimum will likely fail with a `TypeError: 'NoneType' object is not callable` due to python/importlib_metadata#270
This could be fixed by adding `typing_extensions` to the CI or maybe they fix that upstream.","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4690/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
755566566,MDU6SXNzdWU3NTU1NjY1NjY=,4643,mamba does not use strict channel priority (in our CI),10194086,closed,0,,,0,2020-12-02T19:54:19Z,2020-12-05T00:30:11Z,2020-12-05T00:30:11Z,MEMBER,,,,"We use mamba in the new CI:
https://github.com/pydata/xarray/blob/7152b41fa80a56db0ce88b241fbe4092473cfcf0/.github/workflows/upstream-dev-ci.yaml#L39
I just tested it and it is awesomely fast! However, it does not enforce strict channel priority, so packages from main get mixed in (see e.g. https://github.com/pydata/xarray/runs/1487637678#step:5:112 & search for `main`) & we don't want that. So I'd suggest to do:
```bash
mamba env update --override-channels -c conda-forge -f ci/requirements/py38.yml
```
(note there is a `--strict-channel-priority` option in mamba but it still installed packages from main when I tested it)
cc @andersy005: mybe you could add this to #4604?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4643/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
714993891,MDU6SXNzdWU3MTQ5OTM4OTE=,4487,overloaded functions have several signatures in the docs,10194086,closed,0,,,5,2020-10-05T16:37:02Z,2020-11-24T14:52:09Z,2020-11-24T14:52:09Z,MEMBER,,,,"See

(http://xarray.pydata.org/en/latest/generated/xarray.concat.html)
Can this be fixed? Or do we actually want to show both?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4487/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
741115905,MDU6SXNzdWU3NDExMTU5MDU=,4574,nightly upstream test,10194086,closed,0,,,6,2020-11-11T22:31:53Z,2020-11-22T02:37:14Z,2020-11-22T02:37:14Z,MEMBER,,,,"As discussed in the call today it would be nice to remove the upstream test from our ci and setup a ""nightly"" job to test against the development versions of pandas etc. This should lead to less failures unrelated to specific PRs. Question: how are we going to see that the upstream build failed? Having the failure in random PRs is not clean but very visible...
This could be done via github actions. See xpublish for an example setup: https://github.com/xarray-contrib/xpublish/tree/master/.github/workflows
xref #4313","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4574/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
723181209,MDU6SXNzdWU3MjMxODEyMDk=,4516,py38-upstream-dev failure: 'CFTimeIndex' object has no attribute '_id',10194086,closed,0,,,6,2020-10-16T12:39:01Z,2020-10-23T01:08:50Z,2020-10-23T01:08:50Z,MEMBER,,,,"Now that #4502 was fixed upstream we get a new issue in `py38-upstream-dev` (which I am pretty sure is unrelated as dask is not involved). `xarray/tests/test_cftimeindex_resample.py::test_resample` fails with:
```python-traceback
AttributeError: 'CFTimeIndex' object has no attribute '_id'
```
See: https://dev.azure.com/xarray/xarray/_build/results?buildId=4038&view=logs&jobId=603f3fdc-8af6-5e0a-f594-fa71bc949352&j=603f3fdc-8af6-5e0a-f594-fa71bc949352&t=51624cf6-228d-5319-1d6f-8cd30bcca2e7
The failure did not happen on the 14. Oct. (https://github.com/pydata/xarray/commit/db4f03e467d13229512f8f7924dc142db1b9486b the failures here are #4502) but it appeared on the 15. Oct. (https://github.com/pydata/xarray/commit/15537497136345ed67e9e8b089bcd4573df0b2ea)
Maybe a change in pandas? I have not looked at it closely - maybe @spencerkclark sees what's going on?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4516/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
724020766,MDU6SXNzdWU3MjQwMjA3NjY=,4521,cfgrib does not work with newest eccodes version,10194086,closed,0,,,0,2020-10-18T14:35:37Z,2020-10-19T22:21:13Z,2020-10-19T22:21:13Z,MEMBER,,,,"See ecmwf/cfgrib#167. This causes our doc build to fail (#4520). The tests do not fail because `import cfgrib` issues a `ModuleNotFoundError` therfore `@requires_cfgrib` skips the test...
todo
- [ ] unpin docs again
- [ ] it's probably quite a corner case but - should the tests fail? How would this be achieved...?","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4521/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
721833440,MDU6SXNzdWU3MjE4MzM0NDA=,4509,test_dataarray.py not run in py38-all-but-dask,10194086,closed,0,,,2,2020-10-14T22:25:00Z,2020-10-18T15:30:59Z,2020-10-18T15:30:59Z,MEMBER,,,,"The `DataArray` tests are skipped in `py38-all-but-dask` - I have no idea why...
See
https://dev.azure.com/xarray/xarray/_build/results?buildId=4028&view=logs&j=15c5a299-0936-5372-ef76-f6800a28dcef&t=b8653be4-abae-5992-d733-6af037900ab6&l=108
`test_dataarray.py` should be just before `test_dataset.py`","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4509/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
718869334,MDU6SXNzdWU3MTg4NjkzMzQ=,4502,dask dev upstream test failiures,10194086,closed,0,,,1,2020-10-11T16:12:13Z,2020-10-16T12:17:58Z,2020-10-16T12:17:57Z,MEMBER,,,,"Our upstream tests fail due to a change in dask. The likely culprit is dask/dask#6680 - `dask.array.zeros_like` does now take the `meta` keyword and thus it tries to coerce `str` to a `bool` which fails (and it didn't do before). The following should trigger the error:
```python
import xarray as xr
import dask
da = xr.DataArray(dask.array.array(""""))
xr.zeros_like(da, dtype=bool)
```
Note that `zeros_like` is called in `isnull` (which triggered the test failures):
https://github.com/pydata/xarray/blob/080caf4246fe2f4d6aa0c5dcb65a99b376fa669b/xarray/core/duck_array_ops.py#L100-L102
**What happened**:
```python
/home/vsts/work/1/s/xarray/tests/test_duck_array_ops.py:499:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/vsts/work/1/s/xarray/testing.py:139: in compat_variable
return a.dims == b.dims and (a._data is b._data or equiv(a.data, b.data))
/home/vsts/work/1/s/xarray/testing.py:36: in _data_allclose_or_equiv
return duck_array_ops.array_equiv(arr1, arr2)
/home/vsts/work/1/s/xarray/core/duck_array_ops.py:246: in array_equiv
flag_array = (arr1 == arr2) | (isnull(arr1) & isnull(arr2))
/home/vsts/work/1/s/xarray/core/duck_array_ops.py:104: in isnull
return zeros_like(data, dtype=bool)
/home/vsts/work/1/s/xarray/core/duck_array_ops.py:56: in f
return wrapped(*args, **kwargs)
/usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/dask/array/creation.py:174: in zeros_like
return zeros(
/usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/dask/array/wrap.py:78: in wrap_func_shape_as_first_arg
return Array(dsk, name, chunks, dtype=dtype, meta=kwargs.get(""meta"", None))
/usr/share/miniconda/envs/xarray-tests/lib/python3.8/site-packages/dask/array/core.py:1083: in __new__
meta = meta_from_array(meta, dtype=dtype)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
x = array('', dtype=' meta = meta.astype(dtype)
E ValueError: invalid literal for int() with base 10: ''
```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4502/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
532878771,MDU6SXNzdWU1MzI4Nzg3NzE=,3595,xr.Dataset.map drops attrs of DataArray,10194086,closed,0,,,6,2019-12-04T19:11:35Z,2020-10-14T16:29:52Z,2020-10-14T16:29:52Z,MEMBER,,,,"#### MCVE Code Sample
```python
import xarray as xr
import numpy as np
ds = xr.DataArray([1, 2], attrs=dict(tst=""DataArray"")).to_dataset(name=""data"")
ds.attrs[""tst""] = ""Dataset""
ds.map(np.mean, keep_attrs=True).data
```
returns
```python
array(1.5)
```
#### Expected Output
```python
array(1.5)
Attributes:
tst: DataArray
```
#### Problem Description
Applying `xr.Dataset.map(..., keep_attrs=True)` does not retain the attributes of the DataArrays. Should it?
In constrast `ds.mean(keep_attrs=True)` retains DataArray-level attrs.
EDIT: corrected example
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: bd4f048bdb5a5a356a5603904d96a676037d1b6e
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.32-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.6.2
xarray: 0.14.0+117.gbd4f048b.dirty
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.1.2
pydap: installed
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: 1.5.5
zarr: 2.3.2
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: installed
rasterio: 1.1.0
cfgrib: 0.9.7.2
iris: 2.2.0
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: installed
setuptools: 41.6.0.post20191029
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3595/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
679445858,MDU6SXNzdWU2Nzk0NDU4NTg=,4342, unpin matplotlib in ci/requirements/doc.yml again,10194086,closed,0,,,0,2020-08-14T23:15:23Z,2020-10-06T14:43:50Z,2020-10-06T14:43:50Z,MEMBER,,,,"Matplotlib 3.3.1 broke the doc build so I pinned it to 3.3.0 - see #4340
The likely culprit is https://github.com/matplotlib/matplotlib/issues/18254 - thanks @jthielen for finding the matplotlib issue","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4342/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
681627420,MDU6SXNzdWU2ODE2Mjc0MjA=,4352,da.sum(min_count=1) errors for integer data,10194086,closed,0,,,1,2020-08-19T07:52:35Z,2020-10-02T09:28:27Z,2020-10-02T09:28:27Z,MEMBER,,,,"
**What happened**:
`da.sum(min_count=1)` returns a `TypeError` if `da` has an integer dtype. Of course min_count is not necessary for integer data as it cannot contain `NaN`.
**What you expected to happen**:
`min_count` should be ignored
**Minimal Complete Verifiable Example**:
```python
import xarray as xr
da = xr.DataArray([[1, 2, 3], [4, 5, 6]])
da.sum(min_count=1)
```
**Anything else we need to know?**:
Full traceback
```python
In [37]: da.sum(min_count=1)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
----> 1 da.sum(min_count=1)
~/code/xarray/xarray/core/common.py in wrapped_func(self, dim, axis, skipna, **kwargs)
44
45 def wrapped_func(self, dim=None, axis=None, skipna=None, **kwargs):
---> 46 return self.reduce(func, dim, axis, skipna=skipna, **kwargs)
47
48 else:
~/code/xarray/xarray/core/dataarray.py in reduce(self, func, dim, axis, keep_attrs, keepdims, **kwargs)
2336 """"""
2337
-> 2338 var = self.variable.reduce(func, dim, axis, keep_attrs, keepdims, **kwargs)
2339 return self._replace_maybe_drop_dims(var)
2340
~/code/xarray/xarray/core/variable.py in reduce(self, func, dim, axis, keep_attrs, keepdims, allow_lazy, **kwargs)
1591 data = func(input_data, axis=axis, **kwargs)
1592 else:
-> 1593 data = func(input_data, **kwargs)
1594
1595 if getattr(data, ""shape"", ()) == self.shape:
~/code/xarray/xarray/core/duck_array_ops.py in f(values, axis, skipna, **kwargs)
310
311 try:
--> 312 return func(values, axis=axis, **kwargs)
313 except AttributeError:
314 if not isinstance(values, dask_array_type):
~/code/xarray/xarray/core/duck_array_ops.py in f(*args, **kwargs)
46 else:
47 wrapped = getattr(eager_module, name)
---> 48 return wrapped(*args, **kwargs)
49
50 else:
<__array_function__ internals> in sum(*args, **kwargs)
TypeError: _sum_dispatcher() got an unexpected keyword argument 'min_count'
```
**Environment**:
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: a7fb5a9fa1a2b829181ea9e4986b959f315350dd
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.4.0-42-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.15.2.dev64+g2542a63f
pandas: 0.25.3
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.4
pydap: installed
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: 2.3.2
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: installed
rasterio: 1.1.0
cfgrib: 0.9.5.4
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.3.1
cartopy: 0.18.0
seaborn: 0.9.0
numbagg: None
pint: None
setuptools: 49.6.0.post20200814
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.17.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4352/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
688115687,MDU6SXNzdWU2ODgxMTU2ODc=,4385,warnings from internal use of apply_ufunc,10194086,closed,0,,,4,2020-08-28T14:28:56Z,2020-08-30T16:37:52Z,2020-08-30T16:37:52Z,MEMBER,,,,"Another follow up from #4060: `quantile` now emits a `FutureWarning`:
**Minimal Complete Verifiable Example**:
```python
xr.DataArray([1, 2, 3]).quantile(q=0.5)
```
```
~/.conda/envs/ipcc_ar6/lib/python3.7/site-packages/xarray/core/variable.py:1866:
FutureWarning: ``output_sizes`` should be given in the ``dask_gufunc_kwargs``
parameter. It will be removed as direct parameter in a future version.
kwargs={""q"": q, ""axis"": axis, ""interpolation"": interpolation},
```
We should probably check the warnings in the test suite - there may be others.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4385/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
587735698,MDU6SXNzdWU1ODc3MzU2OTg=,3890,error for apply_ufunc with exclude_dims and vectorize,10194086,closed,0,,,2,2020-03-25T14:26:36Z,2020-08-24T13:37:49Z,2020-08-24T13:37:49Z,MEMBER,,,,"I tried to use `apply_ufunc` for a function that takes input of unequal length and requires `vectorize=True` which resulted in a `ValueError`. I think the problem stems from the way `np.vectorize` is called.
#### MCVE Code Sample
```python
import xarray as xr
import scipy as sp
import scipy.stats
import numpy as np
# create dataarrays of unequal length
ds = xr.tutorial.open_dataset(""air_temperature"")
da1 = ds.air
da2 = ds.air.isel(time=slice(None, 50))
# function that takes arguments of unequal length and requires vectorizing
def mannwhitneyu(x, y):
_, p = sp.stats.mannwhitneyu(x, y)
return p
# test that the function takes arguments of unequal length
mannwhitneyu(da1.isel(lat=0, lon=0), da2.isel(lat=0, lon=0))
xr.apply_ufunc(
mannwhitneyu,
da1,
da2,
input_core_dims=[[""time""], [""time""]],
exclude_dims=set([""time""]),
vectorize=True,
)
```
Returns
```python
ValueError: inconsistent size for core dimension 'n': 50 vs 2920
```
Note: the error stems from numpy.
#### Expected Output
A DataArray.
#### Problem Description
I can reproduce the problem in pure numpy:
``` python
vec_wrong = np.vectorize(mannwhitneyu, signature=""(n),(n)->()"", otypes=[np.float])
vec_wrong(da1.values.T, da2.values.T)
```
The correct result is returned when the `signature` is changed:
``` python
vec_correct = np.vectorize(mannwhitneyu, signature=""(m),(n)->()"", otypes=[np.float])
vec_correct(da1.values.T, da2.values.T)
```
So I think the signature needs to be changed when `exclude_dims` are present.
#### Versions
Output of `xr.show_versions()`
This is my development environment, so i think xarray should be 'master'.
**PNC:/home/mathause/conda/envs/xarray_devel/lib/python3.7/site-packages/PseudoNetCDF/pncwarn.py:24:UserWarning:
pyproj could not be found, so IO/API coordinates cannot be converted to lat/lon; to fix, install pyproj or basemap (e.g., `pip install pyproj)`
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.15.0-91-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.1
xarray: 0.11.1+335.gb0c336f6
pandas: 0.25.3
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.3
pydap: installed
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: 2.3.2
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: installed
rasterio: 1.1.0
cfgrib: 0.9.5.4
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.2
cartopy: None
seaborn: 0.9.0
numbagg: None
setuptools: 41.6.0.post20191101
pip: 19.3.1
conda: installed
pytest: 5.2.2
IPython: 7.9.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3890/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
681904962,MDU6SXNzdWU2ODE5MDQ5NjI=,4354,sum: min_count is not available for reduction with more than one dimensions,10194086,closed,0,,,0,2020-08-19T14:52:41Z,2020-08-20T16:22:55Z,2020-08-20T16:22:55Z,MEMBER,,,,"**Is your feature request related to a problem? Please describe.**
`sum` with `min_count` errors when passing more than one dim:
```python
import xarray as xr
da = xr.DataArray([[1., 2, 3], [4, 5, 6]])
da.sum([""dim_0"", ""dim_1""], min_count=1)
```
**Describe the solution you'd like**
The logic to calculate the number of valid elements is here:
https://github.com/pydata/xarray/blob/1be777fe725a85b8cc0f65a2bc41f4bc2ba18043/xarray/core/nanops.py#L35
I *think* this can be fixed by replacing
`mask.shape[axis]` with `np.take(a.shape, axis).prod()`
**Additional context**
Potentially relevant for #4351
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4354/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
592629388,MDU6SXNzdWU1OTI2MjkzODg=,3927,use level of a MultiIndex for plotting?,10194086,closed,0,,,1,2020-04-02T13:24:05Z,2020-05-25T16:32:15Z,2020-05-25T16:32:15Z,MEMBER,,,,"It would be nice to be able to use a level of a MultiIndex for plotting.
#### MCVE Code Sample
```python
import numpy as np
import xarray as xr
da = xr.DataArray(
np.random.randn(10),
dims=""x"",
coords=dict(
a=(""x"", np.arange(10, 20)),
b=(""x"", np.arange(1, 11))
)
)
da = da.set_index(x=[""a"", ""b""])
da
```
This creates the following DataArray
```python
array([-1.34516338, 0.97644817, -0.24032189, -0.70112418, -0.8686898 ,
-0.55607078, 0.56618151, 1.62847463, 0.84947296, -0.5775504 ])
Coordinates:
* x (x) MultiIndex
- a (x) int64 10 11 12 13 14 15 16 17 18 19
- b (x) int64 1 2 3 4 5 6 7 8 9 10
```
Is there a way to plot a line using one of the levels of the MultiIindex?
```python
da.plot(x=""a"")
```
returns
```python
ValueError: x must be either None or one of ('x')
```
```python
da.plot()
```
returns
```python
TypeError: Plotting requires coordinates to be numeric or
dates of type np.datetime64, datetime.datetime, cftime.datetime
or pd.Interval.
```
(which makes sense). If `da` is a 2D Variable the error is
```python
ValueError: x and y must be coordinate variables
```
#### Expected Output
A line plot
#### Versions
Output of `xr.show_versions()`
INSTALLED VERSIONS
------------------
commit: b3bafeefbd6e6d70bce505ae1f0d9d5a2b015089
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.15.0-91-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.1
xarray: 0.11.1+335.gb0c336f6
pandas: 0.25.3
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.3
pydap: installed
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: 2.3.2
cftime: 1.0.4.2
nc_time_axis: None
PseudoNetCDF: installed
rasterio: 1.1.0
cfgrib: 0.9.5.4
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.2
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
pint: None
setuptools: 41.6.0.post20191101
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3927/reactions"", ""total_count"": 1, ""+1"": 1, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
620351521,MDU6SXNzdWU2MjAzNTE1MjE=,4074,[bug] when passing boolean weights to weighted mean,10194086,closed,0,,,0,2020-05-18T16:38:18Z,2020-05-23T21:06:19Z,2020-05-23T21:06:19Z,MEMBER,,,,"
#### MCVE Code Sample
```python
import numpy as np
import xarray as xr
dta = xr.DataArray([1., 1., 1.])
wgt = xr.DataArray(np.array([1, 1, 0], dtype=np.bool))
dta.weighted(wgt).mean()
```
Returns
```
array(2.)
```
#### Expected Output
```
array(1.)
```
#### Problem Description
Passing a boolean array as weights to the weighted mean returns the wrong result because the `weights` are not properly normalized (in this case). Internally the `sum_of_weights` is calculated as
```python
xr.dot(dta.notnull(), wgt)
```
i.e. the dot product of two boolean arrays. This yields:
```
array(True)
```
We'll need to convert it to int or float:
```python
xr.dot(dta.notnull(), wgt * 1)
```
which is correct
```
array(2)
```
#### Versions
Output of xr.show_versions()
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.6 | packaged by conda-forge | (default, Mar 23 2020, 23:03:20)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 5.3.0-51-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.6
libnetcdf: 4.7.4
xarray: 0.15.1
pandas: 1.0.3
numpy: 1.18.1
scipy: 1.4.1
netCDF4: 1.5.3
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: 1.1.1.2
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.1.3
cfgrib: None
iris: None
bottleneck: None
dask: 2.16.0
distributed: 2.16.0
matplotlib: 3.2.1
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 46.1.3.post20200325
pip: 20.1
conda: None
pytest: 5.4.1
IPython: 7.13.0
sphinx: 3.0.3
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/4074/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
559864146,MDU6SXNzdWU1NTk4NjQxNDY=,3750,isort pre-commit hook does not skip text files,10194086,closed,0,,,4,2020-02-04T17:18:31Z,2020-05-06T01:50:29Z,2020-03-28T20:58:15Z,MEMBER,,,,"#### MCVE Code Sample
Add arbitrary change to the file `doc/pandas.rst`
``` bash
git add doc/pandas.rst
git commit -m ""test""
```
The pre-commit hook will fail.
#### Expected Output
the pre-commit hook to pass
#### Problem Description
running `isort -rc doc/*` will change the following files:
``` bash
modified: contributing.rst
modified: howdoi.rst
modified: internals.rst
modified: io.rst
modified: pandas.rst
modified: quick-overview.rst
```
unfortunately it does not behave properly and deletes/ changes arbitrary lines. Can the pre-commit hook be told to only run on *.py files? On the command line this would be `isort -rc *.py`
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3750/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
522457033,MDU6SXNzdWU1MjI0NTcwMzM=,3524,xr.plot infers sequential colormap on diverging levels,10194086,closed,0,,,2,2019-11-13T20:32:46Z,2020-04-05T13:41:25Z,2020-04-05T13:41:25Z,MEMBER,,,,"#### MCVE Code Sample
```python
import numpy as np
import xarray as xr
data = np.random.randn(10, 10)
data = np.abs(data)
da = xr.DataArray(data)
# returns a diverging colormap
da.plot(vmax=2, center=0, extend=""both"")
# returns a sequential colormap
da.plot(levels=[-2, -1, 0, 1, 2], extend=""both"")
```

#### Expected Output
A diverging colormap, maybe?
#### Problem Description
I was surprised by getting the viridis colormap until I realised that my data must all be positive and the colormap is infered from the data and not from levels. However, when specifying the range via `vmax=2, center=0` it is not inferred from the data.
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.25-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.14.0+44.g4dce93f1
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.0.1
pydap: None
h5netcdf: 0.7.4
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: 1.0.22
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
setuptools: 41.4.0
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: 2.2.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3524/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
308030789,MDU6SXNzdWUzMDgwMzA3ODk=,2010,rolling.mean vs rolling.construct.mean,10194086,closed,0,,,8,2018-03-23T13:34:05Z,2020-03-26T02:02:59Z,2020-03-26T02:02:59Z,MEMBER,,,,"#### Code Sample, a copy-pastable example if possible
```python
import xarray as xr
import numpy as np
x = np.arange(4.)
ds = xr.DataArray(x, dims=('dim', ))
ds.rolling(dim=3, center=True).mean()
# RESULT: array([nan, 1., 2., nan])
ds.rolling(dim=3, center=True).construct('window').mean('window')
# RESULT: array([0.5, 1. , 2. , 2.5])
```
#### Problem description
`ds.rolling(...).mean()` and `ds.rolling(...).construct().mean()` yields different results. Because `mean` does `skipna=True` per default.
#### Expected Output
I would expect both ways to yield the same result.
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.114-42-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
xarray: 0.10.2+dev6.g9261601
pandas: 0.22.0
numpy: 1.14.2
scipy: 1.0.0
netCDF4: 1.3.1
h5netcdf: None
h5py: None
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: 1.0.0
dask: 0.17.1
distributed: 1.21.3
matplotlib: 2.2.2
cartopy: None
seaborn: None
setuptools: 39.0.1
pip: 9.0.2
conda: None
pytest: 3.4.2
IPython: 6.2.1
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2010/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
180641734,MDU6SXNzdWUxODA2NDE3MzQ=,1029,`flatten` as convinience method for stack all?,10194086,closed,0,,,6,2016-10-03T13:35:28Z,2020-03-25T08:31:18Z,2020-03-25T08:31:18Z,MEMBER,,,,"There is a bunch of operations that need to be conducted on a 1D array. It could be handy to have a convinience method that mimicks numpys `flatten`, i.e. works along the lines:
```
def flatten(dataarray, name='stacked'):
return dataarray.stack(**{name: dataarray.dims})
```
What do you think?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1029/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
84127296,MDU6SXNzdWU4NDEyNzI5Ng==,422,add average function,10194086,closed,0,,,23,2015-06-02T17:53:53Z,2020-03-19T14:29:42Z,2020-03-19T14:29:42Z,MEMBER,,,,"It would be nice to be able to do `ds.average()` to compute weighted averages (e.g. for geo data). Of course this would require the axes to be in a predictable order. Or to give a weight per dimension...
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/422/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
559794979,MDU6SXNzdWU1NTk3OTQ5Nzk=,3747,The seaborn.apionly entry-point has been removed.,10194086,closed,0,,,2,2020-02-04T15:28:57Z,2020-02-05T16:03:52Z,2020-02-05T16:03:52Z,MEMBER,,,,"Seaborn [recently dropped](https://github.com/mwaskom/seaborn/releases) the `apionly` entry point (in version 0.10.0).
There is a dedicated `import_seaborn` function
https://github.com/pydata/xarray/blob/47a6fc0c9b796997996d79d32358585d08021b9c/xarray/plot/utils.py#L24
but it is not used in one place
https://github.com/pydata/xarray/blob/47a6fc0c9b796997996d79d32358585d08021b9c/xarray/plot/utils.py#L146
which now causes test failures
https://dev.azure.com/xarray/xarray/_build/results?buildId=2111&view=ms.vss-test-web.build-test-results-tab&runId=29632&paneView=debug&resultId=108176
Todo: double check if the supported versions of seaborn still require this workaround.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3747/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
549679475,MDU6SXNzdWU1NDk2Nzk0NzU=,3694,"xr.dot requires equal indexes (join=""exact"")",10194086,closed,0,,,5,2020-01-14T16:28:15Z,2020-01-20T12:09:27Z,2020-01-20T12:09:27Z,MEMBER,,,,"#### MCVE Code Sample
```python
import xarray as xr
import numpy as np
d1 = xr.DataArray(np.arange(4), dims=[""a""], coords=dict(a=[0, 1, 2, 3]))
d2 = xr.DataArray(np.arange(4), dims=[""a""], coords=dict(a=[0, 1, 2, 3]))
# note: different coords
d3 = xr.DataArray(np.arange(4), dims=[""a""], coords=dict(a=[1, 2, 3, 4]))
(d1 * d2).sum() # -> array(14)
xr.dot(d1, d2) # -> array(14)
(d2 * d3).sum() # -> array(8)
xr.dot(d2, d3) # -> ValueError
```
#### Expected Output
```python
array(8)
```
#### Problem Description
The last statement results in an
```python
ValueError: indexes along dimension 'a' are not equal
```
because `xr.apply_ufunc` defaults to `join='exact'`. However, I think this should work -
but maybe there is a good reason for this to fail?
This is a problem for #2922 (weighted operations) - I think it is fine for the weights and data to not align.
Fixing this may be as easy as specifying `join='inner'` in
https://github.com/pydata/xarray/blob/e0fd48052dbda34ee35d2491e4fe856495c9621b/xarray/core/computation.py#L1181-L1187
@fujiisoup
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: 5afc6f32b18f5dbb9a89e30f156b626b0a83597d
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.36-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.6.2
xarray: 0.14.0+164.g5afc6f32.dirty
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.1.2
pydap: installed
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: 1.5.5
zarr: 2.3.2
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: installed
rasterio: 1.1.0
cfgrib: 0.9.7.2
iris: 2.2.0
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: installed
setuptools: 41.6.0.post20191029
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3694/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
545764524,MDU6SXNzdWU1NDU3NjQ1MjQ=,3665,Cannot roundtrip time in NETCDF4_CLASSIC,10194086,closed,0,,,4,2020-01-06T14:47:48Z,2020-01-16T18:27:15Z,2020-01-16T18:27:14Z,MEMBER,,,,"#### MCVE Code Sample
``` python
import numpy as np
import xarray as xr
time = xr.cftime_range(""2006-01-01"", periods=2, calendar=""360_day"")
da = xr.DataArray(time, dims=[""time""])
da.encoding[""dtype""] = np.float
da.to_netcdf(""tst.nc"", format=""NETCDF4_CLASSIC"")
ds = xr.open_dataset(""tst.nc"")
ds.to_netcdf(""tst2.nc"", format=""NETCDF4_CLASSIC"")
```
yields:
```python
ValueError: could not safely cast array from dtype int64 to int32
```
Or an example without `to_netcdf`:
```python
import numpy as np
import xarray as xr
time = xr.cftime_range(""2006-01-01"", periods=2, calendar=""360_day"")
da = xr.DataArray(time, dims=[""time""])
da.encoding[""_FillValue""] = np.array([np.nan])
xr.backends.netcdf3.encode_nc3_variable(xr.conventions.encode_cf_variable(da))
```
#### Expected Output
Xarray can save the dataset/ an `xr.Variable`.
#### Problem Description
If there is a time variable that can be encoded using integers only, but that has a `_FillValue` set to `NaN`, saving `to_netcdf(name, format=""NETCDF4_CLASSIC"")` fails. The problem is that xarray adds a (unnecessary) `_FillValue` when saving a file.
Note: if the time cannot be encoded using integers only, it works:
``` python
da = xr.DataArray(time, dims=[""time""])
da.encoding[""_FillValue""] = np.array([np.nan])
da.encoding[""units""] = ""days since 2006-01-01T12:00:00""
xr.backends.netcdf3.encode_nc3_variable(xr.conventions.encode_cf_variable(da))
```
Another note: when saving with NETCDF4
``` python
da = xr.DataArray(time, dims=[""time""])
da.encoding[""_FillValue""] = np.array([np.nan])
xr.backends.netCDF4_._encode_nc4_variable(xr.conventions.encode_cf_variable(da))
```
The following is returned:
```
array([0, 1])
Attributes:
units: days since 2006-01-01 00:00:00.000000
calendar: proleptic_gregorian
_FillValue: [-9223372036854775808]
```
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.36-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.1
xarray: 0.14.1
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: 1.1.1
cfgrib: None
iris: None
bottleneck: 1.3.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.2
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
setuptools: 41.4.0
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: 2.2.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3665/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
539010474,MDU6SXNzdWU1MzkwMTA0NzQ=,3634,"""ValueError: Percentiles must be in the range [0, 100]""",10194086,closed,0,,,1,2019-12-17T11:34:35Z,2019-12-17T13:50:06Z,2019-12-17T13:50:06Z,MEMBER,,,,"#### MCVE Code Sample
```python
import xarray as xr
da = xr.DataArray([0, 1, 2])
da.quantile(q=50)
>>> ValueError: Percentiles must be in the range [0, 100]
```
#### Expected Output
```python
ValueError: Quantiles must be in the range [0, 1]
```
#### Problem Description
By wrapping `np.nanpercentile` (xref: #3559) we also get the numpy error. However, the error message is wrong as xarray needs it to be in 0..1.
BTW: thanks for #3559, makes my life easier!
#### Output of ``xr.show_versions()``
---
Edit: uses `nanpercentile` internally.
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.36-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.5
libnetcdf: 4.7.1
xarray: 0.14.1+28.gf2b2f9f6 (current master)
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.3
pydap: None
h5netcdf: 0.7.4
h5py: 2.10.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: 1.1.1
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.2
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
setuptools: 41.4.0
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: 2.2.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3634/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
523037716,MDU6SXNzdWU1MjMwMzc3MTY=,3535,subtracting CFTimeIndex can cause pd.TimedeltaIndex to overflow,10194086,closed,0,,,2,2019-11-14T18:45:03Z,2019-12-07T20:38:00Z,2019-12-07T20:38:00Z,MEMBER,,,,"#### MCVE Code Sample
```python
import xarray as xr
i1 = xr.cftime_range(""4991-01-01"", periods=1)
i2 = xr.cftime_range(""7190-12-31"", periods=1)
i2 - i1
```
#### Expected Output
a timedelta
#### Problem Description
returns `OverflowError: Python int too large to convert to C long`. Originally I stumbled upon this when trying to `open_mfdataset` files from a long simulation (piControl). I did not figure out yet where this subtraction happens in `open_mfdataset`. (Opening the single files and using `xr.concat` works).
The offending lines are here
https://github.com/pydata/xarray/blob/40588dc38ddc2d573e3dc8c63b2e6533eb978656/xarray/coding/cftimeindex.py#L433
Ultimately this is probably a pandas problem as it tries to convert `datetime.timedelta(days=803532)` to `'
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 21:52:21)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.25-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.14.0+44.g4dce93f1
pandas: 0.25.2
numpy: 1.17.3
scipy: 1.3.1
netCDF4: 1.5.0.1
pydap: None
h5netcdf: 0.7.4
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.4.2
nc_time_axis: 1.2.0
PseudoNetCDF: None
rasterio: 1.0.22
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 2.6.0
distributed: 2.6.0
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
setuptools: 41.4.0
pip: 19.3.1
conda: None
pytest: 5.2.2
IPython: 7.9.0
sphinx: 2.2.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3535/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
509851476,MDU6SXNzdWU1MDk4NTE0NzY=,3423,add `ALL_DIMS` in `xr.dot`,10194086,closed,0,,,0,2019-10-21T09:45:24Z,2019-10-29T19:12:51Z,2019-10-29T19:12:51Z,MEMBER,,,,"#### MCVE Code Sample
```python
import numpy as np
import xarray as xr
da_a = xr.DataArray(np.arange(3 * 2).reshape(3, 2), dims=['a', 'b'])
da_b = xr.DataArray(np.arange(3 * 2 * 2).reshape(3, 2, 2), dims=['a', 'b', 'c'])
xr.dot(da_a, da_b, dims=None)
```
This sums over the common dimensions:
```python
array([110, 125])
Dimensions without coordinates: c
```
To sum over all dimensions:
```python
xr.dot(da_a, da_b, dims=['a', 'b', 'c'])
```
```python
array([110, 125])
Dimensions without coordinates: c
```
#### Problem Description
`xr.dot` with `dims=None` currently sums over `all the common dimensions`. However, there are cases when a sum over all dimensions is desired. E.g. `xr.dot(da_a, da_b, dims=['a', 'b', 'c'])
` is a a memory efficient way to compute `(da_a * da_b).sum()` (if `a` and `b` don't share the same dimensions). This is currently used in #2922 ([example](https://github.com/pydata/xarray/blob/dc7f6057c1a2533569ff6b5995d9a3c3e4c1fd85/xarray/core/weighted.py#L159)).
Therefore I suggest to allow `xr.dot(da_a, da_b, dims=xr.ALL_DIMS)` as shortcut to sum over all dimensions.
I assume there is no intent to change the behavior of `xr.dot(..., dims=None)`? (As it is a bit in contrast to other functions that are mostly applied over all dimensions.)
@fujiisoup @max-sixty
#### Output of ``xr.show_versions()``
# Paste the output here xr.show_versions() here
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3423/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
490229690,MDU6SXNzdWU0OTAyMjk2OTA=,3284,specifying list of colors does not work for me,10194086,closed,0,,,1,2019-09-06T09:36:08Z,2019-09-09T18:31:16Z,2019-09-09T18:31:16Z,MEMBER,,,,"#### MCVE Code Sample
```python
import xarray as xr
import numpy as np
airtemps = xr.tutorial.load_dataset('air_temperature')
air = airtemps.air.isel(time=0)
levels = np.arange(225, 301, 25)
colors = ['#ffffb2', '#fecc5c', '#fd8d3c', '#e31a1c']
# this does not work for me
air.plot.pcolormesh(levels=levels, colors=colors)
```
#### Expected Output
Should create a plot with the specified colors. According to the the docstring this should work. Or maybe I am doing something wrong here?
#### Problem Description
Instead I get the following error:
```python
/usr/local/Miniconda3-envs/envs/2019/envs/iacpy3_2019/lib/python3.7/site-packages/xarray/plot/utils.py in _process_cmap_cbar_kwargs(func, kwargs, data)
683 # colors is only valid when levels is supplied or the plot is of type
684 # contour or contourf
--> 685 if colors and (('contour' not in func.__name__) and (not levels)):
686 raise ValueError(""Can only specify colors with contour or levels"")
687
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
```
Instead I use the following, which works:
```python
air.plot.pcolormesh(levels=levels, cmap=colors)
```
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.1 | packaged by conda-forge | (default, Feb 18 2019, 01:42:00)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.12.14-lp151.28.13-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_US.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.12.1
pandas: 0.24.2
numpy: 1.16.2
scipy: 1.2.1
netCDF4: 1.5.0.1
pydap: installed
h5netcdf: 0.7.1
h5py: 2.9.0
Nio: None
zarr: 2.3.1
cftime: 1.0.3.4
nc_time_axis: 1.2.0
PseudonetCDF: None
rasterio: 1.0.22
cfgrib: 0.9.7
iris: 2.2.0
bottleneck: 1.2.1
dask: 1.1.5
distributed: 1.26.1
matplotlib: 3.0.3
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 41.0.0
pip: 19.0.3
conda: None
pytest: 4.4.0
IPython: 7.4.0
sphinx: 2.0.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3284/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
441341354,MDU6SXNzdWU0NDEzNDEzNTQ=,2948,xr.merge fails when passing dict,10194086,closed,0,,,5,2019-05-07T17:06:07Z,2019-06-12T15:33:26Z,2019-06-12T15:33:26Z,MEMBER,,,,"#### Code Sample
```python
import xarray as xr
a = xr.DataArray([1, 2], dims=('foo', ), name='a')
b = xr.DataArray([3], dims=('bar', ), name='b')
objects = dict(a=a, b=b)
xr.merge(objects)
```
#### Problem description
This returns an `AttributeError`, while the documentation states that a dict is a valid input.
``` python
def merge(objects, compat='no_conflicts', join='outer'):
""""""Merge any number of xarray objects into a single Dataset as variables.
Parameters
----------
objects : Iterable[Union[xarray.Dataset, xarray.DataArray, dict]]
Merge together all variables from these objects. If any of them are
DataArray objects, they must have a name.
...
```
#### Expected Output
Either the docs or the `dict_like_objects` loop should be changed.
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.1 | packaged by conda-forge | (default, Feb 18 2019, 01:42:00)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.4.138-59-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.12.1
pandas: 0.24.2
numpy: 1.16.2
scipy: 1.2.1
netCDF4: 1.5.0.1
pydap: None
h5netcdf: 0.7.1
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: 1.2.0
PseudonetCDF: None
rasterio: 1.0.22
cfgrib: 0.9.6.2
iris: 2.2.0
bottleneck: 1.2.1
dask: 1.1.5
distributed: 1.26.1
matplotlib: 3.0.3
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 41.0.0
pip: 19.0.3
conda: None
pytest: 4.4.0
IPython: 7.4.0
sphinx: 2.0.1
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2948/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
407864596,MDU6SXNzdWU0MDc4NjQ1OTY=,2754,silence warning for decode_cf_datetime?,10194086,closed,0,,,7,2019-02-07T19:38:38Z,2019-02-19T20:47:26Z,2019-02-19T20:47:26Z,MEMBER,,,,"#### Code Sample, a copy-pastable example if possible
```python
import xarray as xr
import numpy as np
x = np.arange(100) * 365
x = xr.coding.times.decode_cf_datetime(x, 'days since 2400-01-01',
calendar='proleptic_gregorian')
```
#### Problem description
xarray still throws an error when decoding out-of-bounds dates for proleptic_gregorian - should this be silenced?
#### Output of ``xr.show_versions()``
# Paste the output here xr.show_versions() here
NSTALLED VERSIONS
------------------
commit: None
python: 3.7.1 | packaged by conda-forge | (default, Nov 13 2018, 18:33:04)
[GCC 7.3.0]
python-bits: 64
OS: Linux
OS-release: 4.4.172-86-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.11.3
pandas: 0.24.1
numpy: 1.16.1
scipy: 1.2.0
netCDF4: 1.4.2
pydap: None
h5netcdf: 0.6.2
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
PseudonetCDF: None
rasterio: 1.0.17
cfgrib: None
iris: None
bottleneck: 1.2.1
cyordereddict: None
dask: 1.1.1
distributed: 1.25.3
matplotlib: 3.0.2
cartopy: 0.17.0
seaborn: 0.9.0
setuptools: 40.7.3
pip: 19.0.1
conda: None
pytest: 4.2.0
IPython: 7.2.0
sphinx: 1.8.4
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2754/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
106595746,MDU6SXNzdWUxMDY1OTU3NDY=,577,wrap lon coordinates to 360,10194086,closed,0,,,4,2015-09-15T16:36:37Z,2019-01-17T09:34:56Z,2019-01-15T20:15:01Z,MEMBER,,,,"Assume I have two datasets with the same lat/ lon grid. However, one has `lon = 0...359`and the other `lon = -180...179`. How can I wrap around one of them?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/577/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
84068169,MDU6SXNzdWU4NDA2ODE2OQ==,418,select range/ slice with method='nearest',10194086,closed,0,,,5,2015-06-02T15:17:27Z,2019-01-15T20:10:20Z,2019-01-15T20:10:19Z,MEMBER,,,,"It would be nice to support nearest neighbour selection with a slice like so: `ds.sel(lat=slice(30, 50), method='nearest')`. Maybe the `step` has to be disallowed.
Or is there another possibility how to achieve this functionality?
use case:
Often I look at a region with different data sets that don't have the same resolutions. It would be nice to be able to select the closest-matching region with an easy syntax.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/418/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
310819233,MDU6SXNzdWUzMTA4MTkyMzM=,2036,better error message for to_netcdf -> unlimited_dims,10194086,closed,0,,,4,2018-04-03T12:39:21Z,2018-05-18T14:48:32Z,2018-05-18T14:48:32Z,MEMBER,,,,"#### Code Sample, a copy-pastable example if possible
```python
# Your code here
import numpy as np
import xarray as xr
x = np.arange(10)
da = xr.Dataset(data_vars=dict(data=('dim1', x)),
coords=dict(dim1=('dim1', x), dim2=('dim2', x)))
da.to_netcdf('tst.nc', format='NETCDF4_CLASSIC', unlimited_dims='dim1')
```
#### Problem description
This creates the error `RuntimeError: NetCDF: NC_UNLIMITED size already in use`. With `format='NETCDF4'` silently creates the dimensions `d`, `i`, `m`, and `\1`.
The correct syntax is `unlimited_dims=['dim1']`.
With `format='NETCDF4_CLASSIC'` and `unlimited_dims=['dim1', 'dim2']`, still raises the not-so-helpful `NC_UNLIMITED` error.
I only tested with netCDF4 as backend.
#### Expected Output
* better error message
* work with `unlimited_dims='dim1'`
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.5.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.120-45-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
xarray: 0.10.2
pandas: 0.22.0
numpy: 1.14.2
scipy: 1.0.1
netCDF4: 1.3.1
h5netcdf: 0.5.0
h5py: 2.7.1
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: 1.0.0
dask: 0.17.2
distributed: 1.21.5
matplotlib: 2.2.2
cartopy: 0.16.0
seaborn: 0.8.1
setuptools: 39.0.1
pip: 9.0.3
conda: None
pytest: 3.5.0
IPython: 6.3.0
sphinx: 1.7.2
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2036/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
317954266,MDU6SXNzdWUzMTc5NTQyNjY=,2085,units = 'days' leads to timedelta64 for data variable,10194086,closed,0,,,5,2018-04-26T09:47:11Z,2018-04-26T16:44:25Z,2018-04-26T15:55:09Z,MEMBER,,,,"#### Code Sample
```python
import numpy as np
import xarray as xr
def test_units(units):
x = np.arange(10)
data = np.random.randn(10)
ds = xr.Dataset(data_vars=dict(data=('x', data)), coords=dict(x=('x', x)))
ds.data.attrs['units'] = units
ds.to_netcdf('tst.nc')
decoded = xr.open_dataset('tst.nc')
print(units.ljust(8), decoded.data.dtype)
ds.close()
decoded.close()
test_units('seconds')
test_units('second')
test_units('minutes')
test_units('minute')
test_units('days')
test_units('day')
test_units('months')
test_units('years')
```
#### Problem description
Returns:
```
seconds timedelta64[ns]
second float64
minutes timedelta64[ns]
minute float64
days timedelta64[ns]
day float64
months float64
years float64
```
#### Expected Output
I would expect type float for all of them. Or is this expected behaviour?
I have a dataset that reports 'consecutive dry days' and the dataset creator correctly set the units of the data to 'days', but I don't want this to be decoded (but the time axis should)....
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.126-48-default
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8
xarray: 0.10.2+dev6.g9261601
pandas: 0.22.0
numpy: 1.14.2
scipy: 1.0.1
netCDF4: 1.3.1
h5netcdf: 0.5.0
h5py: 2.7.1
Nio: None
zarr: None
bottleneck: 1.2.1
cyordereddict: 1.0.0
dask: 0.17.2
distributed: 1.21.3
matplotlib: 2.2.2
cartopy: None
seaborn: None
setuptools: 39.0.1
pip: 9.0.2
conda: None
pytest: 3.4.2
IPython: 6.2.1
sphinx: None
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2085/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
295498327,MDU6SXNzdWUyOTU0OTgzMjc=,1896,_color_palette not using full range of colors if seaborn is installed,10194086,closed,0,,,2,2018-02-08T12:43:45Z,2018-02-16T21:08:32Z,2018-02-16T21:08:32Z,MEMBER,,,,"```python
from xarray.plot.utils import import_seaborn
_color_palette('Greys', 3)
```
Returns
0.85, ...
0.58, ...
0.31, ...
if seaborn is installed, and
1.00, ...
0.58, ...
0.00, ...
otherwise
#### Problem description
the return value of `_color_palette('Greys', 3)` is different when seaborn is installed or not.
The relevant code is here:
https://github.com/pydata/xarray/blob/6aa225f5dae9cc997e232c11a63072923c8c0238/xarray/plot/utils.py#L115
https://github.com/pydata/xarray/blob/6aa225f5dae9cc997e232c11a63072923c8c0238/xarray/plot/utils.py#L143
The same logic in seaborn
https://github.com/mwaskom/seaborn/blob/0beede57152ce80ce1d4ef5d0c0f1cb61d118375/seaborn/palettes.py#L411
Intuitively I prefer the xarray solution because this uses the full range of colors which I find beneficial, however there may be a reason for this I'm not aware of.
Maybe @mwaskom will answer:
mwaskom/seaborn#1372
#### Expected Output
#### Output of ``xr.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.4.final.0
python-bits: 64
OS: Linux
OS-release: 3.13.0-141-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
xarray: 0.10.0
pandas: 0.21.0
numpy: 1.13.3
scipy: 1.0.0
netCDF4: 1.3.1
h5netcdf: 0.5.0
Nio: None
bottleneck: 1.2.1
cyordereddict: None
dask: 0.16.0
matplotlib: 2.1.1
cartopy: 0.15.1
seaborn: 0.8.1
setuptools: 38.2.4
pip: 9.0.1
conda: None
pytest: None
IPython: 6.2.1
sphinx: None
~~
edit:
sorry I pressed the button to early
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/1896/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
106581329,MDU6SXNzdWUxMDY1ODEzMjk=,576,define fill value for where,10194086,closed,0,,,4,2015-09-15T15:27:32Z,2017-08-08T17:00:30Z,2017-08-08T17:00:30Z,MEMBER,,,,"It would be nice if `where` accepts an `other` argument:
```
def where(self, cond, other=np.NaN):
pass
```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/576/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
105442957,MDU6SXNzdWUxMDU0NDI5NTc=,561,calculate percentiles,10194086,closed,0,,,3,2015-09-08T18:28:12Z,2017-01-23T18:22:14Z,2017-01-23T18:22:14Z,MEMBER,,,,"How would I calculate percentiles over a certain dimension?
```
ds.groupby('time.month').apply(np.percentile, q=5)
```
Does not work.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/561/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
144575316,MDU6SXNzdWUxNDQ1NzUzMTY=,808,bottleneck version,10194086,closed,0,,,3,2016-03-30T12:36:54Z,2017-01-07T07:43:34Z,2017-01-07T07:43:34Z,MEMBER,,,,"Not sure if this is possible to specify in the `setup.py` as bottleneck is not required. However, if bottleneck is used it should probably be in version 1.0. For version 0.8.0 I get the following error:
`>>> move_mean() got an unexpected keyword argument 'min_count'`
Feel free to close.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/808/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
171956399,MDU6SXNzdWUxNzE5NTYzOTk=,975,invalid timestamps in the future,10194086,closed,0,,,6,2016-08-18T17:29:02Z,2016-08-25T22:39:26Z,2016-08-25T22:39:26Z,MEMBER,,,,"If I have a netCDF file that has invalid timesteps from the 'future', it is wrongly converted to datetime64[ns].
```
import netCDF4 as nc
import numpy as np
import xarray as xr
# create netCDF file
ncf = nc.Dataset('test_future.nc', 'w')
ncf.createDimension('time')
ncf.createVariable('time', np.int, dimensions=('time'))
ncf.variables['time'].units = 'days since 1850-01-01 00:00:00'
ncf.variables['time'].calendar = 'standard'
ncf.variables['time'][:] = np.arange(850) * 365
ncf.close()
# open with xr
ds = xr.open_dataset('test_future.nc')
# this works
ds
# ds.time is a datetime64[ns] object
# this fails
ds.time
```
If I choose chalendar='noleap' the dates wrap around!
```
ncf = nc.Dataset('test_future_noleap.nc', 'w')
ncf.createDimension('time')
ncf.createVariable('time', np.int, dimensions=('time'))
ncf.variables['time'].units = 'days since 1850-01-01 00:00:00'
ncf.variables['time'].calendar = 'noleap'
ncf.variables['time'][:] = np.arange(850) * 365
ncf.close()
# open with xr
ds = xr.open_dataset('test_future_noleap.nc')
# after 2262 they go back to 1678!
ds.time
```
If my 'invalid' time is from the 'past' it works as expected:
```
ncf = nc.Dataset('test_past.nc', 'w')
ncf.createDimension('time')
ncf.createVariable('time', np.int, dimensions=('time'))
ncf.variables['time'].units = 'days since 1000-01-01 00:00:00'
ncf.variables['time'].calendar = 'standard'
ncf.variables['time'][:] = np.arange(850) * 365
ncf.close()
# open with xr
ds = xr.open_dataset('test_past.nc')
# this works
ds
# ds.time is a object
ds.time
```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/975/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
138443211,MDU6SXNzdWUxMzg0NDMyMTE=,784,almost-equal grids,10194086,closed,0,,,6,2016-03-04T10:50:34Z,2016-03-29T08:46:07Z,2016-03-29T08:46:07Z,MEMBER,,,,"Sometimes it happens that you have two grids that are equal up to precision or ""for practical purposes"". xarray does not align them. Is there a possibility to still get them aligned (and not having to copy the coordinates from one to the other)?
Examples:
- CESM output from the land model and the atmosphere model.
- I have a file with a region definition on a fine grid. If I regrid that to the model resolution with cdo the grids are equal up to `~1*10**-4`.
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/784/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
138519359,MDU6SXNzdWUxMzg1MTkzNTk=,786,reindex and netCDF indexing,10194086,closed,0,,,2,2016-03-04T16:37:32Z,2016-03-04T18:49:54Z,2016-03-04T18:49:54Z,MEMBER,,,,"reindex can cause problems as long as the data is not loaded
```
import xarray as xr
data = xr.DataArray([1, 2, 3], dims='x').to_dataset('name')
data.to_netcdf('tst.nc')
# works fine
a = xr.open_dataset('tst.nc')
a.load()
a.reindex(x=[2, 0, 1])
# problem
b = xr.open_dataset('tst.nc')
b.reindex(x=[2, 0, 1])
```
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/786/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
134321867,MDU6SXNzdWUxMzQzMjE4Njc=,766,colormap with vmin vmax,10194086,closed,0,,,3,2016-02-17T16:02:30Z,2016-02-18T08:38:50Z,2016-02-18T08:06:05Z,MEMBER,,,,"When specifying a negative vmin and a positive vmax the `viridis` colormap is used. Is this intentional?
```
import xarray as xr
import matplotlib.pyplot as plt
airtemps = xr.tutorial.load_dataset('air_temperature')
air2d = airtemps.air.isel(time=500) - 273.15
# diverging colormap
air2d.plot.pcolormesh()
plt.show()
# viridis
air2d.plot.pcolormesh(vmin=-24, vmax=24)
plt.show()
# ------------------------------------------------------------
# the solution:
# diverging colormap
air2d.plot.pcolormesh(vmin=-24, center=0)
plt.show()
```
EDIT: solution and working example
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/766/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
67356079,MDU6SXNzdWU2NzM1NjA3OQ==,388,DataArray and virtual variables,10194086,closed,0,,,2,2015-04-09T12:59:08Z,2015-09-15T15:26:29Z,2015-09-15T15:26:28Z,MEMBER,,,,"Now that we are at it... Why don't DataArrays have virtual variables?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/388/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
105414928,MDU6SXNzdWUxMDU0MTQ5Mjg=,560,replace time coordinates for whole year,10194086,closed,0,,,3,2015-09-08T16:09:52Z,2015-09-08T16:40:52Z,2015-09-08T16:40:52Z,MEMBER,,,,"It is quite convenient to select a whole year `ds.sel(time='1991')`. However, sel should not be used to assign data. Thus you can not do `ds.sel(time='1991').coords['time'] = time` and `ds[dict(time='1991')]` does not work.
1) Should `ds[dict(time='1991')]` work?
2) A possible workaround is:
```
idx = xray.core.indexing.remap_label_indexers(ds, {'time' : '1999'})
ds[idx] = time
```
Should this be added to the documentation or is this case too uncommon?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/560/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
83530814,MDU6SXNzdWU4MzUzMDgxNA==,415,Nearest neighbor lookups,10194086,closed,0,,,3,2015-06-01T14:34:03Z,2015-06-02T07:29:24Z,2015-06-01T18:27:21Z,MEMBER,,,,"Nearest neighbor lookups does not seem to work:
```
import xray
xray.__version__
```
0.4.1
```
data = xray.DataArray([1, 2, 3], dims='x')
data.sel(x=[1.1, 1.9], method='nearest')
```
ValueError: not all values found in index 'x'
Example from:
http://xray.readthedocs.org/en/latest/indexing.html#nearest-neighbor-lookups
(pandas version 0.16.1)
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/415/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
67332234,MDU6SXNzdWU2NzMzMjIzNA==,386,"""loosing"" virtual variables",10194086,closed,0,,,4,2015-04-09T10:35:31Z,2015-04-20T03:55:44Z,2015-04-20T03:55:44Z,MEMBER,,,,"Once I take a mean over virtual variables, they are not available any more.
```
import pandas as pd
import numpy as np
import xray
t = pd.date_range('2000-01-01', '2000-12-31', freq='6H')
x = np.random.rand(*t.shape)
time = xray.DataArray(t, name='t', dims='time')
ts = xray.Dataset({'x' : ('time', x), 'time' : time})
ts_mean = ts.groupby('time.date').mean()
ts_mean.virtual_variables
```
Is this intended behaviour? And could I get them back somehow?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/386/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
67343193,MDU6SXNzdWU2NzM0MzE5Mw==,387,Accessing virtual_variables,10194086,closed,0,,,1,2015-04-09T11:41:08Z,2015-04-09T13:45:29Z,2015-04-09T13:45:29Z,MEMBER,,,,"Virtual variables such as time.date can not be accessed by dot notation.
```
In [81]: ts.time.date
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in ()
----> 1 ts.time.date
/home/mathause/.local/lib/python2.7/site-packages/xray/core/common.pyc in __getattr__(self, name)
115 pass
116 raise AttributeError(""%r object has no attribute %r"" %
--> 117 (type(self).__name__, name))
118
119 def __dir__(self):
AttributeError: 'DataArray' object has no attribute 'date'
```
Compare
```
ts.__getattr__('time.date')
```
So maybe time.date is not a useful name. time_date? Or don't show these attributes to the user?
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/387/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue
|