Skip to content

Commit c748062

Browse files
author
Joe Hamman
authored
fix nc4 shuffle option roundtrip (#1607)
* fix nc4 shuffle option roundtrip * fix merge conflict
1 parent e713668 commit c748062

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/whats-new.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Bug fixes
196196
- ``:py:meth:`~xarray.Dataset.__init__` raises a ``MergeError`` if an
197197
coordinate shares a name with a dimension but is comprised of arbitrary
198198
dimensions(:issue:`1120`).
199+
199200
- :py:func:`~xarray.open_rasterio` method now skips rasterio.crs -attribute if
200201
it is none.
201202
By `Leevi Annala <https://github.com/leevei>`_.
@@ -212,6 +213,10 @@ Bug fixes
212213
the first argument was a numpy variable (:issue:`1588`).
213214
By `Guido Imperiale <https://github.com/crusaderky>`_.
214215

216+
- Fix ``netCDF4`` backend to properly roundtrip the ``shuffle`` encoding option
217+
(:issue:`1606`).
218+
By `Joe Hamman <https://github.com/jhamman>`_.
219+
215220
- Fix bug when using ``pytest`` class decorators to skiping certain unittests.
216221
The previous behavior unintentionally causing additional tests to be skipped
217222
(:issue:`1531`). By `Joe Hamman <https://github.com/jhamman>`_.

xarray/backends/netCDF4_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def _extract_nc4_variable_encoding(variable, raise_on_invalid=False,
153153

154154
safe_to_drop = set(['source', 'original_shape'])
155155
valid_encodings = set(['zlib', 'complevel', 'fletcher32', 'contiguous',
156-
'chunksizes'])
156+
'chunksizes', 'shuffle'])
157157
if lsd_okay:
158158
valid_encodings.add('least_significant_digit')
159159

xarray/tests/test_backends.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,7 @@ def test_compression_encoding(self):
729729
data['var2'].encoding.update({'zlib': True,
730730
'chunksizes': (5, 5),
731731
'fletcher32': True,
732+
'shuffle': True,
732733
'original_shape': data.var2.shape})
733734
with self.roundtrip(data) as actual:
734735
for k, v in iteritems(data['var2'].encoding):
@@ -1846,6 +1847,11 @@ def test_extract_nc4_variable_encoding(self):
18461847
encoding = _extract_nc4_variable_encoding(var)
18471848
self.assertEqual({}, encoding)
18481849

1850+
# regression test
1851+
var = xr.Variable(('x',), [1, 2, 3], {}, {'shuffle': True})
1852+
encoding = _extract_nc4_variable_encoding(var, raise_on_invalid=True)
1853+
self.assertEqual({'shuffle': True}, encoding)
1854+
18491855
def test_extract_h5nc_encoding(self):
18501856
# not supported with h5netcdf (yet)
18511857
var = xr.Variable(('x',), [1, 2, 3], {},

0 commit comments

Comments
 (0)