Пример #1
0
 def test_nonunique_values_in_column(self):
     """Test if there are multiple non-unique values in a column of the
     dataframe."""
     df = self.truth_df.copy()
     df.at[0, "diagnostic"] = "wind_speed_at_10m"
     msg = "Multiple values provided for the diagnostic"
     with self.assertRaisesRegex(ValueError, msg):
         truth_dataframe_to_cube(df, self.date_range)
Пример #2
0
 def test_two_day_training(self):
     """Test an input DataFrame is converted correctly into an Iris Cube
     for a two day training length."""
     result = truth_dataframe_to_cube(
         self.truth_df,
         self.date_range_two_days,
     )
     self.assertCubeEqual(result, self.expected_period_truth[1:, :])
Пример #3
0
 def test_three_day_training_period_diag(self):
     """Test an input DataFrame is converted correctly into an Iris Cube
     for a three day training length for a period diagnostic."""
     result = truth_dataframe_to_cube(
         self.truth_df,
         self.date_range,
     )
     self.assertCubeEqual(result, self.expected_period_truth)
Пример #4
0
 def test_three_day_training_instantaneous_diag(self):
     """Test an input DataFrame is converted correctly into an Iris Cube
     for a three day training length for an instantaneous diagnostic."""
     self.truth_df["period"] = pd.Timedelta("NaT")
     result = truth_dataframe_to_cube(
         self.truth_df,
         self.date_range,
     )
     self.assertCubeEqual(result, self.expected_instantaneous_truth)
Пример #5
0
 def test_empty_dataframe(self):
     """Test if none of the required data is available in the dataframe."""
     validity_time = np.datetime64("2017-07-22T19:00:00")
     date_range = pd.date_range(end=validity_time,
                                periods=int(self.training_length),
                                freq="D",
                                tz="UTC")
     result = truth_dataframe_to_cube(
         self.truth_df,
         date_range,
     )
     self.assertIsNone(result)