holoviews 1.10 no longer respects the order of coordinates of an xarray dataset
See original GitHub issueThere is a change of behaviour between holoviews 1.9.5 and 1.10 with the way to build kdims from coordinates of an xarray dataset.
I noticed this because I have an images stack with coordinates (x,y,time) ; let’s call it ds. It is handy to visualize it with hv.Dataset(ds).to(hv.Image) because holoviews nicely infers that x and y are the kdims of the image and uses a menu for the time. With 1.10 though, the kdims become (time,x,y) and the inference is no longer what we could expect.
Here is a small exemple to reproduce this :
import numpy as np,holoviews as hv,xarray as xr
from collections import OrderedDict
data = np.zeros((3,4,5))
coords = OrderedDict(b=range(3), c=range(4), a=range(5))
dataset=xr.Dataset(coords=coords)
dataset['value']=([*dataset.coords.keys()], data)
The output is an xarray with dimensions (a,b,c) and coordinates (b,c,a) as we can check with print([*dataset.dims],[*dataset.coords]).
This command hv.Dataset(dataset).kdims
gives:
- output of 1.9.5 : [Dimension(‘b’), Dimension(‘c’), Dimension(‘a’)]
- output of 1.10 : [Dimension(‘a’), Dimension(‘b’), Dimension(‘c’)]
Has it something to do with changes in the XArrayInterface?
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (9 by maintainers)
Top GitHub Comments
If there was some way to tell whether the coord order was defined explicitly or was just decided implicitly by the dictionary ordering I’d be happy to make use of that but as it is I’m inclined to stick with the new behavior for consistency.
Thanks for reporting this. It does seem to be a significant change in behavior and I think we should return to the old behavior for 1.10.1.