From c1f77dcc07a990d44f8f278a17a7a174bfa005e2 Mon Sep 17 00:00:00 2001 From: BigTava Date: Mon, 30 Dec 2024 10:42:02 +0000 Subject: [PATCH] GSYE-719: fix flake8 ci --- gsy_framework/sim_results/carbon_emissions.py | 15 ++++++++------- tests/test_sim_results/test_carbon_emissions.py | 2 +- tox.ini | 9 ++++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gsy_framework/sim_results/carbon_emissions.py b/gsy_framework/sim_results/carbon_emissions.py index 4af5b9ec..ac181dff 100644 --- a/gsy_framework/sim_results/carbon_emissions.py +++ b/gsy_framework/sim_results/carbon_emissions.py @@ -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) @@ -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)"] diff --git a/tests/test_sim_results/test_carbon_emissions.py b/tests/test_sim_results/test_carbon_emissions.py index 6dae8238..57f5bbc2 100644 --- a/tests/test_sim_results/test_carbon_emissions.py +++ b/tests/test_sim_results/test_carbon_emissions.py @@ -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): diff --git a/tox.ini b/tox.ini index af7f310e..de9e7903 100644 --- a/tox.ini +++ b/tox.ini @@ -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