Skip to content

Commit

Permalink
Reformat "emobility/**/model_timeseries.py"
Browse files Browse the repository at this point in the history
There's some interesting stuff in here. First, some of the lines, the
ones within the `# fmt: on`/`# fmt: off` blocks, could not be formatted
by "black" due to psf/black#510. Second, I had to wrestle with "isort"
quite a bit because it kept formatting the imports to be too long so I
had to resort to the `# noqa: E501` solution. Last but not least, if an
import is only used in a docstring, "flake8" doesn't seem to recognize
it as used.
  • Loading branch information
gnn committed Sep 7, 2022
1 parent 7876b1f commit 81bca5f
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
import pandas as pd

from egon.data import db
from egon.data.datasets.emobility.motorized_individual_travel.db_classes import (
from egon.data.datasets.emobility.motorized_individual_travel import ( # noqa: F401, E501 (Used, but only in a docstring. Also, "isort" forces the long line by moving the comment to the import line.)
MotorizedIndividualTravel,
)
from egon.data.datasets.emobility.motorized_individual_travel.db_classes import ( # noqa: E501 (Can't do anything about the long module hierarchy.)
EgonEvMvGridDistrict,
EgonEvPool,
EgonEvTrip,
Expand Down Expand Up @@ -93,7 +96,7 @@ def data_preprocessing(
# charging capacity in MVA
ev_data_df = ev_data_df.assign(
charging_capacity_grid_MW=(
ev_data_df.charging_capacity_grid / 10 ** 3
ev_data_df.charging_capacity_grid / 10**3
),
minimum_charging_time=(
ev_data_df.charging_demand
Expand Down Expand Up @@ -619,7 +622,11 @@ def write_link(scenario_name: str) -> None:
carrier="BEV charger",
efficiency=float(run_config.eta_cp),
p_nom=(
load_time_series_df.simultaneous_plugged_in_charging_capacity.max()
# fmt: off
load_time_series_df
.simultaneous_plugged_in_charging_capacity
.max()
# fmt: on
),
p_nom_extendable=False,
p_nom_min=0,
Expand All @@ -641,7 +648,11 @@ def write_link(scenario_name: str) -> None:
temp_id=1,
p_min_pu=None,
p_max_pu=(
hourly_load_time_series_df.ev_availability.to_list()
# fmt: off
hourly_load_time_series_df
.ev_availability
.to_list()
# fmt: on
),
)
)
Expand Down Expand Up @@ -744,7 +755,11 @@ def write_load(
scenario_name=scenario_name,
connection_bus_id=emob_bus_id,
load_ts=(
hourly_load_time_series_df.driving_load_time_series.to_list()
# fmt: off
hourly_load_time_series_df
.driving_load_time_series
.to_list()
# fmt: on
),
)
else:
Expand Down Expand Up @@ -840,9 +855,9 @@ def write_to_file():

# Write to database: regular and noflex scenario
write_to_db(write_noflex_model=False)
print(' Writing flex scenario...')
print(" Writing flex scenario...")
if write_noflex_model is True:
print(' Writing noflex scenario...')
print(" Writing noflex scenario...")
write_to_db(write_noflex_model=True)

# Export to working dir if requested
Expand Down Expand Up @@ -930,7 +945,7 @@ def generate_model_data_bunch(scenario_name: str, bunch: range) -> None:
Note: `bunch` is NOT a list of grid districts but is used for slicing
the ordered list (by bus_id) of grid districts! This is used for
parallelization. See
:meth:`egon.data.datasets.emobility.motorized_individual_travel.MotorizedIndividualTravel.generate_model_data_tasks`
:meth:`MotorizedIndividualTravel.generate_model_data_tasks`
"""
# Get list of grid districts / substations for this bunch
mvgd_bus_ids = load_grid_district_ids().iloc[bunch]
Expand Down

0 comments on commit 81bca5f

Please sign in to comment.