Skip to content

Commit

Permalink
Merge pull request #403 from timtroendle/feature-more-consistent-test…
Browse files Browse the repository at this point in the history
…-folder-structure

Update folder structure of tests
  • Loading branch information
brynpickering authored Jul 8, 2024
2 parents c47fdf2 + 482c9d1 commit 80b42e2
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
8 changes: 8 additions & 0 deletions tests/model/timeseries/demand/test_heat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def test_unscaled_heat(unscaled_space_heat_timeseries):
"""Expecting more space heating demand in winter than summer."""
# xarray to pandas as we need a newer xarray version (with flox) for `groupby` performance.
df = unscaled_space_heat_timeseries.space_heat.to_series()
hourly_space_monthly = df.groupby(df.index.get_level_values("time").month).sum()
hourly_space_winter = hourly_space_monthly.loc[[12, 1, 2]].sum()
hourly_space_summer = hourly_space_monthly.loc[[6, 7, 8]].sum()
assert (hourly_space_winter > hourly_space_summer).all()
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,3 @@ def test_cop_all_at_least_1(cop_timeseries):
assert (
cop_timeseries.stack() >= 1
).all(), "Found improbably low heat pump COP values (< 1)."


def test_unscaled_heat(unscaled_space_heat_timeseries):
"""Expecting more space heating demand in winter than summer."""
# xarray to pandas as we need a newer xarray version (with flox) for `groupby` performance.
df = unscaled_space_heat_timeseries.space_heat.to_series()
hourly_space_monthly = df.groupby(df.index.get_level_values("time").month).sum()
hourly_space_winter = hourly_space_monthly.loc[[12, 1, 2]].sum()
hourly_space_summer = hourly_space_monthly.loc[[6, 7, 8]].sum()
assert (hourly_space_winter > hourly_space_summer).all()
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os
from pathlib import Path

import numpy as np
import pandas as pd
Expand All @@ -14,7 +14,8 @@
filter_outliers,
)

THIS_DIR = os.path.dirname(__file__)
THIS_DIR = Path(__file__).parent
PATH_TO_RESOURCES = THIS_DIR.parent.parent / "resources"


class TestLoadHelperFunctions:
Expand Down Expand Up @@ -197,14 +198,13 @@ def _load(
"fill-29th-feb-from-28th": fill_29th_feb_from_28th,
"data-source-priority-order": list(data_source_priority_order),
}
path_to_raw_load = os.path.join(
THIS_DIR, "..", "resources", "national", "dummy_load.csv"
)
path_to_raw_load = PATH_TO_RESOURCES / "national" / "dummy_load.csv"

countries = ["ALB", "DEU"]
year = 2016

return clean_load_data(
path_to_raw_load, year, year, data_quality_config, countries
path_to_raw_load.as_posix(), year, year, data_quality_config, countries
)

return _load
Expand Down
File renamed without changes.

0 comments on commit 80b42e2

Please sign in to comment.