Skip to content

Add unit tests for index functions

Implemented tests:

  • CountLevelCrossings
  • CountOccurrences
  • CountJointOccurrencesPrecipitationTemperature
  • CountJointOccurrencesTemperature
  • DiurnalTemperatureRange
  • ExtremeTemperatureRange
  • FirstOccurrence (moved to later release)
  • InterdayDiurnalTemperatureRange
  • LastOccurrence (moved to later release)
  • Percentile
  • Statistics
  • ThresholdedPercentile
  • ThresholdedStatistics
  • RunningStatistics
  • ThresholdedRunningStatistics
  • TemperatureSum

The following unit tests needs to be reviewed from a scientific point of view:

  • CountLevelCrossings - Gustav
  • CountOccurrences - Gustav
  • CountJointOccurrencesPrecipitationTemperature
  • CountJointOccurrencesTemperature
  • DiurnalTemperatureRange - Renate
  • ExtremeTemperatureRange - Renate
  • InterdayDiurnalTemperatureRange - Renate
  • Statistics
  • ThresholdedStatistics - Renate
  • RunningStatistics (complex output with post-processing included)
  • ThresholdedRunningStatistics (complex output with post-processing included)
  • TemperatureSum

E.g.,

TEST_COUNT_LEVEL_CROSSINGS_PARAMETERS = [
    (
        {"data": (-1) * np.arange(12).reshape(2, 2, 3), "units": "degree_Celsius"},
        {"data": np.arange(12).reshape(2, 2, 3), "units": "degree_Celsius"},
        {"data": 0, "units": "degree_Celsius", "standard_name": "air_temperature"},
        np.array([[1, 2, 2], [2, 2, 2]]),
    ),  # ordinary np
]
parameter_names = "f_cube_tasmin, f_cube_tasmax, f_first_threshold, expected"

The index function is count_level_crossings, bellow the parameter list with the data we can see the parameter names. Such that,

f_cube_tasmin = {"data": (-1) * np.arange(12).reshape(2, 2, 3), "units": "degree_Celsius"}
f_cube_tasmax = {"data": np.arange(12).reshape(2, 2, 3), "units": "degree_Celsius"}
f_first_threshold = {"data": 0, "units": "degree_Celsius", "standard_name": "air_temperature"}
expected = np.array([[1, 2, 2], [2, 2, 2]])
Edited by Carolina Nilsson