Skip to content

Commit a1b0523

Browse files
authored
try to import UndefinedVariableError from the new location (#6701)
* try to import `UndefinedVariableError` from the new location * [test-upstream] * mention when to clean up [test-upstream]
1 parent 1d9c1e3 commit a1b0523

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

xarray/tests/test_dataarray.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import pandas as pd
1212
import pytest
1313
from packaging.version import Version
14-
from pandas.core.computation.ops import UndefinedVariableError
1514

1615
import xarray as xr
1716
from xarray import (
@@ -52,6 +51,13 @@
5251
source_ndarray,
5352
)
5453

54+
try:
55+
from pandas.errors import UndefinedVariableError
56+
except ImportError:
57+
# TODO: remove once we stop supporting pandas<1.4.3
58+
from pandas.core.computation.ops import UndefinedVariableError
59+
60+
5561
pytestmark = [
5662
pytest.mark.filterwarnings("error:Mean of empty slice"),
5763
pytest.mark.filterwarnings("error:All-NaN (slice|axis) encountered"),

xarray/tests/test_dataset.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import numpy as np
1212
import pandas as pd
1313
import pytest
14-
from pandas.core.computation.ops import UndefinedVariableError
1514
from pandas.core.indexes.datetimes import DatetimeIndex
1615

1716
import xarray as xr
@@ -57,6 +56,13 @@
5756
source_ndarray,
5857
)
5958

59+
try:
60+
from pandas.errors import UndefinedVariableError
61+
except ImportError:
62+
# TODO: remove once we stop supporting pandas<1.4.3
63+
from pandas.core.computation.ops import UndefinedVariableError
64+
65+
6066
try:
6167
import dask.array as da
6268
except ImportError:

0 commit comments

Comments
 (0)