Skip to content

Commit

Permalink
run pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tanushree04 committed Sep 30, 2024
1 parent cf3c186 commit 5aec6be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
14 changes: 8 additions & 6 deletions geojson_modelica_translator/results_ghp.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,19 @@ def adjust_year(dt):
if len(values) < len(adjusted_time_values):
values.extend([None] * (len(adjusted_time_values) - len(values)))
elif len(values) > len(adjusted_time_values):
values = values[: len(adjusted_time_values)]
data_for_df[var] = values
trimmed_values = values[: len(adjusted_time_values)]
data_for_df[var] = trimmed_values
else:
data_for_df[var] = values

df = pd.DataFrame(data_for_df)
df_values = pd.DataFrame(data_for_df)

# Convert 'Datetime' to datetime and set it as index
df["Datetime"] = pd.to_datetime(df["Datetime"])
df.set_index("Datetime", inplace=True)
df_values["Datetime"] = pd.to_datetime(df_values["Datetime"])
df_values = df_values.set_index("Datetime")

# Resample to 15-minute data, taking the first occurrence for each interval
df_resampled = df.resample("15min").first().reset_index()
df_resampled = df_values.resample("15min").first().reset_index()

# Format datetime to desired format
df_resampled["Datetime"] = df_resampled["Datetime"].dt.strftime("%m/%d/%Y %H:%M")
Expand Down
26 changes: 12 additions & 14 deletions tests/geojson_modelica_translator/test_results_ghp.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ def test_result(self):
assert csv_file_path.exists(), f"File does not exist at path: {csv_file_path}"

# Read the CSV file into a DataFrame
df = pd.read_csv(csv_file_path)
csv_data = pd.read_csv(csv_file_path)

assert "Datetime" in df.columns, "The 'Datetime' column is missing from the CSV file."
assert "Datetime" in csv_data.columns, "The 'Datetime' column is missing from the CSV file."

assert (
"heating_electric_power_d55aa383" in df.columns
"heating_electric_power_d55aa383" in csv_data.columns
), "The heating_electric_power column is missing from the CSV file."

assert "pump_power_3da62a1d" in df.columns, "The pump_power column is missing from the CSV file."
assert "pump_power_3da62a1d" in csv_data.columns, "The pump_power column is missing from the CSV file."

assert (
"electrical_power_consumed" in df.columns
"electrical_power_consumed" in csv_data.columns
), "The electrical_power_consumed column is missing from the CSV file."

def test_result_multiple_ghp(self):
Expand All @@ -74,28 +74,26 @@ def test_result_multiple_ghp(self):
assert csv_file_path.exists(), f"File does not exist at path: {csv_file_path}"

# Read the CSV file into a DataFrame
df = pd.read_csv(csv_file_path)
csv_data_multiple = pd.read_csv(csv_file_path)

assert "Datetime" in df.columns, "The 'Datetime' column is missing from the CSV file."
assert "Datetime" in csv_data_multiple.columns, "The 'Datetime' column is missing from the CSV file."

# Check if any columns contain the "heating_electric_power_" substring
heating_electric_power = [col for col in df.columns if "heating_electric_power_" in col]
heating_electric_power = [col for col in csv_data_multiple.columns if "heating_electric_power_" in col]

assert heating_electric_power, "No columns with 'heating_electric_power' found in the CSV file."

assert (
len(heating_electric_power) == 13
), f"Expected 13 columns with 'heating_electric_power_' but found {len(heating_electric_power)}. Missing or extra columns in the CSV file."
), f"Expected 13 columns with 'heating_electric_power_' but found {len(heating_electric_power)}."

pump_power = [col for col in df.columns if "pump_power_" in col]
pump_power = [col for col in csv_data_multiple.columns if "pump_power_" in col]

# Assert that there is at least one column with the substring
assert pump_power, "No columns with 'pump_power' found in the CSV file."

assert (
len(pump_power) == 26
), f"Expected 26 columns with 'pump_power' but found {len(pump_power)}. Missing or extra columns in the CSV file."
assert len(pump_power) == 26, f"Expected 26 columns with 'pump_power' but found {len(pump_power)}."

assert (
"electrical_power_consumed" in df.columns
"electrical_power_consumed" in csv_data_multiple.columns
), "The electrical_power_consumed column is missing from the CSV file."

0 comments on commit 5aec6be

Please sign in to comment.