Skip to content

Commit

Permalink
TEST: Intolerant area weighted float comparison failure
Browse files Browse the repository at this point in the history
  • Loading branch information
cpelley committed Oct 19, 2016
1 parent 51c04d9 commit 45054fa
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# (C) British Crown Copyright 2014 - 2015, Met Office
# (C) British Crown Copyright 2014 - 2016, Met Office
#
# This file is part of Iris.
#
Expand Down Expand Up @@ -150,5 +150,32 @@ def test_scalar_with_overlap_above_mdtol(self):
self.assertEqual(ma.count_masked(res.data), 1)


class TestWrapAround(tests.IrisTest):
def test_float_tolerant_equality(self):
# Ensure that floating point numbers are treated appropriately when
# introducing precision difference from wrap_around.
source = Cube([[1]])
bounds = np.array([[-91, 0]], dtype='float')
points = bounds.mean(axis=1)
lon_coord = DimCoord(points, bounds=bounds, standard_name='longitude')
source.add_aux_coord(lon_coord, 1)

bounds = np.array([[-90, 90]], dtype='float')
points = bounds.mean(axis=1)
lat_coord = DimCoord(points, bounds=bounds, standard_name='latitude')
source.add_aux_coord(lat_coord, 0)

grid = Cube([[0]])
bounds = np.array([[270, 360]], dtype='float')
points = bounds.mean(axis=1)
lon_coord = DimCoord(points, bounds=bounds, standard_name='longitude')
grid.add_aux_coord(lon_coord, 1)
grid.add_aux_coord(lat_coord, 0)

res = regrid(source, grid)
# The result should be equal to the source data and NOT be masked.
self.assertMaskedArrayEqual(res.data, np.array([1.0]))


if __name__ == '__main__':
tests.main()

0 comments on commit 45054fa

Please sign in to comment.