Example #1
0
 def test_one_bounds(self):
     """Test that if there is only 1 set of bounds on the cubes
     an error is raised."""
     cube_with_bounds = self.cube.copy()
     cube_with_bounds.coord('time').bounds = [0., 1.]
     result = iris.cube.CubeList([cube_with_bounds, self.cube])
     msg = "Cubes with mismatching time bounds are not compatible"
     with self.assertRaisesRegex(ValueError, msg):
         _check_coord_bounds(result)
Example #2
0
 def test_mismatched_bounds(self):
     """Test for error when input cubes has mismatched bounds."""
     cube_with_bounds = self.cube.copy()
     cube_with_bounds.coord('time').bounds = [0., 1.]
     cube_diff_bounds = self.cube.copy()
     cube_diff_bounds.coord('time').bounds = [3., 4.]
     result = iris.cube.CubeList([cube_with_bounds, cube_diff_bounds])
     msg = "Cubes with mismatching time bounds are not compatible"
     with self.assertRaisesRegex(ValueError, msg):
         _check_coord_bounds(result)
Example #3
0
 def test_with_bounds(self):
     """Test that the inputs are unchanged when bounds match for time."""
     cubeA = self.cube.copy()
     cubeB = self.cube.copy()
     bounds = [0., 1.]
     cubeA.coord('time').bounds = bounds
     cubeB.coord('time').bounds = bounds
     result = iris.cube.CubeList([cubeA, cubeB])
     _check_coord_bounds(result)
     self.assertArrayAlmostEqual(result[0].coord('time').bounds, [bounds])
     self.assertArrayAlmostEqual(result[1].coord('time').bounds, [bounds])
Example #4
0
 def test_with_no_bounds(self):
     """ Test that the bounds are not changed when there are no
     bounds."""
     cubeA = self.cube.copy()
     add_forecast_reference_time_and_forecast_period(cubeA)
     cubeB = self.cube.copy()
     add_forecast_reference_time_and_forecast_period(cubeB)
     result = iris.cube.CubeList([cubeA, cubeB])
     _check_coord_bounds(result)
     self.assertTrue(result[0].coord('time').bounds is None)
     self.assertTrue(result[1].coord('time').bounds is None)
Example #5
0
 def test_one_bounds_threecubes(self):
     """Test that when one of the input cubes has no bounds an error is
     raised."""
     cube_with_bounds = self.cube.copy()
     cube_with_bounds.coord('time').bounds = [0., 1.]
     cube_no_bounds = self.cube.copy()
     result = iris.cube.CubeList(
         [cube_with_bounds, cube_no_bounds, cube_with_bounds])
     msg = "Cubes with mismatching time bounds are not compatible"
     for cube in result:
         with self.assertRaisesRegex(ValueError, msg):
             _check_coord_bounds(result)
Example #6
0
 def test_with_bounds_threecubes(self):
     """Test that the inputs are unchanged when bounds match for time
     when using three cubes."""
     cubeA = self.cube.copy()
     cubeB = self.cube.copy()
     cubeC = self.cube.copy()
     bounds = [0., 1.]
     cubeA.coord('time').bounds = bounds
     cubeB.coord('time').bounds = bounds
     cubeC.coord('time').bounds = bounds
     result = iris.cube.CubeList([cubeA, cubeB, cubeC])
     _check_coord_bounds(result)
     for cube in result:
         self.assertArrayAlmostEqual(cube.coord('time').bounds, [bounds])
Example #7
0
 def test_basic_threecubes(self):
     """Test that the input remains an iris.cube.CubeList when three cubes
     are present."""
     result = iris.cube.CubeList([self.cube, self.cube, self.cube])
     _check_coord_bounds(result)
     self.assertIsInstance(result, iris.cube.CubeList)
Example #8
0
 def test_basic(self):
     """Test that the input remains an iris.cube.CubeList."""
     result = iris.cube.CubeList([self.cube])
     _check_coord_bounds(result)
     self.assertIsInstance(result, iris.cube.CubeList)