Skip to content

Commit

Permalink
Fix line in time fix (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulf81 authored Oct 21, 2024
1 parent 44e9bde commit 69b818f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion flasc/utilities/tuner_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def replicate_nan_values(
common_columns = df_1.columns.intersection(df_2.columns)

# Remove the time column from the common columns if included
common_columns.drop("time", errors="ignore")
common_columns = common_columns.drop("time", errors="ignore")

# Use assign to create a new DataFrame with NaN values replaced
df_2_updated = df_2.assign(
Expand Down
36 changes: 36 additions & 0 deletions tests/model_tuning_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,42 @@ def test_replicate_nan_values(self):
assert result_df.equals(expected_df_2)
assert df_1.equals(expected_df_1)

def test_replicate_nan_values_with_time(self):
# Sample dataframes
data_1 = {"A": [1, 2, np.nan, 4], "B": [5, np.nan, 7, 8], "C": [np.nan, 1, 1, 1]}
data_2 = {"A": [10, 20, 30, 40], "B": [50, 60, 70, 80]}
df_1 = pd.DataFrame(data_1)
df_2 = pd.DataFrame(data_2)

df_1["time"] = pd.date_range("2021-01-01", periods=4)
df_2["time"] = df_1["time"]

# Call the function to replicate NaN values
result_df = replicate_nan_values(df_1, df_2)

print(result_df)

# Expected output
expected_df_1 = pd.DataFrame(
{
"A": [1, 2, np.nan, 4],
"B": [5, np.nan, 7, 8],
"C": [np.nan, 1, 1, 1],
"time": pd.date_range("2021-01-01", periods=4),
}
)
expected_df_2 = pd.DataFrame(
{
"A": [10, 20, np.nan, 40],
"B": [50, np.nan, 70, 80],
"time": pd.date_range("2021-01-01", periods=4),
}
)

# Check if the result matches the expected output
assert result_df.equals(expected_df_2)
assert df_1.equals(expected_df_1)

def test_evaluate_overall_wake_loss(self):
# Create a sample DataFrame for testing
data = {"pow_ref": [5, 2, 3], "pow_test": [1, 2, 2]}
Expand Down

0 comments on commit 69b818f

Please sign in to comment.