Skip to content

Commit

Permalink
tests: add maximum duration test
Browse files Browse the repository at this point in the history
  • Loading branch information
abhidg committed May 28, 2024
1 parent 904b241 commit 5851f9f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_windowed_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@ def test_minimise_average(sample_data):
)
assert result == expected

def test_maximum_duration(sample_data):
window_size = 95 # corresponds to 2850 minutes
# Data points separated by 30 minutes intervals
duration = window_size * 30
result = min(WindowedForecast(sample_data, duration, start=sample_data[0].datetime))

# Intensity point estimates over best runtime period
# In this case, the entire period is selected which is 2850 minutes long
v = [s.value for s in sample_data]
expected = CarbonIntensityAverageEstimate(
start=datetime.fromisoformat("2023-05-04T12:30+00:00"),
end=datetime.fromisoformat("2023-05-06T12:00+00:00"),
value=sum([0.5 * (a + b) for a, b in zip(v[:-1], v[1:])]) / window_size,
)
assert result == expected


def test_minimise_average_bst(sample_data):
# We should get a start time in BST if we provide the starting time
Expand Down

0 comments on commit 5851f9f

Please sign in to comment.