Skip to content

Commit 64ce47e

Browse files
committed
minor compatibility fix
1 parent f388362 commit 64ce47e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

psyplot/data.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,11 @@ def get_x(self, var, coords=None):
16991699
triangles = self.get_triangles(var, coords)
17001700
centers = triangles.x[triangles.triangles].mean(axis=-1)
17011701
x = self.get_nodes(self.get_mesh(var, coords), coords)[0]
1702-
return xr.IndexVariable(x.name, centers, attrs=x.attrs.copy())
1702+
try:
1703+
cls = xr.IndexVariable
1704+
except AttributeError: # xarray < 0.9
1705+
cls = xr.Coordinate
1706+
return cls(x.name, centers, attrs=x.attrs.copy())
17031707

17041708
@docstrings.dedent
17051709
def get_y(self, var, coords=None):
@@ -1723,7 +1727,11 @@ def get_y(self, var, coords=None):
17231727
triangles = self.get_triangles(var, coords)
17241728
centers = triangles.y[triangles.triangles].mean(axis=-1)
17251729
y = self.get_nodes(self.get_mesh(var, coords), coords)[1]
1726-
return xr.IndexVariable(y.name, centers, attrs=y.attrs.copy())
1730+
try:
1731+
cls = xr.IndexVariable
1732+
except AttributeError: # xarray < 0.9
1733+
cls = xr.Coordinate
1734+
return cls(y.name, centers, attrs=y.attrs.copy())
17271735

17281736

17291737
# register the UGridDecoder

0 commit comments

Comments
 (0)