[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-01-29 18:31:03 +00:00
parent 3ceffabc94
commit d2f2d4ab0b
5 changed files with 55 additions and 41 deletions

View File

@ -607,21 +607,28 @@ def calculate_costs(u_values, l, cost_retro, window_assumptions): # noqa: E741
"""
return u_values.apply(
lambda x: (
cost_retro.loc[x.name[3], "cost_var"]
* 100
* float(l)
* l_weight.loc[x.name[3]].iloc[0]
+ cost_retro.loc[x.name[3], "cost_fix"]
)
* x.A_element
/ x.A_C_Ref
if x.name[3] != "Window"
else (
(window_cost(x[f"new_U_{l}"], cost_retro, window_assumptions) * x.A_element)
(
cost_retro.loc[x.name[3], "cost_var"]
* 100
* float(l)
* l_weight.loc[x.name[3]].iloc[0]
+ cost_retro.loc[x.name[3], "cost_fix"]
)
* x.A_element
/ x.A_C_Ref
)
if x.value > window_limit(float(l), window_assumptions)
else 0,
if x.name[3] != "Window"
else (
(
(
window_cost(x[f"new_U_{l}"], cost_retro, window_assumptions)
* x.A_element
)
/ x.A_C_Ref
)
if x.value > window_limit(float(l), window_assumptions)
else 0
)
),
axis=1,
)
@ -648,12 +655,14 @@ def calculate_new_u(u_values, l, l_weight, window_assumptions, k=0.035): # noqa
k: thermal conductivity
"""
return u_values.apply(
lambda x: k / ((k / x.value) + (float(l) * l_weight.loc[x.name[3]]))
if x.name[3] != "Window"
else (
min(x.value, u_retro_window(float(l), window_assumptions))
if x.value > window_limit(float(l), window_assumptions)
else x.value
lambda x: (
k / ((k / x.value) + (float(l) * l_weight.loc[x.name[3]]))
if x.name[3] != "Window"
else (
min(x.value, u_retro_window(float(l), window_assumptions))
if x.value > window_limit(float(l), window_assumptions)
else x.value
)
),
axis=1,
)

View File

@ -281,12 +281,14 @@ def plot_balances():
# remove trailing link ports
df.index = [
i[:-1]
if (
(i not in ["co2", "NH3", "H2"])
and (i[-1:] in ["0", "1", "2", "3", "4"])
(
i[:-1]
if (
(i not in ["co2", "NH3", "H2"])
and (i[-1:] in ["0", "1", "2", "3", "4"])
)
else i
)
else i
for i in df.index
]

View File

@ -458,9 +458,9 @@ def update_wind_solar_costs(n, costs):
)
)
n.generators.loc[
n.generators.carrier == tech, "capital_cost"
] = capital_cost.rename(index=lambda node: node + " " + tech)
n.generators.loc[n.generators.carrier == tech, "capital_cost"] = (
capital_cost.rename(index=lambda node: node + " " + tech)
)
def add_carrier_buses(n, carrier, nodes=None):
@ -2932,9 +2932,11 @@ def add_industry(n, costs):
nodes,
suffix=" low-temperature heat for industry",
bus=[
node + " urban central heat"
if node + " urban central heat" in n.buses.index
else node + " services urban decentral heat"
(
node + " urban central heat"
if node + " urban central heat" in n.buses.index
else node + " services urban decentral heat"
)
for node in nodes
],
carrier="low-temperature heat for industry",
@ -3529,10 +3531,9 @@ def lossy_bidirectional_links(n, carrier, efficiencies={}):
)
n.links.loc[carrier_i, "p_min_pu"] = 0
n.links.loc[
carrier_i, "efficiency"
] = efficiency_static * efficiency_per_1000km ** (
n.links.loc[carrier_i, "length"] / 1e3
n.links.loc[carrier_i, "efficiency"] = (
efficiency_static
* efficiency_per_1000km ** (n.links.loc[carrier_i, "length"] / 1e3)
)
rev_links = (
n.links.loc[carrier_i].copy().rename({"bus0": "bus1", "bus1": "bus0"}, axis=1)

View File

@ -468,9 +468,9 @@ def aggregate_to_substations(n, aggregation_strategies=dict(), buses_i=None):
dijkstra(adj, directed=False, indices=bus_indexer), buses_i, n.buses.index
)
dist[
buses_i
] = np.inf # bus in buses_i should not be assigned to different bus in buses_i
dist[buses_i] = (
np.inf
) # bus in buses_i should not be assigned to different bus in buses_i
for c in n.buses.country.unique():
incountry_b = n.buses.country == c

View File

@ -703,9 +703,11 @@ def add_lossy_bidirectional_link_constraints(n):
def get_backward_i(forward_i):
return pd.Index(
[
re.sub(r"-(\d{4})$", r"-reversed-\1", s)
if re.search(r"-\d{4}$", s)
else s + "-reversed"
(
re.sub(r"-(\d{4})$", r"-reversed-\1", s)
if re.search(r"-\d{4}$", s)
else s + "-reversed"
)
for s in forward_i
]
)