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 599993415,MDU6SXNzdWU1OTk5OTM0MTU=,3972,Variable objects not displayable in notebook,9948595,closed,0,,,2,2020-04-15T03:32:13Z,2020-04-29T15:54:23Z,2020-04-29T15:54:23Z,CONTRIBUTOR,,,,"class `Variable` subclasses` AbstractArray` which has a `_repr_html_` method so variable objects should display in a notebook. But this fails with a `AttributeError: 'Variable' object has no attribute 'variable'`: ```python from os.path import join,dirname import xarray as xr ds=join(dirname(xr.__file__), 'tests/data/bears.nc') xr.open_dataset(ds).variables['cross'] ``` ### Fix: change line 186 in `xarray.core.formatting_html.py:: array_section` from ```python preview = escape(inline_variable_array_repr(obj.variable, max_width=70)) ``` to (because obj *is* a variable): ```python preview = escape(inline_variable_array_repr(obj.variable if hasattr(obj, ""variable"") else obj, max_width=70)) ``` I can make a PR if you like. ``` 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-46-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_AU.UTF-8 LOCALE: en_AU.UTF-8 libhdf5: 1.10.5 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: None cfgrib: None iris: None bottleneck: None dask: 2.14.0 distributed: 2.6.0 matplotlib: 3.2.1 cartopy: None seaborn: 0.10.0 numbagg: None setuptools: 46.1.3.post20200325 pip: 20.0.2 conda: 4.8.3 pytest: 5.4.1 IPython: 7.13.0 sphinx: 2.2.1 ```","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/3972/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 437940426,MDU6SXNzdWU0Mzc5NDA0MjY=,2923,Calling max() on a stacked dimension raises exception,9948595,closed,0,,,1,2019-04-27T12:50:01Z,2019-06-27T16:06:55Z,2019-06-27T16:06:55Z,CONTRIBUTOR,,,,"#### Code Sample, a copy-pastable example if possible A ""Minimal, Complete and Verifiable Example"" will make it much easier for maintainers to help you: http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports ```python import numpy as np import xarray as xr data2 = np.random.randn(3,100, 4) da = xr.DataArray( data2, name='value', dims=['replicate', 'rsample', 'exp'], coords=dict(replicate=[0,1,2], exp=['a', 'b', 'c', 'd'], rsample=list(range(100)))) da2 = da.stack(sample=('replicate', 'rsample')) da2.sample.max() ``` #### Problem description Calling `max()` on a stacked dimension raises the exception `ValueError: dimensions () must have the same length as the number of data dimensions, ndim=1` #### Expected Output Maximum value of selected dimension. i.e an index I can use with loc e.g. ` da2.loc['a', da2.sample.max()]` that is `da2.loc['a', (2,99)]` So I guess I'm expecting something like: ``` array((2, 99), dtype=object) ``` This works: `da2.loc['a', xr.DataArray((2,99), dims=(), name='sample')]` #### Output of ``xr.show_versions()`` INSTALLED VERSIONS ------------------ commit: None python: 3.7.3 (default, Mar 27 2019, 22:11:17) [GCC 7.3.0] python-bits: 64 OS: Linux OS-release: 4.15.0-47-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: None LANG: en_AU.UTF-8 LOCALE: en_AU.UTF-8 libhdf5: 1.10.4 libnetcdf: 4.6.1 xarray: 0.12.1 pandas: 0.24.2 numpy: 1.15.4 scipy: 1.2.1 netCDF4: 1.4.2 pydap: None h5netcdf: None h5py: 2.9.0 Nio: None zarr: None cftime: 1.0.3.4 nc_time_axis: None PseudonetCDF: None rasterio: None cfgrib: None iris: None bottleneck: 1.2.1 dask: 1.2.0 distributed: 1.27.0 matplotlib: 3.0.3 cartopy: None seaborn: 0.9.0 setuptools: 40.6.3 pip: 18.1 conda: 4.6.14 pytest: None IPython: 7.4.0 sphinx: 2.0.1 ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/2923/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue