Skip to content

Commit ec384b4

Browse files
committed
Address errors due to pandas-dev/pandas#63231
1 parent 05fe36a commit ec384b4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

xarray/tests/test_variable.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,16 @@ def var():
7474
],
7575
)
7676
def test_as_compatible_data_writeable(data):
77-
pd.set_option("mode.copy_on_write", True)
77+
# In pandas 3 the mode.copy_on_write option defaults to True, so the option
78+
# setting logic can be removed once our minimum version of pandas is
79+
# greater than or equal to 3.
80+
if not has_pandas_3:
81+
pd.set_option("mode.copy_on_write", True)
7882
# GH8843, ensure writeable arrays for data_vars even with
7983
# pandas copy-on-write mode
8084
assert as_compatible_data(data).flags.writeable
81-
pd.reset_option("mode.copy_on_write")
85+
if not has_pandas_3:
86+
pd.reset_option("mode.copy_on_write")
8287

8388

8489
class VariableSubclassobjects(NamedArraySubclassobjects, ABC):

0 commit comments

Comments
 (0)