Skip to content

Feature/holidays in industrial profile #125

Feature/holidays in industrial profile

Feature/holidays in industrial profile #125

Triggered via pull request August 1, 2024 13:55
Status Success
Total duration 33s
Artifacts 1

packaging.yml

on: pull_request
Matrix: build
Fit to window
Zoom out
Zoom in

Annotations

5 errors
/home/runner/work/demandlib/demandlib/src/demandlib/particular_profiles.py#L154
weekend_filter = self.dataframe["weekday"].isin(weekend) holiday_filter = self.dataframe["weekday"].isin(holiday) # Update 'ind' column based on day/night filters and # weekday/weekend/holiday conditions - self.dataframe.loc[day_filter & week_filter, "ind"] = \ - profile_factors["week"]["day"] - self.dataframe.loc[night_filter & week_filter, "ind"] = \ + self.dataframe.loc[day_filter & week_filter, "ind"] = profile_factors[ + "week" + ]["day"] + self.dataframe.loc[night_filter & week_filter, "ind"] = ( profile_factors["week"]["night"] - self.dataframe.loc[day_filter & weekend_filter, "ind"] = \ + ) + self.dataframe.loc[day_filter & weekend_filter, "ind"] = ( profile_factors["weekend"]["day"] - self.dataframe.loc[night_filter & weekend_filter, "ind"] = \ + ) + self.dataframe.loc[night_filter & weekend_filter, "ind"] = ( profile_factors["weekend"]["night"] - self.dataframe.loc[day_filter & holiday_filter, "ind"] = \ + ) + self.dataframe.loc[day_filter & holiday_filter, "ind"] = ( profile_factors["holiday"]["day"] - self.dataframe.loc[night_filter & holiday_filter, "ind"] = \ + ) + self.dataframe.loc[night_filter & holiday_filter, "ind"] = ( profile_factors["holiday"]["night"] + ) # Check for NAN values in the dataframe if self.dataframe["ind"].isnull().any(axis=0): logging.error("NAN value found in industrial load profile")
/home/runner/work/demandlib/demandlib/tests/test_particular_profiles.py#L9
class TestIndustrialLoadProfile: @classmethod def setup_class(cls): dt_index = pd.date_range( - datetime.datetime(2010, 1, 1, 0), - periods=24 * 7, - freq="1H" + datetime.datetime(2010, 1, 1, 0), periods=24 * 7, freq="1H" ) holidays = { datetime.date(2010, 1, 1): "New year", } cls.ilp = IndustrialLoadProfile(
/home/runner/work/demandlib/demandlib/tests/test_particular_profiles.py#L33
# ############### test with default values ############### df = self.ilp.simple_profile(1.0) # check factors in self.dataframe["ind"] # holiday - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-01 6:00"), "ind"] == 0.7 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-01 7:00"), "ind"] == 0.9 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-01 23:00"), "ind"] == 0.9 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-01 6:00"), "ind"] + == 0.7 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-01 7:00"), "ind"] + == 0.9 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-01 23:00"), "ind"] + == 0.9 + ) # weekend day - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-02 6:00"), "ind"] == 0.7 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-02 7:00"), "ind"] == 0.9 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-02 23:00"), "ind"] == 0.9 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-02 6:00"), "ind"] + == 0.7 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-02 7:00"), "ind"] + == 0.9 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-02 23:00"), "ind"] + == 0.9 + ) # week day - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-04 6:00"), "ind"] == 0.6 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-04 7:00"), "ind"] == 0.8 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-04 23:00"), "ind"] == 0.8 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-04 6:00"), "ind"] + == 0.6 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-04 7:00"), "ind"] + == 0.8 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-04 23:00"), "ind"] + == 0.8 + ) # check sum of factors to make sure not only the tested factors are # correct assert np.isclose(self.ilp.dataframe["ind"].sum(), 131.8)
/home/runner/work/demandlib/demandlib/tests/test_particular_profiles.py#L68
} week = [2, 3, 4, 5] weekend = [1, 6, 7] df = self.ilp.simple_profile( 1.0, - week=week, weekend=weekend, + week=week, + weekend=weekend, profile_factors=profile_factors, am=datetime.time(6, 30, 0), pm=datetime.time(22, 00, 0), ) # check factors in self.dataframe["ind"] # holiday - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-01 6:00"), "ind"] == 0.3 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-01 7:00"), "ind"] == 0.8 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-01 23:00"), "ind"] == 0.3 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-01 6:00"), "ind"] + == 0.3 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-01 7:00"), "ind"] + == 0.8 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-01 23:00"), "ind"] + == 0.3 + ) # weekend day - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-02 6:00"), "ind"] == 0.4 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-02 7:00"), "ind"] == 0.7 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-02 22:00"), "ind"] == 0.7 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-02 6:00"), "ind"] + == 0.4 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-02 7:00"), "ind"] + == 0.7 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-02 22:00"), "ind"] + == 0.7 + ) # Monday - now set to be weekend day - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-04 6:00"), "ind"] == 0.4 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-04 7:00"), "ind"] == 0.7 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-04 23:00"), "ind"] == 0.4 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-04 6:00"), "ind"] + == 0.4 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-04 7:00"), "ind"] + == 0.7 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-04 23:00"), "ind"] + == 0.4 + ) # week day - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-05 6:00"), "ind"] == 0.5 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-05 7:00"), "ind"] == 0.6 - assert self.ilp.dataframe.at[ - pd.Timestamp("2010-01-05 23:00"), "ind"] == 0.5 + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-05 6:00"), "ind"] + == 0.5 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-05 7:00"), "ind"] + == 0.6 + ) + assert ( + self.ilp.dataframe.at[pd.Timestamp("2010-01-05 23:00"), "ind"] + == 0.5 + ) # check sum of factors to make sure not only the tested factors are # correct assert np.isclose(self.ilp.dataframe["ind"].sum(), 99.2)
/home/runner/work/demandlib/demandlib/tests/test_particular_profiles.py#L141
1.0, profile_factors=profile_factors ) # check factors in self.dataframe["ind"] # holiday - now treated as Sunday - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-01 6:00"), "ind"] == 0.4 - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-01 7:00"), "ind"] == 0.7 - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-01 23:00"), "ind"] == 0.7 + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-01 6:00"), "ind" + ] + == 0.4 + ) + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-01 7:00"), "ind" + ] + == 0.7 + ) + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-01 23:00"), "ind" + ] + == 0.7 + ) # weekend day - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-02 6:00"), "ind"] == 0.4 - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-02 7:00"), "ind"] == 0.7 - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-02 23:00"), "ind"] == 0.7 + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-02 6:00"), "ind" + ] + == 0.4 + ) + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-02 7:00"), "ind" + ] + == 0.7 + ) + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-02 23:00"), "ind" + ] + == 0.7 + ) # week day - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-04 6:00"), "ind"] == 0.5 - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-04 7:00"), "ind"] == 0.6 - assert self.ilp_holiday.dataframe.at[ - pd.Timestamp("2010-01-04 23:00"), "ind"] == 0.6 + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-04 6:00"), "ind" + ] + == 0.5 + ) + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-04 7:00"), "ind" + ] + == 0.6 + ) + assert ( + self.ilp_holiday.dataframe.at[ + pd.Timestamp("2010-01-04 23:00"), "ind" + ] + == 0.6 + ) # check sum of factors to make sure not only the tested factors are # correct assert np.isclose(self.ilp_holiday.dataframe["ind"].sum(), 98.9)

Artifacts

Produced during runtime
Name Size
tox-gh-actions-dist Expired
203 KB