Skip to content

Commit

Permalink
GSYE-719: fix flake8 ci
Browse files Browse the repository at this point in the history
  • Loading branch information
BigTava committed Dec 30, 2024
1 parent e8b9312 commit c1f77dc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
15 changes: 8 additions & 7 deletions gsy_framework/sim_results/carbon_emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ def calculate_carbon_ratio(
df = self._query_generation_per_plant(country_code, start, end)

generation_types = df.iloc[0].iloc[1:]
carbon_emission_per_plant = lambda x: GENERATION_PLANT_TO_CARBON_EMISSIONS[x][
stat
] # noqa: E731 C3001
# fmt: off
carbon_emission_per_plant = lambda x: GENERATION_PLANT_TO_CARBON_EMISSIONS[ # noqa: E731
x
][stat]
# fmt: on
emissions_map = generation_types.map(carbon_emission_per_plant)

df_numeric = df.iloc[2:].reset_index(drop=True)
Expand Down Expand Up @@ -204,11 +206,10 @@ def update(self, country_code: str, time_slot: duration, results_list: List[Dict
area_result = result["results"][area_uuid]
target_timestamp = pd.Timestamp(current_market).tz_localize("UTC")

nearest_index = df_carbon_ratio.index.get_indexer( # the closest timestamp to the target_timestamp
# the closest timestamp to the target_timestamp
nearest_index = df_carbon_ratio.index.get_indexer(
[target_timestamp], method="nearest"
)[
0
]
)[0]
nearest_row = df_carbon_ratio.iloc[nearest_index]

carbon_ratio = nearest_row["Ratio (gCO2eq/kWh)"]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sim_results/test_carbon_emissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def setup_method(self):
self.house2_uuid = "1521b3f4-c655-4ab8-b8b7-94f14f7279a0"

@patch(
"gsy_framework.sim_results.carbon_emissions.CarbonEmissionsHandler._query_generation_per_plant",
"gsy_framework.sim_results.carbon_emissions.CarbonEmissionsHandler._query_generation_per_plant", # noqa: E501
lambda *args: pd.read_csv("tests/static/generation_per_plant_entsoe_BE_20210801.csv"),
)
def test_update_calculates_carbon_emissions_correctly(self):
Expand Down
9 changes: 8 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ mintoxversion = 2.3
envlist = py38

[testenv]
passenv = LANG TERM LANGUAGE LC_ALL LD_LIBRARY_PATH GITHUB_ACCESS_TOKEN TARGET_BRANCH
passenv =
LANG
TERM
LANGUAGE
LC_ALL
LD_LIBRARY_PATH
GITHUB_ACCESS_TOKEN
TARGET_BRANCH
deps =
pip-tools
coverage
Expand Down

0 comments on commit c1f77dc

Please sign in to comment.