def test_units(self): """Test values are returned in units of perturbations""" for cube in self.background_flow: cube.convert_units("knots") result = _perturb_background_flow(self.background_flow, self.perturbations) for cube in result: self.assertEqual(cube.units, "m s-1") self.assertArrayAlmostEqual(result[0].data, self.expected_u) self.assertArrayAlmostEqual(result[1].data, self.expected_v)
def test_basic(self): """Test function returns cubes with expected names""" expected_names = [ "precipitation_advection_x_velocity", "precipitation_advection_y_velocity", ] result = _perturb_background_flow(self.background_flow, self.perturbations) for i, cube in enumerate(result): self.assertIsInstance(cube, iris.cube.Cube) self.assertEqual(cube.name(), expected_names[i])
def test_nans_values(self): """Test correct values are returned when an input contains nan values""" result = _perturb_background_flow(self.background_flow, self.perturbations_with_nans) self.assertArrayAlmostEqual(result[0].data, self.expected_u) self.assertArrayAlmostEqual(result[1].data, self.expected_v)
def test_values(self): """Test function returns expected values""" result = _perturb_background_flow(self.background_flow, self.perturbations) self.assertArrayAlmostEqual(result[0].data, self.expected_u) self.assertArrayAlmostEqual(result[1].data, self.expected_v)