Skip to content

Commit

Permalink
Cleanup logic inside open_dataset, mostly extra_kwargs (#4462)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici authored Oct 8, 2020
1 parent 544bbe2 commit 6dc3c75
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,8 @@ def open_dataset(

if backend_kwargs is None:
backend_kwargs = {}
extra_kwargs = {}

def maybe_decode_store(store, chunks, lock=False):
def maybe_decode_store(store, chunks):
ds = conventions.decode_cf(
store,
mask_and_scale=mask_and_scale,
Expand Down Expand Up @@ -543,18 +542,17 @@ def maybe_decode_store(store, chunks, lock=False):
if engine is None:
engine = _autodetect_engine(filename_or_obj)

if engine in ["netcdf4", "h5netcdf"]:
extra_kwargs = {}
if group is not None:
extra_kwargs["group"] = group
if lock is not None:
extra_kwargs["lock"] = lock
elif engine in ["pynio", "pseudonetcdf", "cfgrib"]:
extra_kwargs["lock"] = lock
elif engine == "zarr":

if engine == "zarr":
backend_kwargs = backend_kwargs.copy()
overwrite_encoded_chunks = backend_kwargs.pop(
"overwrite_encoded_chunks", None
)
extra_kwargs["mode"] = "r"
extra_kwargs["group"] = group

opener = _get_backend_cls(engine)
store = opener(filename_or_obj, **extra_kwargs, **backend_kwargs)
Expand Down

0 comments on commit 6dc3c75

Please sign in to comment.