Skip to content

Commit

Permalink
Add additional omit_fill_value tests
Browse files Browse the repository at this point in the history
Add additional tests to prevent future regression of setting _FillValue
to None when using the encoding kwarg in to_netcdf.
  • Loading branch information
czroth committed Jan 30, 2018
1 parent b8fd86d commit 9210dfa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,25 @@ def test_explicitly_omit_fill_value(self):
with self.roundtrip(ds) as actual:
assert '_FillValue' not in actual.x.encoding

def test_explicitly_omit_fill_value_via_encoding_kwarg(self):
ds = Dataset({'x': ('y', [np.pi, -np.pi])})
ds.x.encoding['_FillValue'] = None
kwargs = dict(encoding={'x': {'_FillValue': None}})
with self.roundtrip(ds, save_kwargs=kwargs) as actual:
assert '_FillValue' not in actual.x.encoding

def test_explicitly_omit_fill_value_in_coord(self):
ds = Dataset({'x': ('y', [np.pi, -np.pi])}, coords={'y': [0.0, 1.0]})
ds.y.encoding['_FillValue'] = None
with self.roundtrip(ds) as actual:
assert '_FillValue' not in actual.y.encoding

def test_explicitly_omit_fill_value_in_coord_via_encoding_kwarg(self):
ds = Dataset({'x': ('y', [np.pi, -np.pi])}, coords={'y': [0.0, 1.0]})
kwargs = dict(encoding={'y': {'_FillValue': None}})
with self.roundtrip(ds, save_kwargs=kwargs) as actual:
assert '_FillValue' not in actual.y.encoding

def test_encoding_same_dtype(self):
ds = Dataset({'x': ('y', np.arange(10.0, dtype='f4'))})
kwargs = dict(encoding={'x': {'dtype': 'f4'}})
Expand Down

0 comments on commit 9210dfa

Please sign in to comment.