def test_fails_if_can_not_convert_units(self):
     """Test fails if it can not convert units """
     units = 'mm'
     msg = ('Failed to convert coord units ')
     with self.assertRaisesRegex(ValueError, msg):
         WeightsUtilities.process_coord(self.cube, self.coordinate,
                                        self.wrong_coord_vals, units)
 def test_fails_less_points_in_coord(self):
     """Test fails if less points in coord than in cube. """
     exp_coord_vals = self.exp_coord_vals[0]
     msg = ('The cube coordinate has more points ' 'than requested coord, ')
     with self.assertRaisesRegex(ValueError, msg):
         WeightsUtilities.process_coord(self.cube, self.coordinate,
                                        exp_coord_vals)
 def test_basic(self):
     """Test process_coord returns num and array of missing_weights. """
     (result_num_of_weights,
      result_missing) = WeightsUtilities.process_coord(
          self.cube, self.coordinate, self.exp_coord_vals)
     self.assertIsInstance(result_num_of_weights, int)
     self.assertIsInstance(result_missing, np.ndarray)
 def test_no_points_set_in_coord(self):
     """Test returns num in coordinate if no points set in coord. """
     expected_num = len(self.cube_coord.points)
     expected_array = np.ones(expected_num)
     (result_num_of_weights,
      result_missing) = WeightsUtilities.process_coord(self.cube,
                                                       self.coordinate)
     self.assertAlmostEquals(result_num_of_weights, expected_num)
     self.assertArrayAlmostEqual(result_missing, expected_array)
 def test_finds_missing_points(self):
     """Test correct values are returned for case where not all expected
        coordinate values are present in cube."""
     expected_num = 3
     expected_array = np.ones(expected_num)
     expected_array[0] = 0.0
     (result_num_of_weights,
      result_missing) = WeightsUtilities.process_coord(
          self.cube, self.coordinate, self.wrong_coord_vals)
     self.assertAlmostEqual(result_num_of_weights, expected_num)
     self.assertArrayAlmostEqual(result_missing, expected_array)
 def test_fails_coord_not_in_cube(self):
     """ Test process_cord fails if coord not in cube """
     msg = ('The coord for this plugin must be '
            'an existing coordinate in the input cube.')
     with self.assertRaisesRegexp(ValueError, msg):
         WeightsUtilities.process_coord(self.cube, 'not_in_cube', '0')