scripts: mini code cleanup (#140)

This commit is contained in:
Fabian Neumann 2020-03-16 15:55:01 +01:00 committed by GitHub
parent 2f85b0ede5
commit d57989c027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 3 additions and 8 deletions

View File

@ -94,8 +94,6 @@ def load_network_for_plots(fn, tech_costs, config, combine_hydro_ps=True):
import pypsa
from add_electricity import update_transmission_costs, load_costs
opts = config['plotting']
n = pypsa.Network(fn)
n.loads["carrier"] = n.loads.bus.map(n.buses.carrier) + " load"

View File

@ -66,7 +66,7 @@ import yaml
import pandas as pd
import geopandas as gpd
import numpy as np
import scipy as sp, scipy.spatial
import scipy as sp
from scipy.sparse import csgraph
from six import iteritems
from itertools import product

View File

@ -227,7 +227,7 @@ def busmap_for_n_clusters(n, n_clusters, solver_name, focus_weights=None, algori
elif algorithm == "louvain":
return prefix + busmap_by_louvain(reduce_network(n, x), n_clusters[x.name], **algorithm_kwds)
else:
raise ArgumentError("`algorithm` must be one of 'kmeans', 'spectral' or 'louvain'")
raise ValueError(f"`algorithm` must be one of 'kmeans', 'spectral' or 'louvain'. Is {algorithm}.")
return (n.buses.groupby(['country', 'sub_network'], group_keys=False, squeeze=True)
.apply(busmap_for_country).rename('busmap'))

View File

@ -17,7 +17,7 @@ Description
import logging
logger = logging.getLogger(__name__)
from _helpers import (load_network, aggregate_p, aggregate_costs,
from _helpers import (load_network_for_plots, aggregate_p, aggregate_costs,
configure_logging)
import pandas as pd

View File

@ -22,7 +22,6 @@ import pypsa
import pandas as pd
import matplotlib.pyplot as plt
import logging
def cum_p_nom_max(net, tech, country=None):
carrier_b = net.generators.carrier == tech

View File

@ -29,7 +29,6 @@ This rule, as a substitute for :mod:`build_natura_raster`, downloads an already
import logging
logger = logging.getLogger(__name__)
from pathlib import Path
from _helpers import progress_retrieve, configure_logging
if __name__ == "__main__":

View File

@ -47,7 +47,6 @@ from _helpers import configure_logging
import pypsa
import numpy as np
import re
from pathlib import Path
from vresutils.benchmark import memory_logger