Skip to content

Commit 6d08d3b

Browse files
committed
Prevent warning emitted from set_options.__exit__
1 parent 079cfdf commit 6d08d3b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

xarray/core/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ class set_options(object):
109109
"""
110110

111111
def __init__(self, **kwargs):
112-
self.old = OPTIONS.copy()
112+
self.old = {}
113113
for k, v in kwargs.items():
114114
if k not in OPTIONS:
115115
raise ValueError(
@@ -118,6 +118,7 @@ def __init__(self, **kwargs):
118118
if k in _VALIDATORS and not _VALIDATORS[k](v):
119119
raise ValueError(
120120
'option %r given an invalid value: %r' % (k, v))
121+
self.old[k] = OPTIONS[k]
121122
self._apply_update(kwargs)
122123

123124
def _apply_update(self, options_dict):
@@ -130,5 +131,4 @@ def __enter__(self):
130131
return
131132

132133
def __exit__(self, type, value, traceback):
133-
OPTIONS.clear()
134134
self._apply_update(self.old)

0 commit comments

Comments
 (0)