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 1732874789,I_kwDOAMm_X85nSZIl,7885,drop_indexes is reversed by assign_coords of unrelated coord,4502,closed,0,,,2,2023-05-30T19:35:48Z,2023-08-29T14:23:31Z,2023-08-29T14:23:31Z,NONE,,,,"### What happened? I dropped an index on one coord, then later called assign_coords to change another unrelated coord. I expected the index on the original coord to stay dropped. ### What did you expect to happen? The index was silently created again. ### Minimal Complete Verifiable Example ```Python import xarray import numpy as np ds = xarray.Dataset( {'foo': (('x','y'), np.ones((3,5)))}, coords={'x': [1,2,3], 'y': [4,5,6,7,8]}) ds = ds.drop_indexes('x') assert 'x' not in ds.indexes ds = ds.assign_coords(y=ds.y+1) assert 'x' not in ds.indexes # Fails ``` ### 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 _No response_ ### Anything else we need to know? In general it would be nice if xarray made it easier to avoid indexes being automatically created. E.g. right now, as far as I can tell there's no way to avoid an index being created when you construct a DataArray or Dataset with a coordinate of the same name as a dimension. Admittedly I have a slightly niche use case -- I'm using xarray with wrapped JAX arrays, which can't be converted into pandas indexes. Indexes being (re-)created in these cases isn't just an inconvenience it actually causes a crash. ### Environment
INSTALLED VERSIONS ------------------ commit: None python: 3.10.9 (main, Dec 7 2022, 13:47:07) [GCC 12.2.0] python-bits: 64 OS: Linux OS-release: 6.1.20-2rodete1-amd64 machine: x86_64 processor: byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: ('en_US', 'UTF-8') libhdf5: 1.10.8 libnetcdf: 4.9.0 xarray: 999 pandas: 1.5.3 numpy: 1.24.2 scipy: 1.10.0 netCDF4: 1.6.2 pydap: None h5netcdf: 1.1.0 h5py: 3.7.0 Nio: None zarr: 2.13.6+ds cftime: 1.6.2 nc_time_axis: None PseudoNetCDF: None rasterio: 1.3.4 cfgrib: 0.9.10.3 iris: None bottleneck: 1.3.5 dask: None distributed: None matplotlib: 3.6.3 cartopy: None seaborn: None numbagg: None fsspec: 2022.11.0 cupy: None pint: None sparse: None flox: None numpy_groupies: None setuptools: 65.6.3 pip3: None conda: None pytest: 7.2.1 mypy: None IPython: 8.5.0 sphinx: 5.3.0
","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7885/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue 1188262115,I_kwDOAMm_X85G03Dj,6429,FacetGrid padding goes very bad when cartopy projection specified,4502,closed,0,,,2,2022-03-31T15:26:26Z,2023-04-28T13:06:14Z,2023-04-28T13:06:14Z,NONE,,,,"### What happened? When doing a faceted plot and specifying a projection (via e.g. `subplot_kws=dict(projection=ccrs.PlateCarree())`), the padding becomes very weird (often unusable) and strangely unstable to changes in `size` and `aspect`. For example this produces very bad results: ```python data = xarray.DataArray( dims=('lat', 'lon', 'row', 'col'), data=np.ones((180, 360, 2, 2)), coords={'lon': np.arange(360), 'lat': np.arange(-90, 90)} ) xarray.plot.pcolormesh( data, row='row', col='col', size=5, aspect=1.5, subplot_kws=dict(projection=ccrs.PlateCarree()), ) ``` ![image](https://user-images.githubusercontent.com/4502/161090986-6dd7fd6b-5950-40aa-a78e-7699061b3a15.png) whereas if you change `size` from 5 to 4, you suddenly get a much better (although still not quite right) layout: ![image](https://user-images.githubusercontent.com/4502/161091130-7e6b9580-d39c-4a89-9756-932bafff9ff0.png) ### What did you expect to happen? I expected a layout closer to what you get if you comment out `subplot_kws=dict(projection=ccrs.PlateCarree()),` above: ![image](https://user-images.githubusercontent.com/4502/161091524-8993534f-efd7-45d3-9b4c-8e25099fb53e.png) ### Minimal Complete Verifiable Example ```Python import xarray import cartopy.crs as ccrs import numpy as np data = xarray.DataArray( dims=('lat', 'lon', 'row', 'col'), data=np.ones((180, 360, 2, 2)), coords={'lon': np.arange(360), 'lat': np.arange(-90, 90)} ) xarray.plot.pcolormesh( data, row='row', col='col', size=5, aspect=1.5, subplot_kws=dict(projection=ccrs.PlateCarree()), ) ``` ### Relevant log output In the case where the layout isn't (as) broken, I see a warning: `.../xarray/plot/facetgrid.py:394: UserWarning: Tight layout not applied. tight_layout cannot make axes width small enough to accommodate all axes decorations` It seems that when tight_layout does manage to get applied, things really go wrong. Perhaps at a minimum we could have a way to disable tight_layout? (which currently seems to be mandatory) ### Anything else we need to know? _No response_ ### Environment INSTALLED VERSIONS ------------------ commit: None python: 3.7.10 (stable, redacted, redacted) [Clang google3-trunk (e5b1b9edb8b6f6cd926c2ba3e1ad1b6f767021d6)] python-bits: 64 OS: Linux OS-release: 4.15.0-smp-920.39.0.0 machine: x86_64 processor: byteorder: little LC_ALL: en_US.UTF-8 LANG: None LOCALE: ('en_US', 'UTF-8') libhdf5: 1.12.1 libnetcdf: 4.6.1 xarray: 0.18.2 pandas: 1.1.5 numpy: 1.21.5 scipy: 1.2.1 netCDF4: 1.4.1 pydap: None h5netcdf: 0.11.0 h5py: 3.2.1 Nio: None zarr: 2.7.0 cftime: 1.0.0 nc_time_axis: None PseudoNetCDF: None rasterio: None cfgrib: None iris: None bottleneck: None dask: None distributed: None matplotlib: 3.3.4 cartopy: 0+unknown seaborn: 0.11.1 numbagg: None pint: None setuptools: unknown pip: None conda: None pytest: None IPython: 3.2.3 sphinx: None","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/6429/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue