Skip to content

Commit

Permalink
NaN to nan and numpy<2
Browse files Browse the repository at this point in the history
  • Loading branch information
sgatto committed Sep 24, 2024
1 parent 75e7253 commit 1efbffa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions openstef/tasks/create_solar_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def fides(data: pd.DataFrame, all_forecasts: bool = False):
data = pd.DataFrame(index = index,
data = dict(load=np.sin(index.hour/24*np.pi)*np.random.uniform(0.7,1.7, 300)))
data['insolation'] = data.load * np.random.uniform(0.8, 1.2, len(index)) + 0.1
data.loc[int(len(index)/3*2):,"load"] = np.NaN
data.loc[int(len(index)/3*2):,"load"] = np.nan
"""
insolation_forecast = apply_fit_insol(data, add_to_df=False)
Expand Down Expand Up @@ -357,7 +357,7 @@ def apply_fit_insol(data, add_to_df=True, hours_delta=None, polynomial=False):
data = pd.DataFrame(index = index,
data = dict(load=np.sin(index.hour/24*np.pi)*np.random.uniform(0.7,1.7, len(index))))
data['insolation'] = data.load * np.random.uniform(0.8, 1.2, len(index)) + 0.1
data.loc[int(len(index)/3*2):,"load"] = np.NaN
data.loc[int(len(index)/3*2):,"load"] = np.nan
"""
colname = list(data)[0]
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ lightgbm~=3.3
matplotlib~=3.7
mlflow~=2.3
networkx~=3.1
numpy<2.0.0
optuna~=3.1
optuna-integration~=3.6
pandas~=2.2.0
Expand Down
6 changes: 3 additions & 3 deletions test/unit/tasks/test_calculate_kpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

# Prepare dataframe with nans to test low completeness
realised_load_nan = realised_load.copy()
realised_load_nan.loc[realised_load_nan.sample(frac=0.5).index, :] = np.NaN
realised_load_nan.loc[realised_load_nan.sample(frac=0.5).index, :] = np.nan

# Prepare dataframe with nans to test low completeness
predicted_load_nan = predicted_load.copy()
predicted_load_nan.loc[predicted_load_nan.sample(frac=0.5).index, :] = np.NaN
predicted_load_nan.loc[predicted_load_nan.sample(frac=0.5).index, :] = np.nan

prediction_job = TestData.get_prediction_job(pid=307)

Expand Down Expand Up @@ -106,7 +106,7 @@ def test_calc_kpi_for_specific_pid_poor_completeness_realized(self):
prediction_job["id"], realised_load_nan, predicted_load, realised_load_nan
)
t_ahead_keys = kpis.keys()
self.assertIs(kpis[list(t_ahead_keys)[0]]["rMAE"], np.NaN)
self.assertIs(kpis[list(t_ahead_keys)[0]]["rMAE"], np.nan)

# Test whether none is returned in case of poor completeness for predicted data
def test_calc_kpi_for_specific_pid_poor_completeness_predicted(self):
Expand Down

0 comments on commit 1efbffa

Please sign in to comment.