Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Pass kwargs to the FileManager for pynio engine (#2380) #2732

Merged
merged 4 commits into from
Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Bug fixes
:py:class:`CFTimeIndex` now results in a :py:class:`pandas.TimedeltaIndex`
instead of raising a ``TypeError`` (:issue:`2671`). By `Spencer Clark
<https://github.com/spencerkclark>`_.
- backend_kwargs are no longer ignored when using open_dataset with pynio engine
(:issue:'2380')
By 'Jonathan Joyce <https://github.com/jonmjoyce>'_.
- Fix ``open_rasterio`` creating a WKT CRS instead of PROJ.4 with
``rasterio`` 1.0.14+ (:issue:`2715`).
By `David Hoese <https://github.com/djhoese`_.
Expand Down
4 changes: 2 additions & 2 deletions xarray/backends/pynio_.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class NioDataStore(AbstractDataStore):
"""Store for accessing datasets via PyNIO
"""

def __init__(self, filename, mode='r', lock=None):
def __init__(self, filename, mode='r', lock=None, **kwargs):
import Nio
if lock is None:
lock = PYNIO_LOCK
self.lock = ensure_lock(lock)
self._manager = CachingFileManager(
Nio.open_file, filename, lock=lock, mode=mode)
Nio.open_file, filename, lock=lock, mode=mode, kwargs=kwargs)
# xarray provides its own support for FillValue,
# so turn off PyNIO's support for the same.
self.ds.set_option('MaskedArrayMode', 'MaskedNever')
Expand Down
6 changes: 6 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2546,6 +2546,12 @@ def open(self, path, **kwargs):
with open_dataset(path, engine='pynio', **kwargs) as ds:
yield ds

def test_kwargs(self):
kwargs = {'format': 'grib'}
path = os.path.join(os.path.dirname(__file__), 'data', 'example')
with backends.NioDataStore(path, **kwargs) as store:
assert store._manager._kwargs['format'] == 'grib'

def save(self, dataset, path, **kwargs):
return dataset.to_netcdf(path, engine='scipy', **kwargs)

Expand Down