remove six dependency (#245)
This commit is contained in:
parent
f5a0d566d9
commit
11af828c39
@ -156,7 +156,6 @@ def aggregate_p_curtailed(n):
|
||||
])
|
||||
|
||||
def aggregate_costs(n, flatten=False, opts=None, existing_only=False):
|
||||
from six import iterkeys, itervalues
|
||||
|
||||
components = dict(Link=("p_nom", "p0"),
|
||||
Generator=("p_nom", "p"),
|
||||
@ -167,8 +166,8 @@ def aggregate_costs(n, flatten=False, opts=None, existing_only=False):
|
||||
|
||||
costs = {}
|
||||
for c, (p_nom, p_attr) in zip(
|
||||
n.iterate_components(iterkeys(components), skip_empty=False),
|
||||
itervalues(components)
|
||||
n.iterate_components(components.keys(), skip_empty=False),
|
||||
components.values()
|
||||
):
|
||||
if c.df.empty: continue
|
||||
if not existing_only: p_nom += "_opt"
|
||||
|
@ -74,7 +74,6 @@ import scipy as sp
|
||||
import networkx as nx
|
||||
|
||||
from scipy.sparse import csgraph
|
||||
from six import iteritems
|
||||
from itertools import product
|
||||
|
||||
from shapely.geometry import Point, LineString
|
||||
@ -268,13 +267,13 @@ def _apply_parameter_corrections(n):
|
||||
|
||||
if corrections is None: return
|
||||
|
||||
for component, attrs in iteritems(corrections):
|
||||
for component, attrs in corrections.items():
|
||||
df = n.df(component)
|
||||
oid = _get_oid(df)
|
||||
if attrs is None: continue
|
||||
|
||||
for attr, repls in iteritems(attrs):
|
||||
for i, r in iteritems(repls):
|
||||
for attr, repls in attrs.items():
|
||||
for i, r in repls.items():
|
||||
if i == 'oid':
|
||||
r = oid.map(repls["oid"]).dropna()
|
||||
elif i == 'index':
|
||||
|
@ -73,7 +73,7 @@ from _helpers import configure_logging
|
||||
import os
|
||||
import numpy as np
|
||||
from operator import attrgetter
|
||||
from six.moves import reduce
|
||||
from functools import reduce
|
||||
from itertools import takewhile
|
||||
|
||||
import pandas as pd
|
||||
|
@ -135,7 +135,7 @@ import pyomo.environ as po
|
||||
import matplotlib.pyplot as plt
|
||||
import seaborn as sns
|
||||
|
||||
from six.moves import reduce
|
||||
from functools import reduce
|
||||
|
||||
from pypsa.networkclustering import (busmap_by_kmeans, busmap_by_spectral_clustering,
|
||||
_make_consense, get_clustering_from_busmap)
|
||||
|
@ -60,7 +60,6 @@ import os
|
||||
import pypsa
|
||||
import pandas as pd
|
||||
|
||||
from six import iteritems
|
||||
from add_electricity import load_costs, update_transmission_costs
|
||||
|
||||
idx = pd.IndexSlice
|
||||
@ -386,7 +385,7 @@ def make_summaries(networks_dict, country='all'):
|
||||
for output in outputs:
|
||||
dfs[output] = pd.DataFrame(columns=columns,dtype=float)
|
||||
|
||||
for label, filename in iteritems(networks_dict):
|
||||
for label, filename in networks_dict.items():
|
||||
print(label, filename)
|
||||
if not os.path.exists(filename):
|
||||
print("does not exist!!")
|
||||
@ -417,7 +416,7 @@ def make_summaries(networks_dict, country='all'):
|
||||
def to_csv(dfs):
|
||||
dir = snakemake.output[0]
|
||||
os.makedirs(dir, exist_ok=True)
|
||||
for key, df in iteritems(dfs):
|
||||
for key, df in dfs.items():
|
||||
df.to_csv(os.path.join(dir, f"{key}.csv"))
|
||||
|
||||
|
||||
|
@ -25,7 +25,6 @@ from _helpers import (load_network_for_plots, aggregate_p, aggregate_costs,
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
from six.moves import zip
|
||||
|
||||
import cartopy.crs as ccrs
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -62,7 +62,6 @@ import re
|
||||
import pypsa
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
from six import iteritems
|
||||
|
||||
from add_electricity import load_costs, update_transmission_costs
|
||||
|
||||
@ -145,7 +144,7 @@ def average_every_nhours(n, offset):
|
||||
|
||||
for c in n.iterate_components():
|
||||
pnl = getattr(m, c.list_name+"_t")
|
||||
for k, df in iteritems(c.pnl):
|
||||
for k, df in c.pnl.items():
|
||||
if not df.empty:
|
||||
pnl[k] = df.resample(offset).mean()
|
||||
|
||||
|
@ -93,8 +93,7 @@ import numpy as np
|
||||
import scipy as sp
|
||||
from scipy.sparse.csgraph import connected_components, dijkstra
|
||||
|
||||
from six import iteritems
|
||||
from six.moves import reduce
|
||||
from functools import reduce
|
||||
|
||||
import pypsa
|
||||
from pypsa.io import import_components_from_dataframe, import_series_from_dataframe
|
||||
@ -193,7 +192,7 @@ def _aggregate_and_move_components(n, busmap, connection_costs_to_bus, aggregate
|
||||
n.mremove(c, n.df(c).index)
|
||||
|
||||
import_components_from_dataframe(n, df, c)
|
||||
for attr, df in iteritems(pnl):
|
||||
for attr, df in pnl.items():
|
||||
if not df.empty:
|
||||
import_series_from_dataframe(n, df, c, attr)
|
||||
|
||||
@ -237,7 +236,7 @@ def simplify_links(n):
|
||||
if len(G.adj[m]) > 2 or (set(G.adj[m]) - nodes)}
|
||||
|
||||
for u in supernodes:
|
||||
for m, ls in iteritems(G.adj[u]):
|
||||
for m, ls in G.adj[u].items():
|
||||
if m not in nodes or m in seen: continue
|
||||
|
||||
buses = [u, m]
|
||||
@ -245,7 +244,7 @@ def simplify_links(n):
|
||||
|
||||
while m not in (supernodes | seen):
|
||||
seen.add(m)
|
||||
for m2, ls in iteritems(G.adj[m]):
|
||||
for m2, ls in G.adj[m].items():
|
||||
if m2 in seen or m2 == u: continue
|
||||
buses.append(m2)
|
||||
links.append(list(ls)) # [name for name in ls])
|
||||
|
Loading…
Reference in New Issue
Block a user