Beispiel #1
0
 def test_2d_discontigous_masked(self):
     # Test a 2D coordinate which is discontiguous but masked at
     # discontiguities.
     cube = sample_2d_latlons()
     make_bounds_discontiguous_at_point(cube, 3, 4)
     iplt._check_bounds_contiguity_and_mask(cube.coord('longitude'),
                                            cube.data)
 def test_1d_discontigous_unmasked(self):
     # Test a 1D coordinate which is discontiguous and unmasked at
     # discontiguities.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = ma.array(np.array([278, 300, 282]), mask=[1, 0, 0])
     msg = 'coordinate are not contiguous and data is not masked where ' \
           'the discontiguity occurs'
     with self.assertRaisesRegexp(ValueError, msg):
         _check_bounds_contiguity_and_mask(coord, data, atol=1e-3)
Beispiel #3
0
 def test_1d_discontigous_unmasked(self):
     # Test a 1D coordinate which is discontiguous and unmasked at
     # discontiguities.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = ma.array(np.array([278, 300, 282]), mask=[1, 0, 0])
     msg = 'coordinate are not contiguous and data is not masked where ' \
           'the discontiguity occurs'
     with self.assertRaisesRegexp(ValueError, msg):
         iplt._check_bounds_contiguity_and_mask(coord, data, atol=1e-3)
 def test_2d_discontigous_unmasked(self):
     # Test a 2D coordinate which is discontiguous and unmasked at
     # discontiguities.
     cube = sample_2d_latlons()
     make_bounds_discontiguous_at_point(cube, 3, 4)
     msg = 'coordinate are not contiguous'
     cube.data[3, 4] = ma.nomask
     with self.assertRaisesRegexp(ValueError, msg):
         _check_bounds_contiguity_and_mask(cube.coord('longitude'),
                                           cube.data)
Beispiel #5
0
 def test_2d_discontigous_unmasked(self):
     # Test a 2D coordinate which is discontiguous and unmasked at
     # discontiguities.
     cube = sample_2d_latlons()
     make_bounds_discontiguous_at_point(cube, 3, 4)
     msg = 'coordinate are not contiguous'
     cube.data[3, 4] = ma.nomask
     with self.assertRaisesRegexp(ValueError, msg):
         iplt._check_bounds_contiguity_and_mask(cube.coord('longitude'),
                                                cube.data)
 def test_2d_contiguous_atol(self):
     # Check the atol is passed correctly.
     cube = sample_2d_latlons()
     with mock.patch('iris.coords.Coord._discontiguity_in_bounds'
                     ) as discontiguity_check:
         # Discontiguity returns two objects that are unpacked in
         # `_check_bounds_contiguity_and_mask`.
         discontiguity_check.return_value = [True, None]
         _check_bounds_contiguity_and_mask(cube.coord('longitude'),
                                           cube.data, atol=1e-3)
     discontiguity_check.assert_called_with(atol=1e-3)
Beispiel #7
0
 def test_2d_contiguous_atol(self):
     # Check the atol is passed correctly.
     cube = sample_2d_latlons()
     with mock.patch('iris.coords.Coord._discontiguity_in_bounds'
                     ) as discontiguity_check:
         # Discontiguity returns two objects that are unpacked in
         # `_check_bounds_contiguity_and_mask`.
         discontiguity_check.return_value = [True, None]
         iplt._check_bounds_contiguity_and_mask(cube.coord('longitude'),
                                                cube.data,
                                                atol=1e-3)
     discontiguity_check.assert_called_with(atol=1e-3)
Beispiel #8
0
 def test_1d_not_checked(self):
     # Test a 1D coordinate, which is not checked as atol is not set.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = np.array([278, 300, 282])
     # Make sure contiguity checking doesn't throw an error
     _check_bounds_contiguity_and_mask(coord, data)
 def test_1d_discontigous_masked(self):
     # Test a 1D coordinate which is discontiguous but masked at
     # discontiguities.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = ma.array(np.array([278, 300, 282]), mask=[0, 1, 0])
     _check_bounds_contiguity_and_mask(coord, data, atol=1e-3)
Beispiel #10
0
 def test_2d_contiguous(self):
     # Test a 2D coordinate which is contiguous.
     cube = sample_2d_latlons()
     iplt._check_bounds_contiguity_and_mask(cube.coord('longitude'),
                                            cube.data)
Beispiel #11
0
 def test_1d_contiguous(self):
     # Test a 1D coordinate which is contiguous.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [4, 6]])
     data = np.array([278, 300, 282])
     iplt._check_bounds_contiguity_and_mask(coord, data, atol=1e-3)
Beispiel #12
0
 def test_1d_discontigous_masked(self):
     # Test a 1D coordinate which is discontiguous but masked at
     # discontiguities.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = ma.array(np.array([278, 300, 282]), mask=[0, 1, 0])
     iplt._check_bounds_contiguity_and_mask(coord, data, atol=1e-3)
Beispiel #13
0
 def test_1d_not_checked(self):
     # Test a 1D coordinate, which is not checked as atol is not set.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = np.array([278, 300, 282])
     iplt._check_bounds_contiguity_and_mask(coord, data)
Beispiel #14
0
 def test_2d_discontigous_masked(self):
     # Test that a 2D coordinate which is discontiguous but masked at
     # discontiguities doesn't error.
     cube = sample_2d_latlons()
     make_bounds_discontiguous_at_point(cube, 3, 4)
     _check_bounds_contiguity_and_mask(cube.coord("longitude"), cube.data)
 def test_1d_contiguous(self):
     # Test that a 1D coordinate which is contiguous does not fail.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [4, 6]])
     data = np.array([278, 300, 282])
     _check_bounds_contiguity_and_mask(coord, data, atol=1e-3)
 def test_2d_contiguous(self):
     # Test that a 2D coordinate which is contiguous does not throw
     # an error.
     cube = sample_2d_latlons()
     _check_bounds_contiguity_and_mask(cube.coord('longitude'), cube.data)
 def test_2d_discontigous_masked(self):
     # Test that a 2D coordinate which is discontiguous but masked at
     # discontiguities doesn't error.
     cube = sample_2d_latlons()
     make_bounds_discontiguous_at_point(cube, 3, 4)
     _check_bounds_contiguity_and_mask(cube.coord('longitude'), cube.data)
Beispiel #18
0
 def test_2d_contiguous(self):
     # Test that a 2D coordinate which is contiguous does not throw
     # an error.
     cube = sample_2d_latlons()
     _check_bounds_contiguity_and_mask(cube.coord("longitude"), cube.data)
 def test_1d_not_checked(self):
     # Test a 1D coordinate, which is not checked as atol is not set.
     coord = DimCoord([1, 3, 5], bounds=[[0, 2], [2, 4], [5, 6]])
     data = np.array([278, 300, 282])
     # Make sure contiguity checking doesn't throw an error
     _check_bounds_contiguity_and_mask(coord, data)