Elffuss BraidHub

kikocis/auto-code-rover public

main · 1.6 KiBRawPermalink
1to_unstacked_dataset broken for single-dim variables
2<!-- A short summary of the issue, if appropriate -->
3
4
5#### MCVE Code Sample
6
7```python
8arr = xr.DataArray(
9 np.arange(3),
10 coords=[("x", [0, 1, 2])],
11 )
12data = xr.Dataset({"a": arr, "b": arr})
13stacked = data.to_stacked_array('y', sample_dims=['x'])
14unstacked = stacked.to_unstacked_dataset('y')
15# MergeError: conflicting values for variable 'y' on objects to be combined. You can skip this check by specifying compat='override'.
16```
17
18#### Expected Output
19A working roundtrip.
20
21#### Problem Description
22I need to stack a bunch of variables and later unstack them again, however this doesn't work if the variables only have a single dimension.
23
24#### Versions
25
26<details><summary>Output of <tt>xr.show_versions()</tt></summary>
27
28INSTALLED VERSIONS
29------------------
30commit: None
31python: 3.7.3 (default, Mar 27 2019, 22:11:17)
32[GCC 7.3.0]
33python-bits: 64
34OS: Linux
35OS-release: 4.15.0-96-generic
36machine: x86_64
37processor: x86_64
38byteorder: little
39LC_ALL: None
40LANG: en_GB.UTF-8
41LOCALE: en_GB.UTF-8
42libhdf5: 1.10.4
43libnetcdf: 4.6.2
44
45xarray: 0.15.1
46pandas: 1.0.3
47numpy: 1.17.3
48scipy: 1.3.1
49netCDF4: 1.4.2
50pydap: None
51h5netcdf: None
52h5py: 2.10.0
53Nio: None
54zarr: None
55cftime: 1.0.4.2
56nc_time_axis: None
57PseudoNetCDF: None
58rasterio: None
59cfgrib: None
60iris: None
61bottleneck: None
62dask: 2.10.1
63distributed: 2.10.0
64matplotlib: 3.1.1
65cartopy: None
66seaborn: 0.10.0
67numbagg: None
68setuptools: 41.0.0
69pip: 19.0.3
70conda: 4.8.3
71pytest: 5.3.5
72IPython: 7.9.0
73sphinx: None
74
75
76</details>
77