Skip to content

Commit

Permalink
Discovered conflicting _FillValue and missing_value, but both are NaN (
Browse files Browse the repository at this point in the history
…pydata#998)

* fixes pydata#997

* use pd.isnull instead of np.isnan

* add  note to "What's New"
  • Loading branch information
mzuehlke authored and shoyer committed Sep 7, 2016
1 parent 69ac511 commit f00ab9b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ Bug fixes
(:issue:`873`).
By `Stephan Hoyer <https://github.com/shoyer>`_.

- Fix issues with variables where both attributes ``_FillValue`` and
``missing_value`` are set to ``NaN`` (:issue:`997`).
By `Marco Zühlke <https://github.com/mzuehlke>`_.

.. _whats-new.0.8.2:

v0.8.2 (18 August 2016)
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def equivalent(first, second):
if isinstance(first, np.ndarray) or isinstance(second, np.ndarray):
return ops.array_equiv(first, second)
else:
return first is second or first == second
return first is second or first == second or (pd.isnull(first) and pd.isnull(second))


def peek_at(iterable):
Expand Down
14 changes: 14 additions & 0 deletions xarray/test/test_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,20 @@ def test_decode_cf_with_conflicting_fill_missing_value(self):
self.assertRaisesRegexp(ValueError, "_FillValue and missing_value",
lambda: conventions.decode_cf_variable(var))

var = Variable(['t'], np.arange(10),
{'units': 'foobar',
'missing_value': np.nan,
'_FillValue': np.nan})
var = conventions.decode_cf_variable(var)
self.assertIsNotNone(var)

var = Variable(['t'], np.arange(10),
{'units': 'foobar',
'missing_value': np.float32(np.nan),
'_FillValue': np.float32(np.nan)})
var = conventions.decode_cf_variable(var)
self.assertIsNotNone(var)

@requires_netCDF4
def test_decode_cf_datetime_non_iso_strings(self):
# datetime strings that are _almost_ ISO compliant but not quite,
Expand Down

0 comments on commit f00ab9b

Please sign in to comment.