Skip to content

Commit

Permalink
Correct test file, reuse mask
Browse files Browse the repository at this point in the history
  • Loading branch information
DPeterK committed Mar 14, 2017
1 parent f6f14fd commit 9e94584
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ failed to merge into a single cube.
cube.attributes keys differ: 'stuffed'
cube.cell_methods differ
cube.shape differs: (3,) != (2,)
cube data dtype differs: int64 != float64
cube data dtype differs: int64 != int8
14 changes: 6 additions & 8 deletions lib/iris/tests/unit/lazy_data/test_array_masked_to_nans.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ def _common_checks(self, result):
self.assertFalse(ma.isMaskedArray(result))

def test_masked(self):
masked_array = ma.masked_array([[1.0, 2.0], [3.0, 4.0]],
mask=[[0, 1], [0, 0]])
mask = [[False, True], [False, False]]
masked_array = ma.masked_array([[1.0, 2.0], [3.0, 4.0]], mask=mask)

result = array_masked_to_nans(masked_array)

self._common_checks(result)
self.assertArrayAllClose(np.isnan(result),
[[False, True], [False, False]])
self.assertArrayAllClose(np.isnan(result), mask)
result[0, 1] = 777.7
self.assertArrayAllClose(result, [[1.0, 777.7], [3.0, 4.0]])

Expand All @@ -70,15 +69,14 @@ def test_no_mask(self):
self.assertArrayAllClose(result, masked_array.data)

def test_masked__integers(self):
masked_array = ma.masked_array([[1, 2], [3, 4]],
mask=[[0, 1], [0, 0]])
mask = [[False, True], [False, False]]
masked_array = ma.masked_array([[1, 2], [3, 4]], mask=mask)

result = array_masked_to_nans(masked_array)

self._common_checks(result)
self.assertEqual(result.dtype, np.dtype('f8'))
self.assertArrayAllClose(np.isnan(result),
[[False, True], [False, False]])
self.assertArrayAllClose(np.isnan(result), mask)
result[0, 1] = 777.7
self.assertArrayAllClose(result, [[1.0, 777.7], [3.0, 4.0]])

Expand Down

0 comments on commit 9e94584

Please sign in to comment.