Skip to content

Commit

Permalink
Prevent warning emitted from set_options.__exit__
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerkclark committed Oct 31, 2018
1 parent 079cfdf commit 6d08d3b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions xarray/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class set_options(object):
"""

def __init__(self, **kwargs):
self.old = OPTIONS.copy()
self.old = {}
for k, v in kwargs.items():
if k not in OPTIONS:
raise ValueError(
Expand All @@ -118,6 +118,7 @@ def __init__(self, **kwargs):
if k in _VALIDATORS and not _VALIDATORS[k](v):
raise ValueError(
'option %r given an invalid value: %r' % (k, v))
self.old[k] = OPTIONS[k]
self._apply_update(kwargs)

def _apply_update(self, options_dict):
Expand All @@ -130,5 +131,4 @@ def __enter__(self):
return

def __exit__(self, type, value, traceback):
OPTIONS.clear()
self._apply_update(self.old)

0 comments on commit 6d08d3b

Please sign in to comment.