fix linting: run ruff

This commit is contained in:
Fabian 2024-01-19 10:34:49 +01:00
parent 195966af45
commit f876d78ed4
13 changed files with 7 additions and 23 deletions

View File

@ -15,8 +15,6 @@ import pandas as pd
import pytz import pytz
import requests import requests
import yaml import yaml
from pypsa.components import component_attrs, components
from pypsa.descriptors import Dict
from tqdm import tqdm from tqdm import tqdm
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -121,7 +121,7 @@ def add_brownfield(n, n_p, year):
def disable_grid_expansion_if_LV_limit_hit(n): def disable_grid_expansion_if_LV_limit_hit(n):
if not "lv_limit" in n.global_constraints.index: if "lv_limit" not in n.global_constraints.index:
return return
total_expansion = ( total_expansion = (
@ -133,7 +133,7 @@ def disable_grid_expansion_if_LV_limit_hit(n):
# allow small numerical differences # allow small numerical differences
if lv_limit - total_expansion < 1: if lv_limit - total_expansion < 1:
logger.info(f"LV is already reached, disabling expansion and LV limit") logger.info("LV is already reached, disabling expansion and LV limit")
extendable_acs = n.lines.query("s_nom_extendable").index extendable_acs = n.lines.query("s_nom_extendable").index
n.lines.loc[extendable_acs, "s_nom_extendable"] = False n.lines.loc[extendable_acs, "s_nom_extendable"] = False
n.lines.loc[extendable_acs, "s_nom"] = n.lines.loc[extendable_acs, "s_nom_min"] n.lines.loc[extendable_acs, "s_nom"] = n.lines.loc[extendable_acs, "s_nom_min"]

View File

@ -42,7 +42,6 @@ Outputs
import logging import logging
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
import dateutil
import numpy as np import numpy as np
import pandas as pd import pandas as pd
from _helpers import configure_logging from _helpers import configure_logging

View File

@ -50,7 +50,6 @@ With a heat balance considering the maximum temperature threshold of the transmi
the maximal possible capacity factor "s_max_pu" for each transmission line at each time step is calculated. the maximal possible capacity factor "s_max_pu" for each transmission line at each time step is calculated.
""" """
import logging
import re import re
import atlite import atlite

View File

@ -340,7 +340,7 @@ if __name__ == "__main__":
f"Completed weighted capacity factor time series calculation ({duration:2.2f}s)" f"Completed weighted capacity factor time series calculation ({duration:2.2f}s)"
) )
logger.info(f"Calculating maximal capacity per bus") logger.info("Calculating maximal capacity per bus")
p_nom_max = capacity_per_sqkm * availability @ area p_nom_max = capacity_per_sqkm * availability @ area
logger.info("Calculate average distances.") logger.info("Calculate average distances.")

View File

@ -6,8 +6,6 @@
Copy used configuration files and important scripts for archiving. Copy used configuration files and important scripts for archiving.
""" """
from pathlib import Path
from shutil import copy
import yaml import yaml

View File

@ -12,15 +12,9 @@ other metrics.
import numpy as np import numpy as np
import pandas as pd import pandas as pd
import pypsa import pypsa
from make_summary import ( from make_summary import assign_carriers, assign_locations
assign_carriers,
assign_locations,
calculate_cfs,
calculate_nodal_cfs,
calculate_nodal_costs,
)
from prepare_sector_network import prepare_costs from prepare_sector_network import prepare_costs
from pypsa.descriptors import get_active_assets, nominal_attrs from pypsa.descriptors import get_active_assets
from six import iteritems from six import iteritems
idx = pd.IndexSlice idx = pd.IndexSlice

View File

@ -903,7 +903,6 @@ def plot_series(network, carrier="AC", name="test"):
carrier, carrier,
start, start,
stop, stop,
name,
), ),
transparent=True, transparent=True,
) )

View File

@ -12,7 +12,6 @@ logger = logging.getLogger(__name__)
import matplotlib.gridspec as gridspec import matplotlib.gridspec as gridspec
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np
import pandas as pd import pandas as pd
plt.style.use("ggplot") plt.style.use("ggplot")

View File

@ -9,7 +9,6 @@ import pandas as pd
import pypsa import pypsa
import seaborn as sns import seaborn as sns
from _helpers import configure_logging from _helpers import configure_logging
from pypsa.statistics import get_bus_and_carrier
sns.set_theme("paper", style="whitegrid") sns.set_theme("paper", style="whitegrid")

View File

@ -58,7 +58,6 @@ Description
""" """
import logging import logging
import re
import numpy as np import numpy as np
import pandas as pd import pandas as pd

View File

@ -86,7 +86,7 @@ The rule :mod:`simplify_network` does up to four things:
""" """
import logging import logging
from functools import partial, reduce from functools import reduce
import numpy as np import numpy as np
import pandas as pd import pandas as pd

View File

@ -690,7 +690,7 @@ def add_battery_constraints(n):
def add_lossy_bidirectional_link_constraints(n): def add_lossy_bidirectional_link_constraints(n):
if not n.links.p_nom_extendable.any() or not "reversed" in n.links.columns: if not n.links.p_nom_extendable.any() or "reversed" not in n.links.columns:
return return
n.links["reversed"] = n.links.reversed.fillna(0).astype(bool) n.links["reversed"] = n.links.reversed.fillna(0).astype(bool)