Skip to content

Commit 069047b

Browse files
committed
get_options return type to FrozenDict and added retention test
1 parent e2411db commit 069047b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

xarray/core/options.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import warnings
22

3+
from .utils import FrozenDict
4+
35
ARITHMETIC_JOIN = "arithmetic_join"
46
CMAP_DIVERGENT = "cmap_divergent"
57
CMAP_SEQUENTIAL = "cmap_sequential"
@@ -250,4 +252,4 @@ def get_options():
250252
expand, ``False`` to always collapse, or ``default`` to expand unless over
251253
a pre-defined limit. Default: ``default``.
252254
"""
253-
return OPTIONS
255+
return FrozenDict(OPTIONS)

xarray/tests/test_options.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,10 @@ def test_display_dataarray_style_html(self):
203203
html = da._repr_html_()
204204
assert html.startswith("<div>")
205205
assert "#x27;nested&#x27;" in html
206+
207+
208+
def test_get_options_retention():
209+
"""Test to check if get_options will return changes made by set_options"""
210+
with xarray.set_options(arithmetic_join="left"):
211+
get_options = xarray.get_options()
212+
assert get_options["arithmetic_join"] == "left"

0 commit comments

Comments
 (0)