def test_nonunique_values_in_column(self): """Test if there are multiple non-unique values in a column of the dataframe.""" df = self.forecast_df.copy() df.at[0, "period"] = pd.Timedelta(7200, units="seconds") msg = "Multiple values provided for the period" with self.assertRaisesRegex(ValueError, msg): forecast_dataframe_to_cube(df, self.date_range, self.forecast_period)
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.forecast_df["period"] = pd.Timedelta("NaT") result = forecast_dataframe_to_cube(self.forecast_df, self.date_range, self.forecast_period) self.assertCubeEqual(result, self.expected_instantaneous_forecast)
def test_two_day_training(self): """Test an input DataFrame is converted correctly into an Iris Cube for a two day training length.""" result = forecast_dataframe_to_cube(self.forecast_df, self.date_range_two_days, self.forecast_period) self.assertCubeEqual(result, self.expected_period_forecast[:, 1:])
def test_empty_dataframe(self): """Test if none of the required data is available in the dataframe.""" forecast_period = 7 * 3600 result = forecast_dataframe_to_cube(self.forecast_df, self.date_range, forecast_period) self.assertIsNone(result)
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 = forecast_dataframe_to_cube(self.forecast_df, self.date_range, self.forecast_period) self.assertCubeEqual(result, self.expected_period_forecast)